open-telemetry / open-telemetry/opentelemetry-cpp

[EXPORTER] OTLP HTTP exporter should not detach threads

Open
#3,295 1 comment 0 reactions 1 assignee View on GitHub

@marcalff is already working on this.

Since Mar 10, 2025.

bug triage/accepted
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

Context

In an instrumented application, the opentelemetry-cpp library static library is linked inside a bigger shared library, loaded and unloaded dynamically.

On cleanup, the code:

  • calls shutdown on every signal provider
  • releases the last references to every signal provider
  • unload the shared library

Problem

The OTLP HTTP exporter background threads are detached, and may still run by the time the shared library is unloaded.

This causes the code of the opentelemetry-cpp library itself to be un mapped from the process space, while a thread is still running, leading to a crash.

Expected behavior

Never detach a thread.

Instead, properly join background threads to make sure the cleanup is complete, before returning from Shutdown.

This affects the OTLP HTTP exporter, as well as the OTLP FILE exporter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.