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

@opentelemetry/instrumentation-aws-lambda should read API gateway parameters by default #999

Open
lizthegrey opened this issue May 3, 2022 · 13 comments

Comments

@lizthegrey
Copy link
Member

lizthegrey commented May 3, 2022

Is your feature request related to a problem? Please describe

Invokes create a root span, but populate only details about the lambda itself (e.g. /usr/bin/node, lambda runtime version, function name) rather than about the request being performed. When the lambda is being called directly from API gateway, these details should automatically be populated, rather than relying upon telemetry from API gateway to have been also plumbed up and amazon trace header used for correlation.

Describe the solution you'd like to see

the following event.input (but not event.body, to avoid PII leaks) values should be automatically extracted and put into attributes (essentially as a default requestHook); example from https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html

  "input":{
    "resource":"/helloworld",
    "path":"/helloworld",
    "httpMethod":"POST",
    "headers": {
      "Accept":"*/*",
      "content-type":"application/json",
      "Host":"r275xc9bmd.execute-api.us-east-1.amazonaws.com",
      "User-Agent":"curl/7.64.0",
      "X-Amzn-Trace-Id":"Root=1-1a2b3c4d-a1b2c3d4e5f6a1b2c3d4e5f6",
      "X-Forwarded-For":"72.21.198.64",
      "X-Forwarded-Port":"443",
      "X-Forwarded-Proto":"https"
    },
    "queryStringParameters":{
      "city":"Seattle",
      "name":"John"
    },
  },

Describe alternatives you've considered

These attributes could be left on an API gateway span, except there's no easy way to produce OTel formatted spans out of API gateway logs, and even then, API gateway only speaks amazon trace header, not w3c tracecontext, so you'd need to use amazon propagator.

Additional context

tagging component owners @willarmiros @NathanielRN and tagging Honeycomb PM @cartermp
tagging users who encountered this problem and showed me: @longility @nikordaris @meleksomai

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jul 4, 2022
@lizthegrey
Copy link
Member Author

still is a problem/footgun.

@NathanielRN
Copy link
Contributor

Tagging @vasireddy99 and @bryan-aguilar to triage this for investigation.

@dyladan dyladan removed the stale label Jul 5, 2022
@dyladan
Copy link
Member

dyladan commented Jul 5, 2022

This is not stale. Tagging component owners @willarmiros @NathanielRN

@dyladan dyladan added the enhancement New feature or request label Jul 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Sep 5, 2022
@cartermp
Copy link

cartermp commented Sep 5, 2022

Still not stale. Happy to contribute a fix myself, just unsure where I'd access the kind of information that we should be attaching to the created span.

@willarmiros
Copy link
Contributor

willarmiros commented Sep 6, 2022

Hi @cartermp,

It seems these additional attributes for APIGW-invoked Lambdas would have to be added in the Lambda instrumentation around here:

You would need to parse the event used to invoke the Lambda to determine if it is an APIGW event, then record the desired parameters if so.

@NPellet
Copy link
Contributor

NPellet commented Nov 17, 2022

@willarmiros

In case the lambda is triggered from the Gateway API, should the span status be set to Status.Error if the lambda is returning a statusCode != 2XX ? (See https://docs.aws.amazon.com/apigateway/latest/developerguide/handle-errors-in-lambda-integration.html)

We have Sentry that's catching our thrown exceptions and returning a proper 500, but in that case, the lambda itself doesn't really fail, hence the span is not errored, while we receive a Sentry alert.

Just wondering

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Mar 6, 2023
@willarmiros
Copy link
Contributor

Hi @NPellet - sorry for the delayed response I must have missed this. Yeah I think based on those docs we are only handling the "standard error" case, but not the "custom error" case. IMO if the customer is creating a custom error as described in those docs and we can read the HTTP Status code of that custom error, then it is clear that the customer intent is to mark that request as failed and we should update the span status to Error.

Also commenting to remove stale.

@willarmiros
Copy link
Contributor

@dyladan can we make this a never-stale?

@github-actions github-actions bot removed the stale label Mar 13, 2023
@github-actions
Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Jun 12, 2023
@blytheaw
Copy link

We are definitely interested in this feature, especially since API Gateway v2 (HTTP API) isn't supported by AWS X-ray and many other third party providers. Having that as the root span would be immensely helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants