Skip to content

[BUG] The thread context is not properly cleared and messes up the traces #10789

@reta

Description

@reta

Describe the bug
We have the issue with cleaning up the thread context upon certain transport action invocations, the thread context keeps holding the spans from previous invocations, messing up the traces.

To Reproduce
Consider this simple PUT request to create an index:

  curl -X PUT -H "Content-Type: application/json"     http://localhost:9200/test51     -d '{
          "mappings": {
              "properties": {
                  "field": { "type": "date", "format": "epoch_second" }
              }
          },
          "settings": {
              "number_of_shards": 2,
              "number_of_replicas": 2
          }
      }'

It generates the following trace:

Screenshot from 2023-10-20 11-09-24

Now wait just a bit and observe the same trace is growing:

Screenshot from 2023-10-20 11-09-50

And growing:

Screenshot from 2023-10-20 11-21-49

The reason for that is that thread context was not cleaned up and the background tasks still picking the last span as the parent, attaching more and more spans to it.

Expected behavior
The thread context must be properly cleaned up.

Plugins
OpenTelementry

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • Any

Additional context

opensearch.experimental.feature.telemetry.enabled: true
telemetry.tracer.sampler.probability: 1.0
telemetry.otel.tracer.span.exporter.class: io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter
telemetry.tracer.enabled: true 
telemetry.feature.tracer.enabled: true

CC @Gaganjuneja this is serious one

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingv2.12.0Issues and PRs related to version 2.12.0v3.0.0Issues and PRs related to version 3.0.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions