Skip to content

Conversation

@bendrucker
Copy link
Contributor

@bendrucker bendrucker commented Dec 3, 2025

Documents that users need to enable ThreadingInstrumentor alongside BotocoreInstrumentor for proper trace context propagation with S3 upload_file and download_file methods.

Issue

boto3's S3 multipart operations (upload_file, download_file) spawn background threads via ThreadPoolExecutor. Without ThreadingInstrumentor, the OpenTelemetry context is not propagated to these threads, resulting in broken traces where child spans appear as separate traces instead of being linked to their parent.

The opentelemetry-instrumentation-threading module already wraps ThreadPoolExecutor.submit() to propagate context:

  1. Captures context with context.get_current() when submit() is called
  2. Attaches context in the worker thread before executing the task

Changes

  • Adds "Thread Context Propagation" section to botocore instrumentation module docstring
  • Adds "Thread Context Propagation" section to botocore README.rst

References

Closes #298

Document that users need to enable ThreadingInstrumentor alongside
BotocoreInstrumentor for proper trace context propagation with S3
upload_file and download_file methods.
README.rst is not built into the documentation, so keep the
threading context propagation docs only in __init__.py where
autodoc will pick them up.
@bendrucker bendrucker requested a review from xrmx December 4, 2025 17:06
@xrmx xrmx moved this to Easy to review / merge / close in @xrmx's Python PR digest Dec 5, 2025
@xrmx xrmx added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Dec 5, 2025
@xrmx xrmx merged commit e107432 into open-telemetry:main Dec 5, 2025
647 checks passed
@github-project-automation github-project-automation bot moved this from Easy to review / merge / close to Done in @xrmx's Python PR digest Dec 5, 2025
RKest pushed a commit to RKest/opentelemetry-python-contrib that referenced this pull request Dec 5, 2025
…ons (open-telemetry#3999)

* botocore: document threading instrumentation for S3 multipart operations

Document that users need to enable ThreadingInstrumentor alongside
BotocoreInstrumentor for proper trace context propagation with S3
upload_file and download_file methods.

* botocore: move thread context docs to module docstring only

README.rst is not built into the documentation, so keep the
threading context propagation docs only in __init__.py where
autodoc will pick them up.

* Update __init__.py

* Update __init__.py

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
RKest pushed a commit to RKest/opentelemetry-python-contrib that referenced this pull request Dec 5, 2025
…ons (open-telemetry#3999)

* botocore: document threading instrumentation for S3 multipart operations

Document that users need to enable ThreadingInstrumentor alongside
BotocoreInstrumentor for proper trace context propagation with S3
upload_file and download_file methods.

* botocore: move thread context docs to module docstring only

README.rst is not built into the documentation, so keep the
threading context propagation docs only in __init__.py where
autodoc will pick them up.

* Update __init__.py

* Update __init__.py

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
@bendrucker bendrucker deleted the docs/botocore-threading-context-propagation branch December 5, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

boto3 S3 upload_file method does not have the correct trace context

2 participants