您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

43 行
1.6 KiB

  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
  5. //
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  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.
  13. package prometheus
  14. // UntypedOpts is an alias for Opts. See there for doc comments.
  15. type UntypedOpts Opts
  16. // UntypedFunc works like GaugeFunc but the collected metric is of type
  17. // "Untyped". UntypedFunc is useful to mirror an external metric of unknown
  18. // type.
  19. //
  20. // To create UntypedFunc instances, use NewUntypedFunc.
  21. type UntypedFunc interface {
  22. Metric
  23. Collector
  24. }
  25. // NewUntypedFunc creates a new UntypedFunc based on the provided
  26. // UntypedOpts. The value reported is determined by calling the given function
  27. // from within the Write method. Take into account that metric collection may
  28. // happen concurrently. If that results in concurrent calls to Write, like in
  29. // the case where an UntypedFunc is directly registered with Prometheus, the
  30. // provided function must be concurrency-safe.
  31. func NewUntypedFunc(opts UntypedOpts, function func() float64) UntypedFunc {
  32. return newValueFunc(NewDesc(
  33. BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
  34. opts.Help,
  35. nil,
  36. opts.ConstLabels,
  37. ), UntypedValue, function)
  38. }