|
42 | 42 | ec2 = session.create_client("ec2", region_name="us-west-2") |
43 | 43 | ec2.describe_instances() |
44 | 44 |
|
| 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 | +
|
45 | 63 | API |
46 | 64 | --- |
47 | 65 |
|
48 | 66 | The `instrument` method accepts the following keyword args: |
49 | 67 |
|
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 |
55 | 71 |
|
56 | 72 | for example: |
57 | 73 |
|
58 | | -.. code: python |
| 74 | +.. code:: python |
59 | 75 |
|
60 | 76 | from opentelemetry.instrumentation.botocore import BotocoreInstrumentor |
61 | 77 | import botocore.session |
|
0 commit comments