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

Upgrade kafa semconv to 1.26.0 #909

Merged
merged 11 commits into from
Jul 9, 2024
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http
- Support `google.golang.org/grpc` `1.64.1`. ([#916](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/916))
- Support `golang.org/x/net` `v0.27.0`. ([#917](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/917))

### Changed

- Upgrade semconv from `v1.24.0` to `v1.26.0` in `github.com/segmentio/kafka-go` instrumentation. ([#909](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/909))
- The `messaging.operation` attribute key is renamed to `messaging.operation.type`.
- The `messaging.kafka.destination.partition` key is renamed to `messaging.destination.partition.id`

### Fixed

- HTTP client: Use Host field in URL if the Request Host is not present. ([#888](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/888))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ package consumer

import (
"fmt"
"strconv"

"github.com/go-logr/logr"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sys/unix"

Expand Down Expand Up @@ -122,8 +123,8 @@ func convertEvent(e *event) []*probe.SpanEvent {

attributes := []attribute.KeyValue{
semconv.MessagingSystemKafka,
semconv.MessagingOperationReceive,
semconv.MessagingKafkaDestinationPartition(int(e.Partition)),
semconv.MessagingOperationTypeReceive,
semconv.MessagingDestinationPartitionID(strconv.Itoa(int(e.Partition))),
semconv.MessagingDestinationName(topic),
semconv.MessagingKafkaMessageOffset(int(e.Offset)),
semconv.MessagingKafkaMessageKey(unix.ByteSliceToString(e.Key[:])),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/assert"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/auto/internal/pkg/instrumentation/context"
Expand Down Expand Up @@ -63,8 +63,8 @@ func TestProbeConvertEvent(t *testing.T) {
SpanContext: &sc,
Attributes: []attribute.KeyValue{
semconv.MessagingSystemKafka,
semconv.MessagingOperationReceive,
semconv.MessagingKafkaDestinationPartition(12),
semconv.MessagingOperationTypeReceive,
semconv.MessagingDestinationPartitionID("12"),
semconv.MessagingDestinationName("topic1"),
semconv.MessagingKafkaMessageOffset(42),
semconv.MessagingKafkaMessageKey("key1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/go-logr/logr"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sys/unix"

Expand Down Expand Up @@ -118,7 +118,7 @@ func convertEvent(e *event) []*probe.SpanEvent {

globalTopic := unix.ByteSliceToString(e.GlobalTopic[:])

var commonAttrs []attribute.KeyValue = []attribute.KeyValue{semconv.MessagingSystemKafka, semconv.MessagingOperationPublish}
commonAttrs := []attribute.KeyValue{semconv.MessagingSystemKafka, semconv.MessagingOperationTypePublish}
if len(globalTopic) > 0 {
commonAttrs = append(commonAttrs, semconv.MessagingDestinationName(globalTopic))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/assert"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/auto/internal/pkg/instrumentation/probe"
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestProbeConvertEvent(t *testing.T) {
semconv.MessagingKafkaMessageKey("key1"),
semconv.MessagingDestinationName("topic1"),
semconv.MessagingSystemKafka,
semconv.MessagingOperationPublish,
semconv.MessagingOperationTypePublish,
semconv.MessagingBatchMessageCount(2),
},
}
Expand All @@ -89,7 +89,7 @@ func TestProbeConvertEvent(t *testing.T) {
semconv.MessagingKafkaMessageKey("key2"),
semconv.MessagingDestinationName("topic2"),
semconv.MessagingSystemKafka,
semconv.MessagingOperationPublish,
semconv.MessagingOperationTypePublish,
semconv.MessagingBatchMessageCount(2),
},
}
Expand Down
10 changes: 5 additions & 5 deletions internal/test/e2e/kafka-go/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
},
{
"key": "messaging.operation",
"key": "messaging.operation.type",
"value": {
"stringValue": "publish"
}
Expand Down Expand Up @@ -117,7 +117,7 @@
}
},
{
"key": "messaging.operation",
"key": "messaging.operation.type",
"value": {
"stringValue": "publish"
}
Expand Down Expand Up @@ -205,15 +205,15 @@
}
},
{
"key": "messaging.operation",
"key": "messaging.operation.type",
"value": {
"stringValue": "receive"
}
},
{
"key": "messaging.kafka.destination.partition",
"key": "messaging.destination.partition.id",
"value": {
"intValue": "0"
"stringValue": "0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions internal/test/e2e/kafka-go/verify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ SCOPE="go.opentelemetry.io/auto/github.com/segmentio/kafka-go"
assert_equal "$topics" '"key1"'
}

@test "consumer :: valid {messaging.kafka.destination.partition}" {
partition=$(consumer_span_attributes_for ${SCOPE} | jq "select(.key == \"messaging.kafka.destination.partition\").value.intValue" | sort )
@test "consumer :: valid {messaging.destination.partition.id}" {
partition=$(consumer_span_attributes_for ${SCOPE} | jq "select(.key == \"messaging.destination.partition.id\").value.stringValue" | sort )
assert_equal "$partition" '"0"'
}

Expand Down
Loading