1 // Copyright 2014 The Prometheus Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
16 // UntypedOpts is an alias for Opts. See there for doc comments.
19 // UntypedFunc works like GaugeFunc but the collected metric is of type
20 // "Untyped". UntypedFunc is useful to mirror an external metric of unknown
23 // To create UntypedFunc instances, use NewUntypedFunc.
24 type UntypedFunc interface {
29 // NewUntypedFunc creates a new UntypedFunc based on the provided
30 // UntypedOpts. The value reported is determined by calling the given function
31 // from within the Write method. Take into account that metric collection may
32 // happen concurrently. If that results in concurrent calls to Write, like in
33 // the case where an UntypedFunc is directly registered with Prometheus, the
34 // provided function must be concurrency-safe.
35 func NewUntypedFunc(opts UntypedOpts, function func() float64) UntypedFunc {
36 return newValueFunc(NewDesc(
37 BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
41 ), UntypedValue, function)