Documentation
¶
Index ¶
- Constants
- func BuildCompliantName(metric pmetric.Metric, namespace string, addMetricSuffixes bool) string
- func CleanUpString(s string) string
- func NormalizeLabel(label string) string
- func RemovePromForbiddenRunes(s string) string
- func TrimPromSuffixes(promName string, metricType pmetric.MetricType, unit string) string
- func UnitWordToUCUM(unit string) string
Constants ¶
const ( // MetricMetadataTypeKey is the key used to store the original Prometheus // type in metric metadata: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#metric-metadata MetricMetadataTypeKey = "prometheus.type" // ExemplarTraceIDKey is the key used to store the trace ID in Prometheus // exemplars: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#exemplars ExemplarTraceIDKey = "trace_id" // ExemplarSpanIDKey is the key used to store the Span ID in Prometheus // exemplars: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#exemplars ExemplarSpanIDKey = "span_id" // ScopeInfoMetricName is the name of the metric used to preserve scope // attributes in Prometheus format: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope ScopeInfoMetricName = "otel_scope_info" // ScopeNameLabelKey is the name of the label key used to identify the name // of the OpenTelemetry scope which produced the metric: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope ScopeNameLabelKey = "otel_scope_name" // ScopeVersionLabelKey is the name of the label key used to identify the // version of the OpenTelemetry scope which produced the metric: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope ScopeVersionLabelKey = "otel_scope_version" // TargetInfoMetricName is the name of the metric used to preserve resource // attributes in Prometheus format: // https://github.com/open-telemetry/opentelemetry-specification/blob/e6eccba97ebaffbbfad6d4358408a2cead0ec2df/specification/compatibility/prometheus_and_openmetrics.md#resource-attributes-1 // It originates from OpenMetrics: // https://github.com/OpenObservability/OpenMetrics/blob/1386544931307dff279688f332890c31b6c5de36/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems TargetInfoMetricName = "target_info" )
Variables ¶
This section is empty.
Functions ¶
func BuildCompliantName ¶ added in v0.82.0
BuildCompliantName builds a Prometheus-compliant metric name for the specified metric
Metric name is prefixed with specified namespace and underscore (if any). Namespace is not cleaned up. Make sure specified namespace follows Prometheus naming convention.
See rules at https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels and https://prometheus.io/docs/practices/naming/#metric-and-label-naming
func CleanUpString ¶
Clean up specified string so it's Prometheus compliant
func NormalizeLabel ¶
Normalizes the specified label to follow Prometheus label names standard
See rules at https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
Labels that start with non-letter rune will be prefixed with "key_"
Exception is made for double-underscores which are allowed
func RemovePromForbiddenRunes ¶ added in v0.59.0
func TrimPromSuffixes ¶ added in v0.82.0
func TrimPromSuffixes(promName string, metricType pmetric.MetricType, unit string) string
TrimPromSuffixes trims type and unit prometheus suffixes from a metric name. Following the OpenTelemetry specs for converting Prometheus Metric points to OTLP.
func UnitWordToUCUM ¶ added in v0.84.0
UnitWordToUCUM converts english unit words to UCUM units: https://ucum.org/ucum#section-Alphabetic-Index-By-Symbol It also handles rates, such as meters_per_second, by translating the first word to UCUM, and the "per" word to UCUM. It joins them with a "/" between.
Types ¶
This section is empty.