open-telemetry / open-telemetry/opentelemetry-cpp

ETW Exporter: Crash When Ending ETW Exporter Span

Open
#3,849 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The same code works correctly when using the OpenTelemetry Tracer, Span, and OTLP Exporter. However, the application crashes when switching to the ETW Exporter.

Code to Reproduce (ETW Exporter)
  void TestEtwTracer()
  {
    auto traceProvider = std::make_unique<opentelemetry::exporter::etw::TracerProvider>();
    auto tracer = traceProvider->GetTracer("Geneva-Tracer-Foo");
    auto spanFoo = tracer->StartSpan("Span-Foo");
    tracer = traceProvider->GetTracer("Geneva-Tracer-Bar");
    auto spanBar = tracer->StartSpan("Span-Bar");
    spanFoo->End();
    spanBar->End();
  }
Crash Screenshot
Image
Code to Reproduce (OTLP Exporter – Works as Expected)
  void TestOTelTracer()
  {
    auto ostream_exporter = opentelemetry::exporter::trace::OStreamSpanExporterFactory::Create();
    auto ostream_processor = opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(ostream_exporter));

    std::vector<std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor>> processors;
    processors.push_back(std::move(ostream_processor));

    auto resource_attributes = opentelemetry::sdk::resource::ResourceAttributes{ {"service.name", "Test OTel"} };
    auto resource_ptr = opentelemetry::sdk::resource::Resource::Create(resource_attributes);

    std::unique_ptr<opentelemetry::sdk::trace::TracerContext> context =
      opentelemetry::sdk::trace::TracerContextFactory::Create(std::move(processors), resource_ptr);

    auto traceProvider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(context));
    auto tracer = traceProvider->GetTracer("OTel-Tracer-Foo");
    auto spanFoo = tracer->StartSpan("Span-Foo");

    tracer = traceProvider->GetTracer("OTel-Tracer-Bar");
    auto spanBar = tracer->StartSpan("Span-Bar");
    spanFoo->End();
    spanBar->End();
  }
Screenshot (No Crash)
Image

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.

Research direction

The issue names no files or tests. Start by running the ETW exporter reproducer and tracing the span-end path, then compare it with the working OTLP setup to locate the crash. Done means both ETW spans can end without crashing, ideally covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.