Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that guage metric miss labels #1618

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pkg/protocol/decoder/opentelemetry/otlp_metric_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strconv"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
v1Common "go.opentelemetry.io/proto/otlp/common/v1"
v1 "go.opentelemetry.io/proto/otlp/metrics/v1"

Expand Down Expand Up @@ -80,8 +79,8 @@ func exponentialHistogram2Logs(name string, histogram *v1.ExponentialHistogram,
for _, dataPoint := range histogram.GetDataPoints() {
labels := defaultLabels.Clone()
attrsToLabels(labels, dataPoint.GetAttributes())
labels.Append(otlp.TagKeyMetricAggregationTemporality, histogram.GetAggregationTemporality().String())
labels.Append(otlp.TagKeyMetricHistogramType, pmetric.MetricTypeExponentialHistogram.String())
// labels.Append(otlp.TagKeyMetricAggregationTemporality, histogram.GetAggregationTemporality().String())
// labels.Append(otlp.TagKeyMetricHistogramType, pmetric.MetricTypeExponentialHistogram.String())

if dataPoint.GetSum() != 0 {
logs = append(logs, newMetricLogFromRaw(name+metricNameSuffixSum, labels, int64(dataPoint.GetTimeUnixNano()), dataPoint.GetSum()))
Expand Down Expand Up @@ -166,7 +165,7 @@ func sum2Logs(name string, sum *v1.Sum, defaultLabels *helper.MetricLabels) (log
attrsToLabels(labels, dataPoint.GetAttributes())

labels.Append(otlp.TagKeyMetricIsMonotonic, strconv.FormatBool(sum.GetIsMonotonic()))
labels.Append(otlp.TagKeyMetricAggregationTemporality, sum.GetAggregationTemporality().String())
// labels.Append(otlp.TagKeyMetricAggregationTemporality, sum.GetAggregationTemporality().String())

for _, exemplar := range dataPoint.GetExemplars() {
logs = append(logs, exemplarMetricToLogs(name, exemplar, labels.Clone()))
Expand All @@ -184,8 +183,8 @@ func histogram2Logs(name string, histogram *v1.Histogram, defaultLabels *helper.
labels := defaultLabels.Clone()

attrsToLabels(labels, dataPoint.GetAttributes())
labels.Append(otlp.TagKeyMetricAggregationTemporality, histogram.GetAggregationTemporality().String())
labels.Append(otlp.TagKeyMetricHistogramType, pmetric.MetricTypeHistogram.String())
// labels.Append(otlp.TagKeyMetricAggregationTemporality, histogram.GetAggregationTemporality().String())
// labels.Append(otlp.TagKeyMetricHistogramType, pmetric.MetricTypeHistogram.String())

if dataPoint.GetSum() != 0 {
logs = append(logs, newMetricLogFromRaw(name+metricNameSuffixSum, labels, int64(dataPoint.GetTimeUnixNano()), dataPoint.GetSum()))
Expand Down Expand Up @@ -240,7 +239,7 @@ func gauge2Logs(name string, gauga *v1.Gauge, labels *helper.MetricLabels) (logs
logs = append(logs, exemplarMetricToLogs(name, exemplar, newLabels.Clone()))
}

logs = append(logs, newMetricLogFromRaw(name, labels, int64(toTimestamp(dataPoint.TimeUnixNano)), value2Float(dataPoint)))
logs = append(logs, newMetricLogFromRaw(name, newLabels.Clone(), int64(toTimestamp(dataPoint.TimeUnixNano)), value2Float(dataPoint)))
}
return logs
}
Expand Down
Loading