I would like an ability to pass trace parent from request to sidekiq job so trace id for the request and the sidekiq job is the same.
Something similar is currently possible with APM for node.js
I reported a Github issue but no one replied to me yet.
opened 06:17AM - 15 Mar 24 UTC
agent-ruby
## Is your feature request related to a problem? Please describe.
I would lik… e an ability to pass trace parent from request to sidekiq job so trace id for request and sidekiq is the same.
This is currently possible in APM for node.js
https://www.elastic.co/guide/en/apm/agent/nodejs/current/message-queues.html
I tried creating transaction in sidekiq middleware like this
```ruby
ElasticAPM.start_transaction('some-job', 'sidekiq', trace_context: ElasticAPM::TraceContext.new(
traceparent: ElasticAPM::TraceContext::Traceparent.new(trace_id: trace_parent[:trace_id])
))
```
But APM Sidekiq middleware always runs after and it fails with ExistingTransactionError. If it runs before, it still would have this issue.
https://github.com/elastic/apm-agent-ruby/blob/main/lib/elastic_apm/spies/sidekiq.rb#L32
https://github.com/elastic/apm-agent-ruby/blob/main/lib/elastic_apm/instrumenter.rb#L116
## Possible solution
May be you can look for certain parameter on `job` object and use it to set `trace_context` parameter.
https://github.com/elastic/apm-agent-ruby/blob/main/lib/elastic_apm/spies/sidekiq.rb#L32
Client middleware can pass it similar to the example here https://github.com/sidekiq/sidekiq/wiki/Middleware#client-middleware
Does anyone know how to do it in ruby? It seems like a very useful functionality that seems to be missing.
system
(system)
Closed
April 16, 2024, 4:48pm
2
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.