Skip to content

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

Open
@garysassano

Description

@garysassano

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions