Skip to content

boto3 S3 upload_file method does not have the correct trace context #298

@wangzlei

Description

@wangzlei

opentelemetry-instrumentation-botocore bug:
X-Ray spans generated by AWS boto3 S3 upload_file method requests do not have the same trace id as their parent and sibling spans and the parent_id is set to null which causes broken traces.

Steps to reproduce

BotocoreInstrumentor().instrument(tracer_provider=trace.get_tracer_provider())

with tracer.start_as_current_span("foo"):
    s3 = boto3.resource('s3')
    s3.meta.client.upload_file('fromFile', 'myS3Bucket', 'toFile')    # upload a file to s3
    s3.bucket.all()    # list bucket

What is the expected behavior?
upload_file span should be the child of foo, get one trace: (foo -> (s3.upload_file, s3.list))

What is the actual behavior?
Get 2 traces, upload_file is not under foo:
trace1 (foo -> s3.list)
trace2 (s3.upload_file)

Additional context
boto3 s3 upload_file uses multi-part to increase throughput, botocore instrumentation does not cover this special case. Refer an analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededtriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions