Skip to content

Commit

Permalink
Merge branch 'feat/DEX-2307/fix-trace-id' into 'master'
Browse files Browse the repository at this point in the history
[DEX-2307] fix: trace_id

Closes DEX-2307

See merge request nstmrt/rubygems/sbmt-kafka_consumer!59
  • Loading branch information
Arlantir committed Jul 8, 2024
2 parents 94fb4b6 + 587634b commit d8090b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [2.6.1] - 2024-07-05

### Fixed

- Use the current `trace_id` instead of creating a new one

## [2.6.0] - 2024-07-01

### Added
Expand Down
12 changes: 4 additions & 8 deletions lib/sbmt/kafka_consumer/base_consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
module Sbmt
module KafkaConsumer
class BaseConsumer < Karafka::BaseConsumer
attr_reader :trace_id

def self.consumer_klass(skip_on_error: false, middlewares: [])
Class.new(self) do
const_set(:SKIP_ON_ERROR, skip_on_error)
Expand Down Expand Up @@ -41,8 +39,6 @@ def process_batch?
private

def with_instrumentation(message)
@trace_id = SecureRandom.base58

logger.tagged(
trace_id: trace_id,
topic: message.metadata.topic, partition: message.metadata.partition,
Expand All @@ -69,8 +65,6 @@ def with_instrumentation(message)
end

def with_batch_instrumentation(messages)
@trace_id = SecureRandom.base58

logger.tagged(
trace_id: trace_id,
first_offset: messages.first.metadata.offset,
Expand All @@ -88,8 +82,6 @@ def with_batch_instrumentation(messages)
end

def with_common_instrumentation(name, message)
@trace_id = SecureRandom.base58

logger.tagged(
trace_id: trace_id
) do
Expand Down Expand Up @@ -173,6 +165,10 @@ def call_middlewares(message, middlewares)
end
traverse_chain.call
end

def trace_id
@trace_id ||= SecureRandom.base58
end
end
end
end
2 changes: 1 addition & 1 deletion lib/sbmt/kafka_consumer/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Sbmt
module KafkaConsumer
VERSION = "2.6.0"
VERSION = "2.6.1"
end
end

0 comments on commit d8090b4

Please sign in to comment.