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

Otel threads spawn before "main" impact signal handling #2445

Closed
nleclercq opened this issue Dec 11, 2023 · 4 comments
Closed

Otel threads spawn before "main" impact signal handling #2445

nleclercq opened this issue Dec 11, 2023 · 4 comments

Comments

@nleclercq
Copy link

nleclercq commented Dec 11, 2023

Its seems that otel-ccp spawn some threads even before the main function is executed.
That's at least true when the instrumented application is linked against when the otlp_grpc_exporter.
Placing a breakpoint at the entry of main, we clearly see that 3 gRPC threads are already there. I guess they are spawn by hook executed when the shared library is loaded.

The problem is that this behavior as an impact on the signal handling mechanism implemented by our (shared) library. It, in fact, prevents our handler from behind called.

@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 11, 2023
@lalitb
Copy link
Member

lalitb commented Dec 11, 2023

@nleclercq - Can you share the stack trace, to understand the origin of threads. Also if you have the self-contained reproduction. otlp_grpc_exporter doesn't spawn any threads as of now (until #2407 is merged). Batch span processor creates a worked thread during initialization, but it won't be before main unless you are creating a static/global instance of the processor. But all theory for now, will wait for more details from your side :)

@nleclercq
Copy link
Author

nleclercq commented Dec 11, 2023

Damned! I actually have a singleton statically initialized as a global variable which makes a call to opentelemetry::exporter::otlp::OtlpGrpcExporterFactory::Create. I should have identified it as a potential source of the problem - sorry. Thanks for pointing this out. I'm going to switch to an explicit instantiation and see if it solves the problem. Stay tuned.

@nleclercq nleclercq changed the title Some threads are spawn before "main" is executed Otel threads spawn before "main" impact signal handling Dec 13, 2023
@nleclercq
Copy link
Author

Ok. Switching to an explicit instantiation solves the problem. Thanks. I think we can close this issue.

@marcalff marcalff removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 13, 2023
@owent
Copy link
Member

owent commented Dec 19, 2023

@nleclercq - Can you share the stack trace, to understand the origin of threads. Also if you have the self-contained reproduction. otlp_grpc_exporter doesn't spawn any threads as of now (until #2407 is merged). Batch span processor creates a worked thread during initialization, but it won't be before main unless you are creating a static/global instance of the processor. But all theory for now, will wait for more details from your side :)

#2407 do not spawn any thread, it will reuse the background threads of gRPC, and they are also created during or after initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants