From 51bde6bc8ed2dd5dd76c2fee7e90bef0379d98da Mon Sep 17 00:00:00 2001 From: Stephan Salas Date: Tue, 29 Oct 2024 09:06:11 -0500 Subject: [PATCH 1/3] feat: Add topic to internal telemetry attributes (35336) --- receiver/kafkareceiver/kafka_receiver.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/receiver/kafkareceiver/kafka_receiver.go b/receiver/kafkareceiver/kafka_receiver.go index 48ea87559a56..881d5fef857a 100644 --- a/receiver/kafkareceiver/kafka_receiver.go +++ b/receiver/kafkareceiver/kafka_receiver.go @@ -29,6 +29,7 @@ const ( transport = "kafka" // TODO: update the following attributes to reflect semconv attrInstanceName = "name" + attrTopic = "topic" attrPartition = "partition" ) @@ -553,6 +554,7 @@ func (c *tracesConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSe ctx := c.obsrecv.StartTracesOp(session.Context()) attrs := attribute.NewSet( attribute.String(attrInstanceName, c.id.String()), + attribute.String(attrTopic, claim.Topic()), attribute.String(attrPartition, strconv.Itoa(int(claim.Partition()))), ) c.telemetryBuilder.KafkaReceiverMessages.Add(ctx, 1, metric.WithAttributeSet(attrs)) @@ -562,7 +564,7 @@ func (c *tracesConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSe traces, err := c.unmarshaler.Unmarshal(message.Value) if err != nil { c.logger.Error("failed to unmarshal message", zap.Error(err)) - c.telemetryBuilder.KafkaReceiverUnmarshalFailedSpans.Add(session.Context(), 1, metric.WithAttributes(attribute.String(attrInstanceName, c.id.String()))) + c.telemetryBuilder.KafkaReceiverUnmarshalFailedSpans.Add(session.Context(), 1, metric.WithAttributeSet(attrs)) if c.messageMarking.After && c.messageMarking.OnError { session.MarkMessage(message, "") } @@ -630,6 +632,7 @@ func (c *metricsConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupS ctx := c.obsrecv.StartMetricsOp(session.Context()) attrs := attribute.NewSet( attribute.String(attrInstanceName, c.id.String()), + attribute.String(attrTopic, claim.Topic()), attribute.String(attrPartition, strconv.Itoa(int(claim.Partition()))), ) c.telemetryBuilder.KafkaReceiverMessages.Add(ctx, 1, metric.WithAttributeSet(attrs)) @@ -639,7 +642,7 @@ func (c *metricsConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupS metrics, err := c.unmarshaler.Unmarshal(message.Value) if err != nil { c.logger.Error("failed to unmarshal message", zap.Error(err)) - c.telemetryBuilder.KafkaReceiverUnmarshalFailedMetricPoints.Add(session.Context(), 1, metric.WithAttributes(attribute.String(attrInstanceName, c.id.String()))) + c.telemetryBuilder.KafkaReceiverUnmarshalFailedMetricPoints.Add(session.Context(), 1, metric.WithAttributeSet(attrs)) if c.messageMarking.After && c.messageMarking.OnError { session.MarkMessage(message, "") } @@ -707,6 +710,7 @@ func (c *logsConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSess ctx := c.obsrecv.StartLogsOp(session.Context()) attrs := attribute.NewSet( attribute.String(attrInstanceName, c.id.String()), + attribute.String(attrTopic, claim.Topic()), attribute.String(attrPartition, strconv.Itoa(int(claim.Partition()))), ) c.telemetryBuilder.KafkaReceiverMessages.Add(ctx, 1, metric.WithAttributeSet(attrs)) @@ -716,7 +720,7 @@ func (c *logsConsumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSess logs, err := c.unmarshaler.Unmarshal(message.Value) if err != nil { c.logger.Error("failed to unmarshal message", zap.Error(err)) - c.telemetryBuilder.KafkaReceiverUnmarshalFailedLogRecords.Add(ctx, 1, metric.WithAttributes(attribute.String(attrInstanceName, c.id.String()))) + c.telemetryBuilder.KafkaReceiverUnmarshalFailedLogRecords.Add(ctx, 1, metric.WithAttributeSet(attrs)) if c.messageMarking.After && c.messageMarking.OnError { session.MarkMessage(message, "") } From 0899a079c4a671ce7abcf797c20300786fff833b Mon Sep 17 00:00:00 2001 From: Stephan Salas Date: Tue, 29 Oct 2024 09:32:58 -0500 Subject: [PATCH 2/3] feat: Add changelog (35336) --- .chloggen/fix-35336.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .chloggen/fix-35336.yaml diff --git a/.chloggen/fix-35336.yaml b/.chloggen/fix-35336.yaml new file mode 100644 index 000000000000..16db76134909 --- /dev/null +++ b/.chloggen/fix-35336.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: kafkareceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Added topic name as additional attribute to all existing internal consume-claim metrics. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [36068] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] From 013622284fef3f705240e9e20ec7b616fa5d8414 Mon Sep 17 00:00:00 2001 From: Stephan Salas Date: Sun, 10 Nov 2024 12:27:10 -0600 Subject: [PATCH 3/3] feat: Fix change_logs field (35336) --- .chloggen/fix-35336.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chloggen/fix-35336.yaml b/.chloggen/fix-35336.yaml index 16db76134909..f9be8887d3da 100644 --- a/.chloggen/fix-35336.yaml +++ b/.chloggen/fix-35336.yaml @@ -24,4 +24,4 @@ subtext: # Include 'user' if the change is relevant to end users. # Include 'api' if there is a change to a library API. # Default: '[user]' -change_logs: [] +change_logs: [user]