-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boto3 S3 upload_file method does not have the correct trace context #298
Comments
This issue was marked stale due to lack of activity. It will be closed in 30 days. |
Is there any information why this happens? We are currently facing this issue. |
Had to debug a similar issue today with the In that scenario, the auto-instrumentation libraries correctly instrument outgoing requests but can't correctly associate the trace context to the main thread. We were able to solve those issues using code similar to the following: import time
import threading
from opentelemetry import context
def thread_worker(thread_id, context):
with tracer.start_as_current_span('thread-worker', context) as span:
span.set_attribute('thread_id', thread_id)
time.sleep(0.5)
threads = list()
trace_context = context.get_context()
for i in range(4):
thread = threading.Thread(target=thread_worker, args = (i, trace_context))
threads.append(thread)
thread.start()
for t in threads:
t.join() Based on the similar broken trace behavior and the observation that the status code for Since the spans in question are from auto-instrumented method, there's no way to explicitly pass the trace context the way I did in my sample code. What we did to try to work around this issue:
What we did that actually worked:
with tracer.start_as_current_span('download-file-from-s3') as download_span:
# Note: see GitHub issue https://github.com/open-telemetry/opentelemetry-python-contrib/issues/298
BotocoreInstrumentor().uninstrument()
s3.download_file(bucket_name, key_name, output_file_name)
BotocoreInstrumentor().instrument()
download_span.set_attributes({
"s3.bucket_name": bucket_name,
"s3.key_name": key_name,
}) |
Thanks @ericksoen this looks like a practicable work around to put into a library function. Tyvm for this investigation! |
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
What is the expected behavior?
upload_file
span should be the child offoo
, get one trace: (foo -> (s3.upload_file, s3.list))What is the actual behavior?
Get 2 traces,
upload_file
is not underfoo
: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.The text was updated successfully, but these errors were encountered: