Skip to content

Commit e107432

Browse files
bendruckerxrmx
andauthored
botocore: document threading instrumentation for S3 multipart operations (#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>
1 parent 61641aa commit e107432

File tree

1 file changed

+22
-6
lines changed
  • instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore

1 file changed

+22
-6
lines changed

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,36 @@
4242
ec2 = session.create_client("ec2", region_name="us-west-2")
4343
ec2.describe_instances()
4444
45+
Thread Context Propagation
46+
--------------------------
47+
48+
boto3's S3 ``upload_file`` and ``download_file`` methods use background threads
49+
for multipart transfers. To ensure trace context is propagated to these threads,
50+
also enable the threading instrumentation:
51+
52+
.. code:: python
53+
54+
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
55+
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
56+
57+
ThreadingInstrumentor().instrument()
58+
BotocoreInstrumentor().instrument()
59+
60+
When using auto-instrumentation (``opentelemetry-instrument``), both instrumentors
61+
are enabled automatically if their packages are installed.
62+
4563
API
4664
---
4765
4866
The `instrument` method accepts the following keyword args:
4967
50-
tracer_provider (TracerProvider) - an optional tracer provider
51-
request_hook (Callable) - a function with extra user-defined logic to be performed before performing the request
52-
this function signature is: def request_hook(span: Span, service_name: str, operation_name: str, api_params: dict) -> None
53-
response_hook (Callable) - a function with extra user-defined logic to be performed after performing the request
54-
this function signature is: def response_hook(span: Span, service_name: str, operation_name: str, result: dict) -> None
68+
* tracer_provider (``TracerProvider``) - an optional tracer provider
69+
* request_hook (``Callable[[Span, str, str, dict], None]``) - a function with extra user-defined logic to be performed before performing the request
70+
* response_hook (``Callable[[Span, str, str, dict], None]``) - a function with extra user-defined logic to be performed after performing the request
5571
5672
for example:
5773
58-
.. code: python
74+
.. code:: python
5975
6076
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
6177
import botocore.session

0 commit comments

Comments
 (0)