Skip to content
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

Add native support for threading (new instrumentation package) #737

Closed
owais opened this issue Oct 13, 2021 · 9 comments · Fixed by #2253
Closed

Add native support for threading (new instrumentation package) #737

owais opened this issue Oct 13, 2021 · 9 comments · Fixed by #2253

Comments

@owais
Copy link
Contributor

owais commented Oct 13, 2021

OpenCensus has native integration for the threading module that automatically propagates tracing context across threads. It would be nice to port it over to OpenTelemetry.

OpenCensus Threading integration: https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-threading

@rdpravin1895
Copy link

Currently, whats the best way to propagate tracing context across threads? I have been looking for it, but cannot find any reference snippet

@owais
Copy link
Contributor Author

owais commented Mar 18, 2022

Passing context as an function argument to the thread and then setting the received context on the other side. There is no automated solution.

@jsmolina
Copy link

I did it by passing context and then re-attaching it:

from opentelemetry import context

def execute_ec2_func(method, data, ctx):
    context.attach(ctx)
    return method(**data)

Then the boto3 methods are called passing current context:

loop.run_in_executor(
 self.executor,
 execute_ec2_func,
 self.ec2.start_instances,
 {"InstanceIds": instance_ids},
 context.get_current(),
)

@srikanthccv
Copy link
Member

@pridhi-arora, you will be working on this as part of the outreachy program. Please leave a comment here so that I can assign this to you.

@pridhi-arora
Copy link
Contributor

Thanks, @srikanthccv. Looking forward to work on this.

@pridhi-arora
Copy link
Contributor

What do we mean by propagate tracing context across threads? @srikanthccv Can you shed some light on this? Thanks in advance.

@ocelotl
Copy link
Contributor

ocelotl commented Dec 22, 2023

@bobthemighty for some reason I can't assign you to this issue 🤔 apparently you need to leave a comment here first.

@bobthemighty
Copy link

@ocelotl like this?

@changemyminds
Copy link
Contributor

changemyminds commented Feb 18, 2024

@srikanthccv and @ocelotl, any update news for this PR? or could I provide the PR about this threading feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment