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

Clarifying behavior of env, service, and version when extension_layer_version is not provided (ie because lambda docker image is used) #320

Open
pviolette3 opened this issue Nov 1, 2024 · 2 comments
Assignees

Comments

@pviolette3
Copy link

Expected Behavior

Given below code, with lambda_handlers running Docker images,

    datadog = Datadog(
        stack,
        "Datadog",
        add_layers=False,  # Extension provided in Dockerfiles. We don't add layers here.
        # NOTE: Extension layer is NOT used however we do need it to add the tags we're specifying in the construct.
        # https://github.com/DataDog/datadog-cdk-constructs/blob/main/src/env.ts#L127
        **extension_layer_version=None,**
        api_key_secret=datadog_api_key,
        site="datadoghq.com",
        enable_datadog_logs=True,
        enable_datadog_tracing=True,
        enable_merge_xray_traces=True,
        inject_log_context=True,
        log_level="debug",
        capture_lambda_payload=True,
        env=stage_name,
        service=stack.stack_name,
        version=version,
    )
    datadog.add_lambda_functions(lambda_handlers)

the env, service, and version should correspond to the DD_ENV, DD_SERVICE, and DD_VERSION environment variables added to the lambda handlers.

It does seem that passing a dummy extension_layer_version=65 does add them again.

Actual Behavior

DD_SERVICE, DD_ENV, and DD_VERSION the variables seem not to get added if you don't pass extension_layer_version, and these are typically how one may find the relevant traces.

Noted here in the code that the constructs do not add these variables if the extension layer is unspecified: https://github.com/DataDog/datadog-cdk-constructs/blob/main/src/env.ts#L127-L140

It seems this may be intended behavior, but I am not sure why.

#185 seems related.

Steps to Reproduce the Problem

  1. Create a DockerImage lambda function which includes the datadog extension already.
  2. Create Datadog construct with no extension_layer_version.
  3. Deploy and note whether or not DD_SERVICE, DD_ENV, and DD_VERSION are set.

NOTE: Traces are showing up fine. It's just that the 3 common fields I'd search for in APM Traces are not tagged (ie searching by service, env, or version) so it appears as if it doesn't work.

Specifications

  • Datadog Lambda Layer version: 65 (installing via COPY --from=public.ecr.aws/datadog/lambda-extension:65 /opt/. /opt/ based on public.ecr.aws/lambda/python:3.10
    )
  • Node version: v20.12.0 (CDK)

datadog-cdk-constructs-v2==1.18.0

Stacktrace

There is no crash; this behavior may be WAI.

Would anyone be able to share?

BTW - thank you Datadog team for a great product. It is so useful :)

@lym953
Copy link
Contributor

lym953 commented Nov 5, 2024

Thanks for reporting! I think DD_SERVICE, DD_ENV, and DD_VERSION should be set in this case. I'm going to track this issue internally. For now, you can set a dummy extension_layer_version to have the environment variables set.

@lym953
Copy link
Contributor

lym953 commented Nov 5, 2024

Internal ticket: https://datadoghq.atlassian.net/browse/SVLS-5931

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

No branches or pull requests

2 participants