feat: Lambdas behind an Application Load Balancer get HTTP attributes on their spans - #102
Open
RaphaelManke wants to merge 1 commit into
Open
feat: Lambdas behind an Application Load Balancer get HTTP attributes on their spans#102RaphaelManke wants to merge 1 commit into
RaphaelManke wants to merge 1 commit into
Conversation
Application Load Balancer events were detected only well enough to be excluded from API Gateway classification, so ALB-triggered invocations got no HTTP attributes at all. Extend the existing extraction to cover them. ALB carries the same information under different field names, so ApiGatewayVersion becomes HttpEventKind with an Alb variant and the extraction branches on it. Attributes ALB has no source for are omitted rather than guessed: there is no resource/routeKey, so no http.route, and no protocol field, so no network.protocol.version. Two ALB behaviours needed handling that API Gateway does not have: - Target groups with lambda.multi_value_headers.enabled send multiValueHeaders and multiValueQueryStringParameters *instead of* their single-value counterparts, in both directions. Reading only `headers` yields nothing at all on those target groups. - ALB listeners serve plain HTTP, so url.scheme follows x-forwarded-proto rather than being hardcoded to https. Verified against a real ALB rather than the docs alone: a temporary load balancer with both target group types confirmed the field shapes, header lower-casing, x-forwarded-for chaining, un-decoded query strings, and the headers-only health check event. The DASH0_API_GATEWAY_* env vars now gate ALB capture too; their names are kept for backwards compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
http.route, because the event has no route in it to read.Notable changes
Details
http.routeandnetwork.protocol.versionare absent for ALB. The event carries no route template and no protocol field, so the extension omits them rather than guessing. It does not fall back tourl.pathas the route, since that value is high cardinality.DASH0_ENABLE_API_GATEWAY_SPAN_NAME, the extension names an ALB span after the bare method, such asGET. That is the HTTP semconv fallback when no route is available.DASH0_API_GATEWAY_*variables now gate ALB capture too. Their names stay as they are so nothing breaks for current users, and the README notes it.ApiGatewayVersionbecomesHttpEventKind, and theInvocationEntryfields lose theirapi_gateway_prefix. No env var or attribute name changes.Feature: HTTP attributes for ALB-triggered invocations
Details
What & Why:
requestContextand a top-levelhttpMethod, so without that guard the extension would have reported them as REST API v1. Nothing picked them back up afterwards, so an ALB-triggered invocation got no HTTP attributes and no response status code.Implementation:
httpMethodwould otherwise match the v1 branch.url.schemereadsx-forwarded-proto,server.addressandserver.portreadhostwithx-forwarded-portas the port fallback, andclient.addresstakes the firstx-forwarded-forhop.url.schemerather than hardcodinghttpsas the API Gateway branches do, because ALB listeners serve plain HTTP as well.lambda.multi_value_headers.enabledsendmultiValueHeadersandmultiValueQueryStringParametersinstead of their single-value counterparts, in both directions. Reading onlyheadersreturns nothing at all on those target groups, so the code resolves either shape. A header sent more than once becomes one comma-joined value, which keeps the attribute a string in both configurations.user-agentand nothing else, so each attribute is optional on its own rather than all-or-nothing.flowchart LR E[invoke event] --> D{requestContext.elb?} D -->|yes| A[ALB] D -->|no| V{rawPath and<br/>requestContext.http?} V -->|yes| V2[API Gateway v2] V -->|no| V1{httpMethod?} V1 -->|yes| R[API Gateway v1] V1 -->|no| N[not HTTP, no attributes]Verification:
x-forwarded-for.requestContextholds onlyelb.targetGroupArn, with no route information anywhere in the eventx-forwarded-foruser-agent