Skip to content

Commit

Permalink
fix check of is_otel_instrumented (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAnshul756 committed Sep 9, 2022
1 parent ff9651e commit 4c23823
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1208](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1208))
- `opentelemetry-instrumentation-aiohttp-client` Fix producing additional spans with each newly created ClientSession
- ([#1246](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1246))
- Add _is_openetlemetry_instrumented check in _InstrumentedFastAPI class
([#1313](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1313))

## [1.12.0-0.33b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0-0.33b0) - 2022-08-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def __init__(self, *args, **kwargs):
client_response_hook=_InstrumentedFastAPI._client_response_hook,
tracer_provider=_InstrumentedFastAPI._tracer_provider,
)
self._is_instrumented_by_opentelemetry = True


def _get_route_details(scope):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ def test_request(self):
self.assertEqual(span.resource.attributes["key1"], "value1")
self.assertEqual(span.resource.attributes["key2"], "value2")

def test_mulitple_way_instrumentation(self):
self._instrumentor.instrument_app(self._app)
count = 0
for middleware in self._app.user_middleware:
if middleware.cls is OpenTelemetryMiddleware:
count += 1
self.assertEqual(count, 1)

def tearDown(self):
self._instrumentor.uninstrument()
super().tearDown()
Expand Down

0 comments on commit 4c23823

Please sign in to comment.