mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 14:17:12 +02:00
Set metadata type as gauge in otelMetricTypeToPromMetric
Signed-off-by: Carrie Edwards <edwrdscarrie@gmail.com>
This commit is contained in:
parent
9c32a69bf3
commit
ff693401eb
@ -212,19 +212,8 @@ func createAttributes(resource pcommon.Resource, attributes pcommon.Map, scope s
|
||||
|
||||
if metadata.Type != prompb.MetricMetadata_UNKNOWN {
|
||||
typeValue := strings.ToLower(metadata.Type.String())
|
||||
|
||||
if settings.AllowDeltaTemporality && hasTemporality && temporality == pmetric.AggregationTemporalityDelta {
|
||||
switch metadata.Type {
|
||||
case prompb.MetricMetadata_COUNTER:
|
||||
typeValue = "gauge"
|
||||
case prompb.MetricMetadata_HISTOGRAM:
|
||||
typeValue = "gaugehistogram"
|
||||
}
|
||||
}
|
||||
|
||||
l["__type__"] = typeValue
|
||||
}
|
||||
|
||||
if metadata.Unit != "" {
|
||||
l["__unit__"] = unitNamer.Build(metadata.Unit)
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
|
||||
continue
|
||||
}
|
||||
metadata := prompb.MetricMetadata{
|
||||
Type: otelMetricTypeToPromMetricType(metric),
|
||||
Type: otelMetricTypeToPromMetricType(metric, settings.AllowDeltaTemporality),
|
||||
MetricFamilyName: promName,
|
||||
Help: metric.Description(),
|
||||
Unit: metric.Unit(),
|
||||
|
@ -22,7 +22,10 @@ import (
|
||||
"github.com/prometheus/prometheus/prompb"
|
||||
)
|
||||
|
||||
func otelMetricTypeToPromMetricType(otelMetric pmetric.Metric) prompb.MetricMetadata_MetricType {
|
||||
// As part of implementing support for delta temporality, the metric type metadata for delta metrics
|
||||
// will be "gauge"/"gaugehistogram".
|
||||
// See proposal: https://github.com/prometheus/proposals/pull/48/
|
||||
func otelMetricTypeToPromMetricType(otelMetric pmetric.Metric, allowDeltaTemporality bool) prompb.MetricMetadata_MetricType {
|
||||
switch otelMetric.Type() {
|
||||
case pmetric.MetricTypeGauge:
|
||||
return prompb.MetricMetadata_GAUGE
|
||||
@ -31,26 +34,20 @@ func otelMetricTypeToPromMetricType(otelMetric pmetric.Metric) prompb.MetricMeta
|
||||
if otelMetric.Sum().IsMonotonic() {
|
||||
metricType = prompb.MetricMetadata_COUNTER
|
||||
}
|
||||
// We're in an early phase of implementing delta support (proposal: https://github.com/prometheus/proposals/pull/48/)
|
||||
// We don't have a proper way to flag delta metrics yet, therefore marking the metric type as unknown for now.
|
||||
if otelMetric.Sum().AggregationTemporality() == pmetric.AggregationTemporalityDelta {
|
||||
metricType = prompb.MetricMetadata_UNKNOWN
|
||||
if otelMetric.Sum().AggregationTemporality() == pmetric.AggregationTemporalityDelta && allowDeltaTemporality {
|
||||
metricType = prompb.MetricMetadata_GAUGE
|
||||
}
|
||||
return metricType
|
||||
case pmetric.MetricTypeHistogram:
|
||||
// We're in an early phase of implementing delta support (proposal: https://github.com/prometheus/proposals/pull/48/)
|
||||
// We don't have a proper way to flag delta metrics yet, therefore marking the metric type as unknown for now.
|
||||
if otelMetric.Histogram().AggregationTemporality() == pmetric.AggregationTemporalityDelta {
|
||||
return prompb.MetricMetadata_UNKNOWN
|
||||
if otelMetric.Histogram().AggregationTemporality() == pmetric.AggregationTemporalityDelta && allowDeltaTemporality {
|
||||
return prompb.MetricMetadata_GAUGEHISTOGRAM
|
||||
}
|
||||
return prompb.MetricMetadata_HISTOGRAM
|
||||
case pmetric.MetricTypeSummary:
|
||||
return prompb.MetricMetadata_SUMMARY
|
||||
case pmetric.MetricTypeExponentialHistogram:
|
||||
if otelMetric.ExponentialHistogram().AggregationTemporality() == pmetric.AggregationTemporalityDelta {
|
||||
// We're in an early phase of implementing delta support (proposal: https://github.com/prometheus/proposals/pull/48/)
|
||||
// We don't have a proper way to flag delta metrics yet, therefore marking the metric type as unknown for now.
|
||||
return prompb.MetricMetadata_UNKNOWN
|
||||
if otelMetric.ExponentialHistogram().AggregationTemporality() == pmetric.AggregationTemporalityDelta && allowDeltaTemporality {
|
||||
return prompb.MetricMetadata_GAUGEHISTOGRAM
|
||||
}
|
||||
return prompb.MetricMetadata_HISTOGRAM
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user