42 Commits

Author SHA1 Message Date
4d6893e8fa fastapi: fix wrapping of middlewares (#3012)
* fastapi: fix wrapping of middlewares

* fix import, super

* add test

* changelog

* lint

* lint

* fix

* ci

* fix wip

* fix

* fix

* lint

* lint

* Exit?

* Update test_fastapi_instrumentation.py

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>

* remove break

* fix

* remove dunders

* add test

* lint

* add endpoint to class

* fmt

* pr feedback

* move type ignores

* fix sphinx?

* Update CHANGELOG.md

* update fastapi versions

* fix?

* generate

* stop passing on user-supplied error handler

This prevents potential side effects, such as logging, to be executed
more than once per request handler exception.

* fix ci

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix ruff

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* remove unused funcs

Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* fix lint,ruff

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix changelog

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* add changelog note

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix conflicts with main

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Alexander Dorn <ad@not.one>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
2025-05-20 11:00:56 -03:00
ef2b5468d5 Fix ruff (#3515) 2025-05-19 09:59:28 -03:00
ec731581af refactor(fastapi): replace uses of SpanAttributes with opentelemetry.semconv.attributes (#3491)
* refactor(fastapi): migrate HTTP_ROUTE from SpanAttributes to new semantic conventions

Replaced usage of `SpanAttributes.HTTP_ROUTE` with `opentelemetry.semconv.attributes.http_attributes.HTTP_ROUTE`
as part of the migration away from `SpanAttributes`.

Refs: #3475

* refactor(fastapi): refactor tests

* refactor(fastapi): remove duplicated import

* sort imports

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2025-05-19 08:15:49 +00:00
6d5a5149d0 Make auto instrumentation use the same dependency resolver as manual instrumentation does (#3202) 2025-04-08 15:11:09 +02:00
0adc58b4bf Introducing ruff as linter and formatter (basic setup) (#2921) 2024-10-23 10:54:14 -07:00
e4ece57a81 Remove pkg resources (#2871) 2024-10-19 06:49:08 -07:00
d135f20c29 Fastapi auto tests (#2860)
* ep test passes

* cleaned ep test

* Corrected mock paths.

* with installed works

* tests pass

* Clean up

* Clean up

* lint

* lint
2024-09-12 09:36:59 +02:00
b0129acbdf fix ut in pypy (#2809) 2024-08-28 10:02:42 -07:00
fc1c8f0f3f Audit and test opentelemetry-instrumentation-fastapi NoOpTracerProvider (#2779) 2024-08-07 08:41:01 -07:00
3e18560228 feat: add header extraction parameters to FastAPIInstrumentor().instrument_app (#2241)
* add header parameters to FastAPIInstrumentor().instrument_app

* add changelog

* move #2072 changelog to unreleased

* remove accidental pprint

* linting

* future annotations for fastapi

* same logic for instrument()

* Fix lint

* Fix test case

---------

Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
2024-08-01 16:15:34 -06:00
26ab80925f Remove extra duration check in fastapi test (#2743) 2024-07-26 08:04:09 -07:00
6293d6a991 HTTP semantic convention stability migration for fastapi (#2682) 2024-07-12 11:48:04 -07:00
ef4bc9f9b4 fix(opentelemetry-instrumentation-asgi): Correct http.url attribute generation (#2477) 2024-07-03 10:28:54 -07:00
f6ed62a7aa Repeated headers list for ASGI frameworks (#2361)
* avoid loosing repeated HTTP headers

* fix fof wsgi, test in falcon

* add changelog

* add more tests

* linting

* fix falcon and flask

* remove unused test

* Use a list for repeated HTTP headers

* linting

* add changelog entry

* update docs and improve fastapi tests

* revert changes in wsgi based webframeworks

* fix linting

* Fix import path of typing symbols

---------

Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
2024-06-20 16:37:26 -06:00
da78275a55 increase delta for fastapi flaky test (#2591) 2024-06-11 10:16:18 -07:00
5b841282ab Do not use asgi name and version for tracer/meter for instrumentations using Asgi Middleware (#2580) 2024-06-06 12:52:32 -07:00
ed51ebb312 feat(asgi,fastapi,starlette)!: provide both send and receive hooks with scope and message (#2546) 2024-06-03 10:18:47 -07:00
ac97b00457 Fix typos in test names (#2558) 2024-05-28 14:31:44 -07:00
256d8ce12d Add http.server.request.size for ASGI metric implementation (#1867)
* Update changelog file.

* Update changelog file.

* Add new request.size metric for ASGI middleware.

* Clean-up.

* Refactor try except section.

---------

Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
2023-06-21 23:56:38 +03:00
60753e2a55 Add http.server.response.size metric to ASGI implementation. (#1789)
* Add http.server.response.size metric to ASGI implementation.
Add new unit tests.

* Update changelog.

* Fix linting by disabling too-many-nested-blocks

* Put new logic in a new method

* Refactor the placement of new logic.

* Fixed the unit tests in FastAPI and Starlette

* Update changelog.

* FIx lint errors.

* Refactor getting content-length header

* Refactor getting content-length header

---------

Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
2023-06-19 23:00:59 +03:00
743ac64661 Issue #1757 - Update HTTP server/client instrumentation span names (#1759)
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2023-06-16 00:21:05 +02:00
e5d9ac5755 fix fastapi instrumentation tests for version 0.91 (#1710) 2023-03-07 20:29:24 +05:30
bc57cc029d fix(asgi-instrumentation): extract target after running the framework (#1461) 2022-12-05 02:00:09 +00:00
496d6581cc Add support for regular expression matching and sanitizing of headers in FastAPI. (#1403) 2022-11-07 22:23:08 +05:30
0b69786c30 fix flaky test in fastapi (#1344) 2022-09-21 01:29:35 +05:30
2b7a0057da uninstruemnt existing instances before uninstrumenting fastapi class (#1258) 2022-09-19 07:25:07 +00:00
56530ebdfc Metric instrumentation fastapi (#1199) 2022-09-12 20:11:58 +00:00
4c2382338d fix check of is_otel_instrumented (#1313) 2022-09-09 10:58:31 -07:00
18e056b85a Codespell ci (#1237) 2022-08-29 15:08:25 +05:30
45448f8bb2 FastAPI: capture custom request response headers in span attributes (#1032) 2022-04-11 11:10:26 -07:00
4c813c47e4 ASGI: Conditionally create SERVER spans (#843) 2022-01-07 15:12:58 -06:00
3137c1fa41 Upgrade black (#802) 2021-11-10 20:57:01 +00:00
ffc2a2ff4c More consistent assertion methods (#641)
* More consistent assertion methods

* Updated core SHA
2021-08-30 22:46:18 +02:00
c5c6977584 Add hooks for aiohttp, asgi, starlette, fastAPI, urllib, urllib3 (#576) 2021-07-26 14:34:50 -07:00
56da6d74df Consistent way of not instrumenting multiple times (#549) 2021-07-09 09:55:44 -07:00
7cae4d3001 Enable passing explicit urls to exclude in instrumentation in FastAPI (#486) 2021-06-14 17:17:39 -07:00
3ec77360cb Update instrumentations to use tracer_provider for creating tracer if given, otherwise use global tracer provider (#402) 2021-04-28 08:36:37 -07:00
8d0c150b31 Sync with auto generated semantic convention constants (#428) 2021-04-19 23:37:10 -07:00
2fd68a2bf9 Remove Configuration from instrumentations (#285) 2021-02-04 08:02:37 -08:00
472f845381 Upgrade isort and enable black compat mode (#248) 2021-01-05 07:23:53 -08:00
76fda25b25 Add ability to exclude some routes in fastapi and starlette (#237) 2020-12-08 10:24:32 -08:00
c05e1798b7 Rename web framework packages from "ext" to "instrumentation" (#961) 2020-10-21 21:55:34 -07:00