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

Add support for ALB events in opentelemetry-instrumentation-aws-lambda

Open jbfenton opened this issue 1 year ago • 4 comments
trafficstars

Description

The current opentelemetry-instrumentation-aws-lambda module only supports conventional API Gateway events which typically contain a headers field that the trace context can be extracted from.

ALB events will only contain a headers field when Multi value headers is disabled for the ALB in question. Otherwise the necessary headers will be found under the 'multiValueHeaders` field: ELB: Lambda functions as targets

As a part of implementing this change, types + interfaces of the instrumentation have been hardened so that we avoid passing Optional parameters down the call chain wherever it is practical.

Handlers for processing types of events have also been placed in wrappers to make it a little easier to identify where we are pulling the trace context from, and where/why a given set of span attributes is being extracted + applied.

The hope is that in the future if someone wanted to add an additional span attribute for an API Gateway Proxy they could simply add it to APIGatewayProxyWrapper.set_pre_execution_span_attributes without risk of breaking any of the other event handlers.

This change should also resolve: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2511

Type of change

Please delete options that are not relevant.

  • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update
    • Current documentation doesn't cover event_context_extractor that has changed.

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

  • Sample events have been added for all types of events that the instrumentation supports.
  • Unit tests have also been aded for new/modified utility functions.

Does This PR Require a Core Repo Change?

  • [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
  • [ ] Documentation has been updated

jbfenton avatar Jun 07 '24 06:06 jbfenton