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

[Feat] Better control of threads executed by opentelemetry-cpp #3174

Open
marcalff opened this issue Nov 26, 2024 · 3 comments · May be fixed by #3175
Open

[Feat] Better control of threads executed by opentelemetry-cpp #3174

marcalff opened this issue Nov 26, 2024 · 3 comments · May be fixed by #3175
Assignees
Labels
enhancement New feature or request

Comments

@marcalff
Copy link
Member

Context

The opentelemetry-cpp uses threads internally, for various components.

For example:

  • the batch processor uses a thread to process records from the span buffer.
  • the periodic metric reader uses a thread to trigger periodic collection, and a child thread to collect observable metrics.
  • the log processor uses a thread to process records from a log buffer.
  • every exporter based on CURL uses a thread internally, to process HTTP requests and responses.

Problem

An application that links with the opentelemetry-cpp library may have additional constraints, and may want to control at a very low level how the code executes within a thread.

For example:

  • the application may want to name threads, to be visible in the operating system under an application controlled name.
  • the application may need to initialize thread local storage, in particular when custom code is executed within a thread spawned by opentelemetry. Typically, callbacks for observable metrics may need TLS keys in place to execute properly.
  • the application may need to control thread priorities, or bind internal opentelemetry threads to some CPUs.
  • the application may need to control the current network namespace, when a thread opens a network connection.

Currently, there is no way to implement any of this from an application that uses opentelemetry-cpp.

@marcalff marcalff added the bug Something isn't working label Nov 26, 2024
@marcalff marcalff self-assigned this Nov 26, 2024
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 26, 2024
@marcalff marcalff added enhancement New feature or request and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. bug Something isn't working labels Nov 26, 2024
marcalff added a commit to marcalff/opentelemetry-cpp that referenced this issue Nov 26, 2024
@marcalff marcalff linked a pull request Nov 26, 2024 that will close this issue
3 tasks
@lalitb
Copy link
Member

lalitb commented Nov 27, 2024

This was discussed earlier, with some proposal here - #1822 (comment)

@owent
Copy link
Member

owent commented Dec 5, 2024

There is another discussion in #1250 , I think the best solution is implementing a event driven module, which just like libuv, libevent, boost.asio or other simular solution. We can handle timer callback and IO event in a shared thread pool.
Or can we just import libuv or libevent?

@marcalff
Copy link
Member Author

marcalff commented Dec 5, 2024

This is not about thread scheduling.

The need here is to add hooks to an opentelemetry-cpp thread, to get a chance to execute at strategic locations:

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

Successfully merging a pull request may close this issue.

3 participants