Enable passing explicit urls to exclude in instrumentation in FastAPI (#486)

This commit is contained in:
Cristian Vargas
2021-06-14 19:17:39 -05:00
committed by GitHub
parent c1fbe0e281
commit 7cae4d3001
5 changed files with 104 additions and 9 deletions

View File

@ -1,4 +1,5 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@ -56,6 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#472](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/472)) ([#472](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/472))
- Set the `traced_request_attrs` of FalconInstrumentor by an argument correctly. - Set the `traced_request_attrs` of FalconInstrumentor by an argument correctly.
([#473](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/473)) ([#473](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/473))
- Enable passing explicit urls to exclude in instrumentation in FastAPI
([#486](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/486))
- Distros can now implement `load_instrumentor(EntryPoint)` method to customize instrumentor - Distros can now implement `load_instrumentor(EntryPoint)` method to customize instrumentor
loading behaviour. loading behaviour.
([#480](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/480)) ([#480](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/480))
@ -63,12 +66,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#492](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/492)) ([#492](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/492))
### Added ### Added
- Move `opentelemetry-instrumentation` from core repository - Move `opentelemetry-instrumentation` from core repository
([#465](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/465)) ([#465](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/465))
## [0.20b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.20b0) - 2021-04-20 ## [0.20b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.20b0) - 2021-04-20
### Changed ### Changed
- Restrict DataDog exporter's `ddtrace` dependency to known working versions. - Restrict DataDog exporter's `ddtrace` dependency to known working versions.
([#400](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/400)) ([#400](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/400))
- GRPC instrumentation now correctly injects trace context into outgoing requests. - GRPC instrumentation now correctly injects trace context into outgoing requests.
@ -80,7 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update instrumentations to use tracer_provider for creating tracer if given, otherwise use global tracer provider - Update instrumentations to use tracer_provider for creating tracer if given, otherwise use global tracer provider
([#402](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/402)) ([#402](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/402))
- `opentelemetry-instrumentation-wsgi` Replaced `name_callback` with `request_hook` - `opentelemetry-instrumentation-wsgi` Replaced `name_callback` with `request_hook`
and `response_hook` callbacks. and `response_hook` callbacks.
([#424](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/424)) ([#424](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/424))
- Update gRPC instrumentation to better wrap server context - Update gRPC instrumentation to better wrap server context
([#420](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/420)) ([#420](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/420))
@ -90,6 +95,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#265](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/265)) ([#265](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/265))
### Added ### Added
- `opentelemetry-instrumentation-urllib3` Add urllib3 instrumentation - `opentelemetry-instrumentation-urllib3` Add urllib3 instrumentation
([#299](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/299)) ([#299](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/299))
@ -118,16 +124,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#442](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/442)) ([#442](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/442))
### Removed ### Removed
- Remove `http.status_text` from span attributes - Remove `http.status_text` from span attributes
([#406](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/406)) ([#406](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/406))
## [0.19b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.19b0) - 2021-03-26 ## [0.19b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.19b0) - 2021-03-26
- Implement context methods for `_InterceptorChannel` - Implement context methods for `_InterceptorChannel`
([#363](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/363)) ([#363](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/363))
### Changed ### Changed
- Rename `IdsGenerator` to `IdGenerator` - Rename `IdsGenerator` to `IdGenerator`
([#350](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/350)) ([#350](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/350))
- `opentelemetry-exporter-datadog` Fix warning when DatadogFormat encounters a request with - `opentelemetry-exporter-datadog` Fix warning when DatadogFormat encounters a request with
@ -147,18 +154,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#372](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/372)) ([#372](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/372))
### Removed ### Removed
- Removing support for Python 3.5 - Removing support for Python 3.5
([#374](https://github.com/open-telemetry/opentelemetry-python/pull/374)) ([#374](https://github.com/open-telemetry/opentelemetry-python/pull/374))
## [0.18b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.18b0) - 2021-02-16 ## [0.18b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.18b0) - 2021-02-16
### Added ### Added
- `opentelemetry-propagator-ot-trace` Add OT Trace Propagator - `opentelemetry-propagator-ot-trace` Add OT Trace Propagator
([#302](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/302)) ([#302](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/302))
- `opentelemetry-instrumentation-logging` Added logging instrumentation to enable log - trace correlation. - `opentelemetry-instrumentation-logging` Added logging instrumentation to enable log - trace correlation.
([#345](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/345)) ([#345](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/345))
### Removed ### Removed
- Remove `component` span attribute in instrumentations. - Remove `component` span attribute in instrumentations.
`opentelemetry-instrumentation-aiopg`, `opentelemetry-instrumentation-dbapi` Remove unused `database_type` parameter from `trace_integration` function. `opentelemetry-instrumentation-aiopg`, `opentelemetry-instrumentation-dbapi` Remove unused `database_type` parameter from `trace_integration` function.
([#301](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/301)) ([#301](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/301))
@ -176,6 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.17b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.17b0) - 2021-01-20 ## [0.17b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.17b0) - 2021-01-20
### Added ### Added
- `opentelemetry-instrumentation-sqlalchemy` Ensure spans have kind set to "CLIENT" - `opentelemetry-instrumentation-sqlalchemy` Ensure spans have kind set to "CLIENT"
([#278](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/278)) ([#278](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/278))
- `opentelemetry-instrumentation-celery` Add support for Celery version 5.x - `opentelemetry-instrumentation-celery` Add support for Celery version 5.x
@ -210,6 +221,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#273](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/273)) ([#273](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/273))
### Changed ### Changed
- Fix broken links to project ([#413](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/413)) - Fix broken links to project ([#413](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/413))
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-wsgi` Return `None` for `CarrierGetter` if key not found - `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-wsgi` Return `None` for `CarrierGetter` if key not found
([#233](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/233)) ([#233](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/233))
@ -239,6 +251,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#276](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/276)) ([#276](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/276))
### Removed ### Removed
- Remove Configuration - Remove Configuration
([#285](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/285)) ([#285](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/285))
@ -247,6 +260,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.16b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b0) - 2020-11-25 ## [0.16b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b0) - 2020-11-25
### Added ### Added
- `opentelemetry-instrumentation-flask` Add span name callback - `opentelemetry-instrumentation-flask` Add span name callback
([#152](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/152)) ([#152](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/152))
- `opentelemetry-sdk-extension-aws` Add AWS X-Ray Ids Generator Entry Point - `opentelemetry-sdk-extension-aws` Add AWS X-Ray Ids Generator Entry Point
@ -265,6 +279,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#181](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/181)) ([#181](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/181))
### Changed ### Changed
- `opentelemetry-instrumentation-pymemcache` Update pymemcache instrumentation to follow semantic conventions - `opentelemetry-instrumentation-pymemcache` Update pymemcache instrumentation to follow semantic conventions
([#183](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/183)) ([#183](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/183))
- `opentelemetry-instrumentation-redis` Update redis instrumentation to follow semantic conventions - `opentelemetry-instrumentation-redis` Update redis instrumentation to follow semantic conventions
@ -289,6 +304,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.15b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.15b0) - 2020-11-02 ## [0.15b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.15b0) - 2020-11-02
### Added ### Added
- `opentelemetry-instrumentation-requests` Add support for tracking http metrics - `opentelemetry-instrumentation-requests` Add support for tracking http metrics
([#1230](https://github.com/open-telemetry/opentelemetry-python/pull/1230)) ([#1230](https://github.com/open-telemetry/opentelemetry-python/pull/1230))
- `opentelemetry-instrumentation-django` Added capture of http.route - `opentelemetry-instrumentation-django` Added capture of http.route
@ -297,6 +313,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1230](https://github.com/open-telemetry/opentelemetry-python/pull/1230)) ([#1230](https://github.com/open-telemetry/opentelemetry-python/pull/1230))
### Changed ### Changed
- `opentelemetry-exporter-datadog` Make `SpanProcessor.on_start` accept parent Context - `opentelemetry-exporter-datadog` Make `SpanProcessor.on_start` accept parent Context
([#1251](https://github.com/open-telemetry/opentelemetry-python/pull/1251)) ([#1251](https://github.com/open-telemetry/opentelemetry-python/pull/1251))
- `opentelemetry-instrumentation-flask` Use `url.rule` instead of `request.endpoint` for span name - `opentelemetry-instrumentation-flask` Use `url.rule` instead of `request.endpoint` for span name
@ -313,6 +330,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.14b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.14b0) - 2020-10-13 ## [0.14b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.14b0) - 2020-10-13
### Added ### Added
- `opentelemetry-exporter-datadog` Add support for span resource labels and service name - `opentelemetry-exporter-datadog` Add support for span resource labels and service name
- `opentelemetry-instrumentation-celery` Span operation names now include the task type. - `opentelemetry-instrumentation-celery` Span operation names now include the task type.
([#1135](https://github.com/open-telemetry/opentelemetry-python/pull/1135)) ([#1135](https://github.com/open-telemetry/opentelemetry-python/pull/1135))
@ -326,6 +344,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1154](https://github.com/open-telemetry/opentelemetry-python/pull/1154)) ([#1154](https://github.com/open-telemetry/opentelemetry-python/pull/1154))
### Changed ### Changed
- `opentelemetry-instrumentation-pymongo` Cast PyMongo commands as strings - `opentelemetry-instrumentation-pymongo` Cast PyMongo commands as strings
([#1132](https://github.com/open-telemetry/opentelemetry-python/pull/1132)) ([#1132](https://github.com/open-telemetry/opentelemetry-python/pull/1132))
- `opentelemetry-instrumentation-system-metrics` Fix issue when specific metrics are not available in certain OS - `opentelemetry-instrumentation-system-metrics` Fix issue when specific metrics are not available in certain OS
@ -338,6 +357,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.13b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.13b0) - 2020-09-17 ## [0.13b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.13b0) - 2020-09-17
### Added ### Added
- `opentelemetry-instrumentation-falcon` Initial release. Added instrumentation for Falcon 2.0+ - `opentelemetry-instrumentation-falcon` Initial release. Added instrumentation for Falcon 2.0+
- `opentelemetry-instrumentation-tornado` Initial release. Supports Tornado 6.x on Python 3.5 and newer. - `opentelemetry-instrumentation-tornado` Initial release. Supports Tornado 6.x on Python 3.5 and newer.
- `opentelemetry-instrumentation-aiohttp-client` Add instrumentor and auto instrumentation support for aiohttp - `opentelemetry-instrumentation-aiohttp-client` Add instrumentor and auto instrumentation support for aiohttp
@ -348,18 +368,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1116](https://github.com/open-telemetry/opentelemetry-python/pull/1116)) ([#1116](https://github.com/open-telemetry/opentelemetry-python/pull/1116))
### Changed ### Changed
- `opentelemetry-instrumentation-aiohttp-client` Updating span name to match semantic conventions - `opentelemetry-instrumentation-aiohttp-client` Updating span name to match semantic conventions
([#972](https://github.com/open-telemetry/opentelemetry-python/pull/972)) ([#972](https://github.com/open-telemetry/opentelemetry-python/pull/972))
- `opentelemetry-instrumentation-dbapi` cursors and connections now produce spans when used with context managers - `opentelemetry-instrumentation-dbapi` cursors and connections now produce spans when used with context managers
([#1028](https://github.com/open-telemetry/opentelemetry-python/pull/1028)) ([#1028](https://github.com/open-telemetry/opentelemetry-python/pull/1028))
### Removed ### Removed
- Drop support for Python 3.4 - Drop support for Python 3.4
([#1099](https://github.com/open-telemetry/opentelemetry-python/pull/1099)) ([#1099](https://github.com/open-telemetry/opentelemetry-python/pull/1099))
## [0.12b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.12.0) - 2020-08-14 ## [0.12b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.12.0) - 2020-08-14
### Changed ### Changed
- `opentelemetry-ext-pymemcache` Change package name to opentelemetry-instrumentation-pymemcache - `opentelemetry-ext-pymemcache` Change package name to opentelemetry-instrumentation-pymemcache
([#966](https://github.com/open-telemetry/opentelemetry-python/pull/966)) ([#966](https://github.com/open-telemetry/opentelemetry-python/pull/966))
- `opentelemetry-ext-redis` Update default SpanKind to `SpanKind.CLIENT` - `opentelemetry-ext-redis` Update default SpanKind to `SpanKind.CLIENT`
@ -426,6 +449,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.11b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.11.0) - 2020-07-28 ## [0.11b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.11.0) - 2020-07-28
### Added ### Added
- `opentelemetry-instrumentation-aiopg` Initial release - `opentelemetry-instrumentation-aiopg` Initial release
- `opentelemetry-instrumentation-fastapi` Initial release - `opentelemetry-instrumentation-fastapi` Initial release
([#890](https://github.com/open-telemetry/opentelemetry-python/pull/890)) ([#890](https://github.com/open-telemetry/opentelemetry-python/pull/890))
@ -436,6 +460,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-ext-grpc` Add metric recording (bytes in/out, errors, latency) to gRPC client - `opentelemetry-ext-grpc` Add metric recording (bytes in/out, errors, latency) to gRPC client
### Changed ### Changed
- `opentelemetry-ext-pyramid` Use one general exclude list instead of two - `opentelemetry-ext-pyramid` Use one general exclude list instead of two
([#872](https://github.com/open-telemetry/opentelemetry-python/pull/872)) ([#872](https://github.com/open-telemetry/opentelemetry-python/pull/872))
- `opentelemetry-ext-boto` fails to export spans via jaeger - `opentelemetry-ext-boto` fails to export spans via jaeger
@ -456,6 +481,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.10b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.10.0) - 2020-06-23 ## [0.10b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.10.0) - 2020-06-23
### Added ### Added
- `opentelemetry-ext-pymemcache` Initial release - `opentelemetry-ext-pymemcache` Initial release
- `opentelemetry-ext-elasticsearch` Initial release - `opentelemetry-ext-elasticsearch` Initial release
- `opentelemetry-ext-celery` Add instrumentation for Celery - `opentelemetry-ext-celery` Add instrumentation for Celery
@ -468,6 +494,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.9b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.9.0) - 2020-06-10 ## [0.9b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.9.0) - 2020-06-10
### Added ### Added
- `opentelemetry-ext-pyramid` Initial release - `opentelemetry-ext-pyramid` Initial release
- `opentelemetry-ext-boto` Initial release - `opentelemetry-ext-boto` Initial release
- `opentelemetry-ext-botocore` Initial release - `opentelemetry-ext-botocore` Initial release
@ -477,6 +504,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.8b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.8.0) - 2020-05-27 ## [0.8b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.8.0) - 2020-05-27
### Added ### Added
- `opentelemetry-ext-datadog` Add exporter to Datadog - `opentelemetry-ext-datadog` Add exporter to Datadog
([#572](https://github.com/open-telemetry/opentelemetry-python/pull/572)) ([#572](https://github.com/open-telemetry/opentelemetry-python/pull/572))
- `opentelemetry-ext-sqlite3` Initial release - `opentelemetry-ext-sqlite3` Initial release
@ -489,12 +517,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-ext-django` Add support for django >= 1.10 (#717) - `opentelemetry-ext-django` Add support for django >= 1.10 (#717)
### Changed ### Changed
- `opentelemetry-ext-grpc` lint: version of grpc causes lint issues - `opentelemetry-ext-grpc` lint: version of grpc causes lint issues
([#696](https://github.com/open-telemetry/opentelemetry-python/pull/696)) ([#696](https://github.com/open-telemetry/opentelemetry-python/pull/696))
## [0.7b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.7.1) - 2020-05-12 ## [0.7b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.7.1) - 2020-05-12
### Added ### Added
- `opentelemetry-ext-redis` Initial release - `opentelemetry-ext-redis` Initial release
- `opentelemetry-ext-jinja2` Add jinja2 instrumentation - `opentelemetry-ext-jinja2` Add jinja2 instrumentation
([#643](https://github.com/open-telemetry/opentelemetry-python/pull/643)) ([#643](https://github.com/open-telemetry/opentelemetry-python/pull/643))
@ -518,12 +548,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#654](https://github.com/open-telemetry/opentelemetry-python/pull/654)) ([#654](https://github.com/open-telemetry/opentelemetry-python/pull/654))
### Changed ### Changed
- `opentelemetry-ext-http-requests` Rename package to opentelemetry-ext-requests - `opentelemetry-ext-http-requests` Rename package to opentelemetry-ext-requests
([#619](https://github.com/open-telemetry/opentelemetry-python/pull/619)) ([#619](https://github.com/open-telemetry/opentelemetry-python/pull/619))
## [0.6b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.6.0) - 2020-03-30 ## [0.6b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.6.0) - 2020-03-30
### Added ### Added
- `opentelemetry-ext-flask` Add an entry_point to be usable in auto-instrumentation - `opentelemetry-ext-flask` Add an entry_point to be usable in auto-instrumentation
([#327](https://github.com/open-telemetry/opentelemetry-python/pull/327)) ([#327](https://github.com/open-telemetry/opentelemetry-python/pull/327))
- `opentelemetry-ext-grpc` Add gRPC integration - `opentelemetry-ext-grpc` Add gRPC integration
@ -534,11 +566,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.4a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.4.0) - 2020-02-21 ## [0.4a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.4.0) - 2020-02-21
### Added ### Added
- `opentelemetry-ext-psycopg2` Initial release - `opentelemetry-ext-psycopg2` Initial release
- `opentelemetry-ext-dbapi` Initial release - `opentelemetry-ext-dbapi` Initial release
- `opentelemetry-ext-mysql` Initial release - `opentelemetry-ext-mysql` Initial release
### Changed ### Changed
- `opentelemetry-ext-pymongo` Updating network connection attribute names - `opentelemetry-ext-pymongo` Updating network connection attribute names
([#350](https://github.com/open-telemetry/opentelemetry-python/pull/350)) ([#350](https://github.com/open-telemetry/opentelemetry-python/pull/350))
- `opentelemetry-ext-wsgi` Updating network connection attribute names - `opentelemetry-ext-wsgi` Updating network connection attribute names
@ -549,10 +583,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.3a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.3.0) - 2019-12-11 ## [0.3a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.3.0) - 2019-12-11
### Added ### Added
- `opentelemetry-ext-flask` Initial release - `opentelemetry-ext-flask` Initial release
- `opentelemetry-ext-pymongo` Initial release - `opentelemetry-ext-pymongo` Initial release
### Changed ### Changed
- `opentelemetry-ext-wsgi` Support new semantic conventions - `opentelemetry-ext-wsgi` Support new semantic conventions
([#299](https://github.com/open-telemetry/opentelemetry-python/pull/299)) ([#299](https://github.com/open-telemetry/opentelemetry-python/pull/299))
- `opentelemetry-ext-wsgi` Updates for core library changes - `opentelemetry-ext-wsgi` Updates for core library changes
@ -560,11 +596,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.2a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.2.0) - 2019-10-29 ## [0.2a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.2.0) - 2019-10-29
### Changed ### Changed
- `opentelemetry-ext-wsgi` Updates for core library changes - `opentelemetry-ext-wsgi` Updates for core library changes
- `opentelemetry-ext-http-requests` Updates for core library changes - `opentelemetry-ext-http-requests` Updates for core library changes
## [0.1a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.1.0) - 2019-09-30 ## [0.1a0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.1.0) - 2019-09-30
### Added ### Added
- `opentelemetry-ext-wsgi` Initial release - `opentelemetry-ext-wsgi` Initial release
- `opentelemetry-ext-http-requests` Initial release - `opentelemetry-ext-http-requests` Initial release

View File

@ -51,9 +51,14 @@ Usage
FastAPIInstrumentor.instrument_app(app) FastAPIInstrumentor.instrument_app(app)
You can also pass the list of urls to exclude explicitly to the instrumentation call:
.. code-block:: python
FastAPIInstrumentor.instrument_app(app, "client/.*/info,healthcheck")
References References
---------- ----------
* `OpenTelemetry Project <https://opentelemetry.io/>`_ * `OpenTelemetry Project <https://opentelemetry.io/>`_
* `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_ * `OpenTelemetry Python Examples <https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples>`_

View File

@ -21,9 +21,9 @@ from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
from opentelemetry.instrumentation.asgi.package import _instruments from opentelemetry.instrumentation.asgi.package import _instruments
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.util.http import get_excluded_urls from opentelemetry.util.http import get_excluded_urls, parse_excluded_urls
_excluded_urls = get_excluded_urls("FASTAPI") _excluded_urls_from_env = get_excluded_urls("FASTAPI")
class FastAPIInstrumentor(BaseInstrumentor): class FastAPIInstrumentor(BaseInstrumentor):
@ -35,12 +35,19 @@ class FastAPIInstrumentor(BaseInstrumentor):
_original_fastapi = None _original_fastapi = None
@staticmethod @staticmethod
def instrument_app(app: fastapi.FastAPI, tracer_provider=None): def instrument_app(
app: fastapi.FastAPI, tracer_provider=None, excluded_urls=None,
):
"""Instrument an uninstrumented FastAPI application.""" """Instrument an uninstrumented FastAPI application."""
if not getattr(app, "is_instrumented_by_opentelemetry", False): if not getattr(app, "is_instrumented_by_opentelemetry", False):
if excluded_urls is None:
excluded_urls = _excluded_urls_from_env
else:
excluded_urls = parse_excluded_urls(excluded_urls)
app.add_middleware( app.add_middleware(
OpenTelemetryMiddleware, OpenTelemetryMiddleware,
excluded_urls=_excluded_urls, excluded_urls=excluded_urls,
span_details_callback=_get_route_details, span_details_callback=_get_route_details,
tracer_provider=tracer_provider, tracer_provider=tracer_provider,
) )
@ -52,6 +59,12 @@ class FastAPIInstrumentor(BaseInstrumentor):
def _instrument(self, **kwargs): def _instrument(self, **kwargs):
self._original_fastapi = fastapi.FastAPI self._original_fastapi = fastapi.FastAPI
_InstrumentedFastAPI._tracer_provider = kwargs.get("tracer_provider") _InstrumentedFastAPI._tracer_provider = kwargs.get("tracer_provider")
_excluded_urls = kwargs.get("excluded_urls")
_InstrumentedFastAPI._excluded_urls = (
_excluded_urls_from_env
if _excluded_urls is None
else parse_excluded_urls(_excluded_urls)
)
fastapi.FastAPI = _InstrumentedFastAPI fastapi.FastAPI = _InstrumentedFastAPI
def _uninstrument(self, **kwargs): def _uninstrument(self, **kwargs):
@ -60,12 +73,13 @@ class FastAPIInstrumentor(BaseInstrumentor):
class _InstrumentedFastAPI(fastapi.FastAPI): class _InstrumentedFastAPI(fastapi.FastAPI):
_tracer_provider = None _tracer_provider = None
_excluded_urls = None
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.add_middleware( self.add_middleware(
OpenTelemetryMiddleware, OpenTelemetryMiddleware,
excluded_urls=_excluded_urls, excluded_urls=_InstrumentedFastAPI._excluded_urls,
span_details_callback=_get_route_details, span_details_callback=_get_route_details,
tracer_provider=_InstrumentedFastAPI._tracer_provider, tracer_provider=_InstrumentedFastAPI._tracer_provider,
) )

View File

@ -31,6 +31,12 @@ class TestFastAPIManualInstrumentation(TestBase):
self._instrumentor.instrument_app(app) self._instrumentor.instrument_app(app)
return app return app
def _create_app_explicit_excluded_urls(self):
app = self._create_fastapi_app()
to_exclude = "/user/123,/foobar"
self._instrumentor.instrument_app(app, excluded_urls=to_exclude)
return app
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.env_patch = patch.dict( self.env_patch = patch.dict(
@ -39,7 +45,7 @@ class TestFastAPIManualInstrumentation(TestBase):
) )
self.env_patch.start() self.env_patch.start()
self.exclude_patch = patch( self.exclude_patch = patch(
"opentelemetry.instrumentation.fastapi._excluded_urls", "opentelemetry.instrumentation.fastapi._excluded_urls_from_env",
get_excluded_urls("FASTAPI"), get_excluded_urls("FASTAPI"),
) )
self.exclude_patch.start() self.exclude_patch.start()
@ -84,6 +90,17 @@ class TestFastAPIManualInstrumentation(TestBase):
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0) self.assertEqual(len(spans), 0)
def test_fastapi_excluded_urls_not_env(self):
"""Ensure that given fastapi routes are excluded when passed explicitly (not in the environment)"""
app = self._create_app_explicit_excluded_urls()
client = TestClient(app)
client.get("/user/123")
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)
client.get("/foobar")
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)
@staticmethod @staticmethod
def _create_fastapi_app(): def _create_fastapi_app():
app = fastapi.FastAPI() app = fastapi.FastAPI()
@ -124,6 +141,20 @@ class TestAutoInstrumentation(TestFastAPIManualInstrumentation):
self._instrumentor.instrument(tracer_provider=tracer_provider) self._instrumentor.instrument(tracer_provider=tracer_provider)
return self._create_fastapi_app() return self._create_fastapi_app()
def _create_app_explicit_excluded_urls(self):
resource = Resource.create({"key1": "value1", "key2": "value2"})
tracer_provider, exporter = self.create_tracer_provider(
resource=resource
)
self.memory_exporter = exporter
to_exclude = "/user/123,/foobar"
self._instrumentor.uninstrument() # Disable previous instrumentation (setUp)
self._instrumentor.instrument(
tracer_provider=tracer_provider, excluded_urls=to_exclude,
)
return self._create_fastapi_app()
def test_request(self): def test_request(self):
self._client.get("/foobar") self._client.get("/foobar")
spans = self.memory_exporter.get_finished_spans() spans = self.memory_exporter.get_finished_spans()

View File

@ -52,6 +52,13 @@ def get_excluded_urls(instrumentation):
_root.format("{}_EXCLUDED_URLS".format(instrumentation)), [] _root.format("{}_EXCLUDED_URLS".format(instrumentation)), []
) )
return parse_excluded_urls(excluded_urls)
def parse_excluded_urls(excluded_urls):
"""
Small helper to put an arbitrary url list inside of ExcludeList
"""
if excluded_urls: if excluded_urls:
excluded_urls = [ excluded_urls = [
excluded_url.strip() for excluded_url in excluded_urls.split(",") excluded_url.strip() for excluded_url in excluded_urls.split(",")