-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture common HTTP attributes from API Gateway proxy events in Lambd…
…a instrumentor (#1233)
- Loading branch information
1 parent
a8cf644
commit 36264e9
Showing
6 changed files
with
297 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
...tation/opentelemetry-instrumentation-aws-lambda/tests/mocks/api_gateway_http_api_event.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Generated via `sam local generate-event apigateway http-api-proxy` | ||
|
||
MOCK_LAMBDA_API_GATEWAY_HTTP_API_EVENT = { | ||
"version": "2.0", | ||
"routeKey": "$default", | ||
"rawPath": "/path/to/resource", | ||
"rawQueryString": "parameter1=value1¶meter1=value2¶meter2=value", | ||
"cookies": ["cookie1", "cookie2"], | ||
"headers": {"header1": "value1", "Header2": "value1,value2"}, | ||
"queryStringParameters": { | ||
"parameter1": "value1,value2", | ||
"parameter2": "value", | ||
}, | ||
"requestContext": { | ||
"accountId": "123456789012", | ||
"apiId": "api-id", | ||
"authentication": { | ||
"clientCert": { | ||
"clientCertPem": "CERT_CONTENT", | ||
"subjectDN": "www.example.com", | ||
"issuerDN": "Example issuer", | ||
"serialNumber": "a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1", | ||
"validity": { | ||
"notBefore": "May 28 12:30:02 2019 GMT", | ||
"notAfter": "Aug 5 09:36:04 2021 GMT", | ||
}, | ||
} | ||
}, | ||
"authorizer": { | ||
"jwt": { | ||
"claims": {"claim1": "value1", "claim2": "value2"}, | ||
"scopes": ["scope1", "scope2"], | ||
} | ||
}, | ||
"domainName": "id.execute-api.us-east-1.amazonaws.com", | ||
"domainPrefix": "id", | ||
"http": { | ||
"method": "POST", | ||
"path": "/path/to/resource", | ||
"protocol": "HTTP/1.1", | ||
"sourceIp": "192.168.0.1/32", | ||
"userAgent": "agent", | ||
}, | ||
"requestId": "id", | ||
"routeKey": "$default", | ||
"stage": "$default", | ||
"time": "12/Mar/2020:19:03:58 +0000", | ||
"timeEpoch": 1583348638390, | ||
}, | ||
"body": "eyJ0ZXN0IjoiYm9keSJ9", | ||
"pathParameters": {"parameter1": "value1"}, | ||
"isBase64Encoded": True, | ||
"stageVariables": {"stageVariable1": "value1", "stageVariable2": "value2"}, | ||
} |
85 changes: 85 additions & 0 deletions
85
...mentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/api_gateway_proxy_event.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Generated via `sam local generate-event apigateway aws-proxy` | ||
|
||
MOCK_LAMBDA_API_GATEWAY_PROXY_EVENT = { | ||
"body": "eyJ0ZXN0IjoiYm9keSJ9", | ||
"resource": "/{proxy+}", | ||
"path": "/path/to/resource", | ||
"httpMethod": "POST", | ||
"isBase64Encoded": True, | ||
"queryStringParameters": {"foo": "bar"}, | ||
"multiValueQueryStringParameters": {"foo": ["bar"]}, | ||
"pathParameters": {"proxy": "/path/to/resource"}, | ||
"stageVariables": {"baz": "qux"}, | ||
"headers": { | ||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | ||
"Accept-Encoding": "gzip, deflate, sdch", | ||
"Accept-Language": "en-US,en;q=0.8", | ||
"Cache-Control": "max-age=0", | ||
"CloudFront-Forwarded-Proto": "https", | ||
"CloudFront-Is-Desktop-Viewer": "true", | ||
"CloudFront-Is-Mobile-Viewer": "false", | ||
"CloudFront-Is-SmartTV-Viewer": "false", | ||
"CloudFront-Is-Tablet-Viewer": "false", | ||
"CloudFront-Viewer-Country": "US", | ||
"Host": "1234567890.execute-api.us-east-1.amazonaws.com", | ||
"Upgrade-Insecure-Requests": "1", | ||
"User-Agent": "Custom User Agent String", | ||
"Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", | ||
"X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", | ||
"X-Forwarded-For": "127.0.0.1, 127.0.0.2", | ||
"X-Forwarded-Port": "443", | ||
"X-Forwarded-Proto": "https", | ||
}, | ||
"multiValueHeaders": { | ||
"Accept": [ | ||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" | ||
], | ||
"Accept-Encoding": ["gzip, deflate, sdch"], | ||
"Accept-Language": ["en-US,en;q=0.8"], | ||
"Cache-Control": ["max-age=0"], | ||
"CloudFront-Forwarded-Proto": ["https"], | ||
"CloudFront-Is-Desktop-Viewer": ["true"], | ||
"CloudFront-Is-Mobile-Viewer": ["false"], | ||
"CloudFront-Is-SmartTV-Viewer": ["false"], | ||
"CloudFront-Is-Tablet-Viewer": ["false"], | ||
"CloudFront-Viewer-Country": ["US"], | ||
"Host": ["0123456789.execute-api.us-east-1.amazonaws.com"], | ||
"Upgrade-Insecure-Requests": ["1"], | ||
"User-Agent": ["Custom User Agent String"], | ||
"Via": [ | ||
"1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)" | ||
], | ||
"X-Amz-Cf-Id": [ | ||
"cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==" | ||
], | ||
"X-Forwarded-For": ["127.0.0.1, 127.0.0.2"], | ||
"X-Forwarded-Port": ["443"], | ||
"X-Forwarded-Proto": ["https"], | ||
}, | ||
"requestContext": { | ||
"accountId": "123456789012", | ||
"resourceId": "123456", | ||
"stage": "prod", | ||
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", | ||
"requestTime": "09/Apr/2015:12:34:56 +0000", | ||
"requestTimeEpoch": 1428582896000, | ||
"identity": { | ||
"cognitoIdentityPoolId": None, | ||
"accountId": None, | ||
"cognitoIdentityId": None, | ||
"caller": None, | ||
"accessKey": None, | ||
"sourceIp": "127.0.0.1", | ||
"cognitoAuthenticationType": None, | ||
"cognitoAuthenticationProvider": None, | ||
"userArn": None, | ||
"userAgent": "Custom User Agent String", | ||
"user": None, | ||
}, | ||
"path": "/prod/path/to/resource", | ||
"resourcePath": "/{proxy+}", | ||
"httpMethod": "POST", | ||
"apiId": "1234567890", | ||
"protocol": "HTTP/1.1", | ||
}, | ||
} |
This file contains 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
This file contains 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