Skip to content

Collecting events from more threads does not work #94

@mladedav

Description

@mladedav

Bug Report

Version

Current HEAD in git: 101dc89 (origin/v0.1.x, origin/HEAD) Honor explicit parent spans for events (#92)

For completeness sake:

tracing-opentelemetry v0.22.0 (/...)
├── tracing v0.1.40
│   ├── tracing-attributes v0.1.27 (proc-macro)
│   └── tracing-core v0.1.32
├── tracing-core v0.1.32 (*)
├── tracing-log v0.2.0
│   └── tracing-core v0.1.32 (*)
└── tracing-subscriber v0.3.18
    └── tracing-core v0.1.32 (*)
│   │       │   │   │   │   └── tracing v0.1.40 (*)
│   │       │   │   │   └── tracing v0.1.40 (*)
│   │       │   │   ├── tracing v0.1.40 (*)
│   │       │   │   └── tracing v0.1.40 (*)
│   │       └── tracing v0.1.40 (*)
├── tracing v0.1.40 (*)
└── tracing-subscriber v0.3.18 (*)

Platform

Linux silver 6.1.71-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Jan 5 17:36:36 UTC 2024 x86_64 GNU/Linux

Description

When events are emitted for the same span from multiple threads, some of them may be lost due to race conditions.

Repro is here

This is caused by the OpenTelemetryLayer taking the OtelData from extensions, mutating the events and then replacing it back. If some other thread tries to log an event in the meantime and doesn't find OtelData in the extensions, that event will be lost.

Important context is #59 which is also the reason we cannot simply take a unique reference to the metadata because it might cause a deadlock. More context concerning that:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions