Giter Club home page Giter Club logo

Comments (7)

arielvalentin avatar arielvalentin commented on June 29, 2024 1

I appreciate the warm welcome and the time you put into pointing me to the relevant part of the code.
Lot's of new info - I'll need to do some reading and digging to feel comfortable enough with this flow.
In the meantime, maybe someone has the knowledge and time to investigate this low priority issue and propose a fix.

We really could use the help so please take your time investigating.

from opentelemetry-ruby-contrib.

arielvalentin avatar arielvalentin commented on June 29, 2024

Thanks for opening this issue and providing us with details.

Do you have a hypothesis as to why this is happening?

from opentelemetry-ruby-contrib.

blumamir avatar blumamir commented on June 29, 2024

Thanks for opening this issue and providing us with details.

Do you have a hypothesis as to why this is happening?

I am new to ruby so not sure how to approach and debug this issue. I assume that the context should be set using some mechanism here so the sidekiq code executed after the TracerMiddleware will have context with current span set to the sidekiq span, but don't know how this can be achieved.

from opentelemetry-ruby-contrib.

arielvalentin avatar arielvalentin commented on June 29, 2024

@blumamir Welcome to the Ruby Community!

I am not familiar enough with Sidekiq (or Redis low level API) to know how it works but I can say with certainty that there is an implicit parent context that is shared as a Fiber local variable so as long as the code executes within the same fiber an new child spans will be attached to the "current" span:

Tracer.in_span -> Tracer.start_span -> Trace.current_span

https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/lib/opentelemetry/trace/tracer.rb#L28
https://github.com/open-telemetry/opentelemetry-ruby/blob/main/sdk/lib/opentelemetry/sdk/trace/tracer.rb#L33

The redis instrumentation does the same:

https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/redis/lib/opentelemetry/instrumentation/redis/patches/client.rb#L45

Looking at the test suite for the sidekiq instrumentation, it looks like it tests that the spans are generated sequentially but does not check their hierarchy:

https://github.com/open-telemetry/opentelemetry-ruby/blob/d11cbd1ed101280d0c64d38709c16eab0e92fc9d/instrumentation/sidekiq/test/opentelemetry/instrumentation/sidekiq/patches/launcher_test.rb#L48

It is difficult to tell without knowing more about how Sidekiq uses Redis under the hood, e.g. does it indeed execute a redis call as part of the client pipeline or is it batching them and sending all requests for enqueued jobs together? If it is the latter case then the span output you see is correct.

The only thing I can see for certain is that it is using Redis pipelining https://redis.io/topics/pipelining

from opentelemetry-ruby-contrib.

blumamir avatar blumamir commented on June 29, 2024

Thanks @arielvalentin :)
I appreciate the warm welcome and the time you put into pointing me to the relevant part of the code.
Lot's of new info - I'll need to do some reading and digging to feel comfortable enough with this flow.
In the meantime, maybe someone has the knowledge and time to investigate this low priority issue and propose a fix.

from opentelemetry-ruby-contrib.

indrekj avatar indrekj commented on June 29, 2024

We have the same problem.

I think I have an idea what is happening here. Basically in sidekiq there's:

    def push(item)
      normed = normalize_item(item)
      payload = process_single(item['class'], normed)

      if payload
        raw_push([payload])
        payload['jid']
      end
    end

process_single method handles the middleware which creates the "send" span. But the Redis call is happening in the raw_push method. That's why the Redis call is not the child of the send span.

I think one option to solve this would be to patch the push method instead of using the client middleware, but I'm open to suggestions.

from opentelemetry-ruby-contrib.

github-actions avatar github-actions commented on June 29, 2024

👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot.

from opentelemetry-ruby-contrib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.