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

Automatically set faas.trigger attribute with @opentelemetry/instrumentation-aws-lambda #2570

Open
garysassano opened this issue Nov 30, 2024 · 2 comments

Comments

@garysassano
Copy link

garysassano commented Nov 30, 2024

Summary

Developers authoring AWS Lambda functions in TypeScript often rely on the @types/aws-lambda module to define the handler type or event source triggering the function. This information could serve as a valuable hint to automatically set the faas.trigger attribute and other related attributes in OpenTelemetry.

Proposal

By inspecting the handler or event type, the instrumentation can infer the faas.trigger attribute and enrich telemetry data accordingly.

Examples

  • API Gateway (REST)

    • Handler: ApiGatewayProxyHandler
    • Event: ApiGatewayProxyEvent
      • faas.triggerhttp
  • API Gateway (HTTP API v2)

    • Handler: ApiGatewayProxyHandlerV2
    • Event: ApiGatewayProxyEventV2
      • faas.triggerhttp
  • EventBridge Scheduler (or Rules)

    • Handler: ScheduledHandler
    • Event: ScheduledEvent
      • faas.triggertimer
  • SQS

    • Handler: SQSHandler
    • Event: SQSEvent
      • faas.triggerpubsub
      • messaging.systemaws_sqs
      • messaging.operationprocess
  • S3

    • Handler: S3Handler
    • Event: S3Event
      • faas.triggerdatasource

Additional S3 Context

If the event includes an S3EventRecord, additional attributes could be derived:

  • faas.document.collectionBucket Name (e.g., myBucketName)
  • faas.document.operationOperation Type (e.g., insert)
  • faas.document.nameFile Name (e.g., myFile.txt)
  • faas.document.timeEvent Time (e.g., 2020-01-23T13:47:06Z)

Benefits

Automatically setting these attributes improves traceability and observability, reducing the burden on developers to manually add this information while adhering to OpenTelemetry semantic conventions.

@pichlermarc pichlermarc transferred this issue from open-telemetry/opentelemetry-js Dec 1, 2024
@pichlermarc
Copy link
Member

Note: Transferred from the core repo as this is a feature request only concerns @opentelemetry/instrumentation-aws-lambda.

This feature-request is pending approval/rejection by @jj22ee (component owner)

@jj22ee
Copy link
Contributor

jj22ee commented Dec 9, 2024

TypeScript often rely on the @types/aws-lambda module to define the handler type or event source triggering the function.

By inspecting the handler or event type, the instrumentation can infer the faas.trigger attribute and enrich telemetry data accordingly.

The @types/aws-lambda package is a DefinitelyTyped package, it only provides types/interfaces to help with development in your IDE. The actual generated JS code cannot change logic based on such types from TypeScript.

This is one of the reasons why this related PR (#2404) adds attributes for APIGW events based on what exactly is in an event, rather than checking the TypeScript types/interfaces of the handler/event (not possible).

I suppose the proposal needs to be modified so that each event source is differentiated based on the values in the event.

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

3 participants