Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with headers not being a dict in AWS lambda instr #1055

Merged
merged 6 commits into from Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.11.1-0.30b1...HEAD)

### Fixed
- `opentelemetry-instrumentation-aws-lambda` Fixed an issue - in some rare cases (API GW proxy integration test)
This conversation was marked as resolved.
Show resolved Hide resolved
headers are set to None, breaking context propagators.
([#1055](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1055))

## [1.11.1-0.30b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.1-0.30b1) - 2022-04-21

### Added
- `opentelemetry-instrumentation-starlette` Capture custom request/response headers in span attributes
([#1046])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1046)

### Fixed
- Prune autoinstrumentation sitecustomize module directory from PYTHONPATH immediately
([#1066](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1066))

Expand All @@ -23,13 +28,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-pyramid` Fixed which package is the correct caller in _traced_init.
([#830](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/830))
- `opentelemetry-instrumentation-tornado` Fix Tornado errors mapping to 500
([#1048])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1048)
([#1048](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1048))
- `opentelemetry-instrumentation-urllib` make span attributes available to sampler
([1014](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1014))
- `opentelemetry-instrumentation-flask` Fix non-recording span bug
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
([#999](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999))
- `opentelemetry-instrumentation-tornado` Fix non-recording span bug
([#999])(https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999)
([#999](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/999))

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def _default_event_context_extractor(lambda_event: Any) -> Context:
Assumes the Lambda Event is a map with the headers under the 'headers' key.
This is the mapping to use when the Lambda is invoked by an API Gateway
REST API where API Gateway is acting as a pure proxy for the request.
Protects headers from being something other than dictionary, as this
is what downstream propagators expect.

See more:
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
Expand All @@ -118,12 +120,14 @@ def _default_event_context_extractor(lambda_event: Any) -> Context:
Returns:
A Context with configuration found in the event.
"""
headers = None
try:
headers = lambda_event["headers"]
except (TypeError, KeyError):
logger.debug(
"Extracting context from Lambda Event failed: either enable X-Ray active tracing or configure API Gateway to trigger this Lambda function as a pure proxy. Otherwise, generated spans will have an invalid (empty) parent context."
)
if not isinstance(headers, dict):
headers = {}
return get_global_textmap().extract(headers)

Expand Down