Effect CommunityEC
Effect Community5mo ago
1 reply
Gabriel

Effect Tracing with Datadog inside AWS Lambda

I try to get spans created by Effect.withSpan to Datadog inside a Lambda Function using their Lambda Extension.

I use the AWS CDK and datadog-cdk-constructs-v2 with this configuration:
    const monitoring = new DatadogLambda(this, "Datadog", {
      nodeLayerVersion: 127,
      extensionLayerVersion: 84,

      site: "datadoghq.eu",
      apiKeySecret,

      env: props.stage,
      service: props.serviceName,

      captureCloudServicePayload: true,
      captureLambdaPayload: true,
    })
    const apiFunction = new ln.NodejsFunction(this, "ApiFunction", {
      entry: "api.ts",
      environment: {
        DD_TRACE_OTEL_ENABLED: "true",
        DD_TRACE_DEBUG: "true",
      },
      runtime: lambda.Runtime.NODEJS_22_X,
      architecture: lambda.Architecture.ARM_64,
      logGroup: new logs.LogGroup(this, "LogGroup", {
        retention: logs.RetentionDays.THREE_DAYS,
      }),
      timeout: cdk.Duration.minutes(1),
      memorySize: 512,
    })
    props.monitoring.addLambdaFunctions([apiFunction])


I use @effect-aws/lambda to build my handler and I provide the following layer
const TelemetryLayer = Tracer.layerGlobal.pipe(
  Layer.provide(
    Layer.effect(
      Resource.Resource,
      Effect.gen(function* () {
        return Resources.resourceFromAttributes(
          Resource.configToAttributes({
            serviceName: yield* Config.string("DD_SERVICE"),
          }),
        )
      }),
    ),
  ),
)


The trace is in Datadog but my custom spans are missing.

One issue I can think of is a version mismatch between dd-trace-js that requires @opentelemetry/api@<1.9.0 and @effect/opentelemetry that requires @opentelemetry/api@>=1.9.0.

Does anyone have any experience with this setup?
GitHub
Datadog APM client for Node.js. Contribute to DataDog/dd-trace-js development by creating an account on GitHub.
GitHub - DataDog/dd-trace-js: Datadog APM client for Node.js
Was this page helpful?