opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

feat: add header extraction parameters to `FastAPIInstrumentor().instrument_app`

Open samuelcolvin opened this issue 1 year ago • 4 comments

Description

Continuing from the work done in https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2026 by @adriangb, this adds three new keyword parameters to FastAPIInstrumentor().instrument_app:

  • http_capture_headers_server_request
  • http_capture_headers_server_response
  • http_capture_headers_sanitize_fields

All of course have the same meaning and behavior as in the asgi OpenTelemetryMiddleware - they're just passed straight through to that middleware.

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added TestHTTPAppWithCustomHeadersParameters

Does This PR Require a Core Repo Change?

  • [ ] Yes. - Link to PR:
  • [x] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • [x] Followed the style guidelines of this project
  • [x] Changelogs have been updated
  • [x] Unit tests have been added
  • [x] Documentation has been updated

samuelcolvin avatar Feb 16 '24 11:02 samuelcolvin

sorry about that, linting fixed hopefully.

samuelcolvin avatar Feb 20 '24 13:02 samuelcolvin

Lgtm too. Please could you fix the Changelog merge conflict that popped up after the 1.23.0 release.

tammy-baylis-swi avatar Mar 06 '24 23:03 tammy-baylis-swi

Lgtm too. Please could you fix the Changelog merge conflict that popped up after the 1.23.0 release.

Thanks, done.

samuelcolvin avatar Mar 07 '24 10:03 samuelcolvin

@lzchen I've corrected those things.

samuelcolvin avatar Mar 18 '24 18:03 samuelcolvin