Skip to content

Parallel SDK requests share the same OpenTelemetry span #1211

@samkolton

Description

@samkolton

Describe the bug

I'm using SDK in Ktor server to access Bedrock. Each user request to the server creates a new span (with a new traceId) and corresponds to 1 call to Bedrock.
I was trying to use OpenTelemetryProvider to add tracing for SDK. However, enabling telemetryProvider causes multiple independent user requests to share the same traceId (essentially breaking traces).

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected behavior

Each user request should use a different traceId

Current behavior

Multiple user requests share the same traceId

Steps to Reproduce

Perform 2 consecutive calls to Bedrock through SDK under independent OpenTelemetry spans

Possible Solution

From the first look, it seems like the line private val spanScope = otelSpan.makeCurrent() (here) might be the issue.

Context

No response

Smithy-Kotlin version

1.3.31

Platform (JVM/JS/Native)

JVM

Operating system and version

MacOS 15.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions