From 61f400eccb0ee498e5bebd360ea7f3d0ea91046f Mon Sep 17 00:00:00 2001 From: Zakhar Bessarab Date: Fri, 15 Dec 2023 14:16:25 +0400 Subject: [PATCH] lib/protoparser/opentelemetry: add metric to track skipped rows without resource (#5459) Currently, it is impossible to understand why metrics are not ingested when resource is not set by OTEL exporter. Adding metric should simplify debugging and make it improve debuggability. Signed-off-by: Zakhar Bessarab Co-authored-by: Roman Khavronenko (cherry picked from commit 317834f876747843f38ee770af352cd83e67e047) --- lib/protoparser/opentelemetry/stream/streamparser.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/protoparser/opentelemetry/stream/streamparser.go b/lib/protoparser/opentelemetry/stream/streamparser.go index 882451fdc..a21777ff6 100644 --- a/lib/protoparser/opentelemetry/stream/streamparser.go +++ b/lib/protoparser/opentelemetry/stream/streamparser.go @@ -6,6 +6,8 @@ import ( "strconv" "sync" + "github.com/VictoriaMetrics/metrics" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal" "github.com/VictoriaMetrics/VictoriaMetrics/lib/fasttime" @@ -14,7 +16,6 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/common" "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/pb" "github.com/VictoriaMetrics/VictoriaMetrics/lib/writeconcurrencylimiter" - "github.com/VictoriaMetrics/metrics" ) // ParseStream parses OpenTelemetry protobuf or json data from r and calls callback for the parsed rows. @@ -273,6 +274,7 @@ func (wr *writeContext) parseRequestToTss(req *pb.ExportMetricsServiceRequest) { for _, rm := range req.ResourceMetrics { if rm.Resource == nil { // skip metrics without resource part. + rowsDroppedResourceNotSet.Inc() continue } wr.baseLabels = appendAttributesToPromLabels(wr.baseLabels[:0], rm.Resource.Attributes) @@ -302,4 +304,5 @@ var ( rowsDroppedUnsupportedHistogram = metrics.NewCounter(`vm_protoparser_rows_dropped_total{type="opentelemetry",reason="unsupported_histogram_aggregation"}`) rowsDroppedUnsupportedSum = metrics.NewCounter(`vm_protoparser_rows_dropped_total{type="opentelemetry",reason="unsupported_sum_aggregation"}`) rowsDroppedUnsupportedMetricType = metrics.NewCounter(`vm_protoparser_rows_dropped_total{type="opentelemetry",reason="unsupported_metric_type"}`) + rowsDroppedResourceNotSet = metrics.NewCounter(`vm_protoparser_rows_dropped_total{type="opentelemetry",reason="resource_not_set"}`) )