Support passing tracer provider in aiohttp server instrumentation lib#3819
Conversation
|
@bisgaard-itis You need to sign the CLA in order to contribute to OpenTelemetry, thanks. |
Perfect, thanks a lot for pointing this out @xrmx. I have signed it. |
|
@krnr this PR has been hanging for some time. Can I convince you to to review it? 🙏🏻 |
i see no issues, the code is pretty much straight-forward - the same middleware logic, but the middleware itself is created on-the-fly. i like it 👍 |
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Show resolved
Hide resolved
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
|
Also:
|
…lemetry#3875) * Only decode JSON input buffer in Anthropic Claude streaming _decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block. * Update test_botocore_bedrock.py Fix lint: `opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py:2990:4: C0415: Import outside toplevel (opentelemetry.instrumentation.botocore.extensions.bedrock_utils.InvokeModelWithResponseStreamWrapper) (import-outside-toplevel)` * Update test_botocore_bedrock.py Remove extra line * fix lint issue
* Stop using deprecated span.instrumentation_info * aiohttp-client: add support for OTEL_PYTHON_EXCLUDED_URLS / OTEL_PYTHON_HTTPX_EXCLUDED_URLS * Add docs * Add changelog * Please lint * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * Test for both env vars * Assert at each iteration --------- Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
Nothing needed since it's on the triage project board 👍 It just takes time since we're always in need of more contributors and approvers! If you do want to bring this PR up more synchronously, you can check out #otel-python on the CNCF Slack or attend the Thursday meetings (all linked here). |
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
…acerProvider-in-aiohttp-server-instrumentation-lib
a934b0c to
ca8ece2
Compare
…acerProvider-in-aiohttp-server-instrumentation-lib
…tp-server-instrumentation-lib
b438f24 to
dd31778
Compare
…tp-server-instrumentation-lib
83fe32f to
e39dd4d
Compare
…tp-server-instrumentation-lib
…tp-server-instrumentation-lib
…tp-server-instrumentation-lib
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
...-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py
Outdated
Show resolved
Hide resolved
…open-telemetry#3819) * allow to pass tracer_provider when instrumenting aiohttp server * minor fix * add note to indicate backwards compatibility * small fix * add test * update changelog * Only decode JSON input buffer in Anthropic Claude streaming (open-telemetry#3875) * Only decode JSON input buffer in Anthropic Claude streaming _decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block. * Update test_botocore_bedrock.py Fix lint: `opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py:2990:4: C0415: Import outside toplevel (opentelemetry.instrumentation.botocore.extensions.bedrock_utils.InvokeModelWithResponseStreamWrapper) (import-outside-toplevel)` * Update test_botocore_bedrock.py Remove extra line * fix lint issue * aiohttp-client: add support for url exclusions (open-telemetry#3850) * Stop using deprecated span.instrumentation_info * aiohttp-client: add support for OTEL_PYTHON_EXCLUDED_URLS / OTEL_PYTHON_HTTPX_EXCLUDED_URLS * Add docs * Add changelog * Please lint * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * Test for both env vars * Assert at each iteration --------- Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * update changelog * @tammy-baylis-swi add link to PR * create factory for instrumented application * run precommit hooks * update readthedocs * cleanup changelog after merge conflicts * make pre-commit happy * @tammy-baylis-swi add comment about optional inputs * fix issues caused by merge * precommit hooks * fix typehints * sort imports * @xrmx removed assert * Apply suggestions from code review --------- Co-authored-by: Thomas Pierce <thp@amazon.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
…open-telemetry#3819) * allow to pass tracer_provider when instrumenting aiohttp server * minor fix * add note to indicate backwards compatibility * small fix * add test * update changelog * Only decode JSON input buffer in Anthropic Claude streaming (open-telemetry#3875) * Only decode JSON input buffer in Anthropic Claude streaming _decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block. * Update test_botocore_bedrock.py Fix lint: `opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py:2990:4: C0415: Import outside toplevel (opentelemetry.instrumentation.botocore.extensions.bedrock_utils.InvokeModelWithResponseStreamWrapper) (import-outside-toplevel)` * Update test_botocore_bedrock.py Remove extra line * fix lint issue * aiohttp-client: add support for url exclusions (open-telemetry#3850) * Stop using deprecated span.instrumentation_info * aiohttp-client: add support for OTEL_PYTHON_EXCLUDED_URLS / OTEL_PYTHON_HTTPX_EXCLUDED_URLS * Add docs * Add changelog * Please lint * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * Test for both env vars * Assert at each iteration --------- Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * update changelog * @tammy-baylis-swi add link to PR * create factory for instrumented application * run precommit hooks * update readthedocs * cleanup changelog after merge conflicts * make pre-commit happy * @tammy-baylis-swi add comment about optional inputs * fix issues caused by merge * precommit hooks * fix typehints * sort imports * @xrmx removed assert * Apply suggestions from code review --------- Co-authored-by: Thomas Pierce <thp@amazon.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
…open-telemetry#3819) * allow to pass tracer_provider when instrumenting aiohttp server * minor fix * add note to indicate backwards compatibility * small fix * add test * update changelog * Only decode JSON input buffer in Anthropic Claude streaming (open-telemetry#3875) * Only decode JSON input buffer in Anthropic Claude streaming _decode_tool_use was only used when _tool_json_input_buf was found, but we were decoding the entire _content_block after adding _tool_json_input_buf to it. The _content_block overall which could contain non-JSON elements (e.g. {}), causing failures. To fix this, we have removed _decode_tool_use helper function and inlined JSON decoding logic directly into content_block_stop handler in _process_anthropic_claude_chunk, where we only use it to decode _tool_json_input_buf before appending to _content_block. * Update test_botocore_bedrock.py Fix lint: `opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py:2990:4: C0415: Import outside toplevel (opentelemetry.instrumentation.botocore.extensions.bedrock_utils.InvokeModelWithResponseStreamWrapper) (import-outside-toplevel)` * Update test_botocore_bedrock.py Remove extra line * fix lint issue * aiohttp-client: add support for url exclusions (open-telemetry#3850) * Stop using deprecated span.instrumentation_info * aiohttp-client: add support for OTEL_PYTHON_EXCLUDED_URLS / OTEL_PYTHON_HTTPX_EXCLUDED_URLS * Add docs * Add changelog * Please lint * Update CHANGELOG.md Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * Test for both env vars * Assert at each iteration --------- Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> * update changelog * @tammy-baylis-swi add link to PR * create factory for instrumented application * run precommit hooks * update readthedocs * cleanup changelog after merge conflicts * make pre-commit happy * @tammy-baylis-swi add comment about optional inputs * fix issues caused by merge * precommit hooks * fix typehints * sort imports * @xrmx removed assert * Apply suggestions from code review --------- Co-authored-by: Thomas Pierce <thp@amazon.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
Description
Support passing a
TracerProviderwhen using the aiohttp server instrumentation library. This gives users of the library the possibility to provide their own TracerProvider instead of relying on the global one. This is in particular useful for testing.Fixes # (issue)
TracerProviderwhen instrumenting an aiohttp server #3801Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
test_non_global_tracer_providerwhich checks that a non-globalTracerProvidercan be provided when instrumenting the aiohttp server. I check that the non-globalTracerProvideris used by the instrumentation library by setting a non-default sampling probability in that provider and checking that the corresponding number of traces are collected.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.