diff --git a/.chloggen/fix-35336.yaml b/.chloggen/fix-35336.yaml new file mode 100644 index 000000000000..f9be8887d3da --- /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: [user] diff --git a/receiver/kafkareceiver/kafka_receiver.go b/receiver/kafkareceiver/kafka_receiver.go index 1ec2d5aca6e9..eb6bc4e2a2b7 100644 --- a/receiver/kafkareceiver/kafka_receiver.go +++ b/receiver/kafkareceiver/kafka_receiver.go @@ -30,6 +30,7 @@ const ( transport = "kafka" // TODO: update the following attributes to reflect semconv attrInstanceName = "name" + attrTopic = "topic" attrPartition = "partition" ) @@ -558,6 +559,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)) @@ -567,7 +569,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, "") } @@ -635,6 +637,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)) @@ -644,7 +647,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, "") } @@ -712,6 +715,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)) @@ -721,7 +725,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, "") }