Skip to content

feat: Update attributes to match semconv in racecar #1613

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions instrumentation/racecar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History: opentelemetry-instrumentation-racecar

* Renamed messaging.kafka.message_key to messaging.kafka.message.key to match semantic conventions.

* Renamed messaging.destination to messaging.destination.name to match semantic conventions.

* Renamed messaging.kafka.partition to messaging.destination.partition.id to match semantic conventions.

* Removed messaging.destination_kind to match semantic conventions.

* Add messaging.operation.type attribute as per semantic conventions.

### v0.4.0 / 2025-01-16

* BREAKING CHANGE: Set minimum supported version to Ruby 3.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module Consumer
def produce(payload, topic:, key: nil, partition: nil, partition_key: nil, headers: nil, create_time: nil)
attributes = {
'messaging.system' => 'kafka',
'messaging.destination' => topic,
'messaging.destination_kind' => 'topic'
'messaging.destination.name' => topic,
'messaging.operation.type' => 'send'
}

headers ||= {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def start(_name, _id, payload)
def attributes(payload)
attributes = {
'messaging.system' => 'kafka',
'messaging.destination' => payload[:topic],
'messaging.destination_kind' => 'topic',
'messaging.kafka.partition' => payload[:partition],
'messaging.kafka.offset' => payload[:offset]
'messaging.destination.name' => payload[:topic],
'messaging.destination.partition.id' => payload[:partition],
'messaging.kafka.offset' => payload[:offset],
'messaging.operation.type' => 'receive'
}

message_key = extract_message_key(payload[:key])
attributes['messaging.kafka.message_key'] = message_key if message_key
attributes['messaging.kafka.message.key'] = message_key if message_key

attributes
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def stop_racecar(thread)
first_process_span = process_spans[0]
_(first_process_span.name).must_equal("#{topic_name} process")
_(first_process_span.kind).must_equal(:consumer)
_(first_process_span.attributes['messaging.destination']).must_equal(topic_name)
_(first_process_span.attributes['messaging.kafka.partition']).wont_be_nil
_(first_process_span.attributes['messaging.destination.name']).must_equal(topic_name)
_(first_process_span.attributes['messaging.destination.partition.id']).wont_be_nil

first_process_span_link = first_process_span.links[0]
linked_span_context = first_process_span_link.span_context
Expand Down Expand Up @@ -184,10 +184,10 @@ def stop_racecar(thread)
process_spans = spans.select { |s| s.name == "#{topic_name} process" }

first_process_span = process_spans[0]
_(first_process_span.attributes['messaging.kafka.message_key']).must_equal('Key 1')
_(first_process_span.attributes['messaging.kafka.message.key']).must_equal('Key 1')

second_process_span = process_spans[1]
_(second_process_span.attributes).wont_include('messaging.kafka.message_key')
_(second_process_span.attributes).wont_include('messaging.kafka.message.key')
end
end
end
Expand Down Expand Up @@ -216,8 +216,8 @@ def stop_racecar(thread)
first_process_span = process_spans[0]
_(first_process_span.name).must_equal("#{topic_name} process")
_(first_process_span.kind).must_equal(:consumer)
_(first_process_span.attributes['messaging.destination']).must_equal(topic_name)
_(first_process_span.attributes['messaging.kafka.partition']).wont_be_nil
_(first_process_span.attributes['messaging.destination.name']).must_equal(topic_name)
_(first_process_span.attributes['messaging.destination.partition.id']).wont_be_nil

first_process_span_link = first_process_span.links[0]
linked_span_context = first_process_span_link.span_context
Expand Down