diff --git a/CHANGELOG.md b/CHANGELOG.md index c572c7a..9c6a52d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +## [3.2.2] - 2024-09-23 + +### Fixed + +- log OTEL `trace_id` + ## [3.2.1] - 2024-09-20 ### Fixed diff --git a/lib/sbmt/kafka_consumer/base_consumer.rb b/lib/sbmt/kafka_consumer/base_consumer.rb index 5f7b93c..7cebc62 100644 --- a/lib/sbmt/kafka_consumer/base_consumer.rb +++ b/lib/sbmt/kafka_consumer/base_consumer.rb @@ -162,7 +162,11 @@ def call_middlewares(message, middlewares) end def trace_id - @trace_id ||= SecureRandom.base58 + return nil unless defined?(::OpenTelemetry) + + context = ::OpenTelemetry::Trace.current_span.context + + context.valid? ? context.hex_trace_id : nil end def config diff --git a/lib/sbmt/kafka_consumer/version.rb b/lib/sbmt/kafka_consumer/version.rb index f1677c4..0b2893d 100644 --- a/lib/sbmt/kafka_consumer/version.rb +++ b/lib/sbmt/kafka_consumer/version.rb @@ -2,6 +2,6 @@ module Sbmt module KafkaConsumer - VERSION = "3.2.1" + VERSION = "3.2.2" end end