Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mq] working branch - merge d78bde2 on top of main at da42521
Browse files Browse the repository at this point in the history
{"baseBranch":"main","baseCommit":"da425210ee811ae537488b020c67498d19703ee0","createdAt":"2024-12-05T20:08:17.195679Z","headSha":"d78bde2eb009aa7b32d45416b11d7af8905d6016","id":"0c142435-bdb6-4c7e-a3c1-90920255666c","priority":"200","pullRequestNumber":"344","queuedAt":"2024-12-05T20:20:26.523946Z","status":"STATUS_QUEUED"}
dd-mergequeue[bot] authored Dec 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 4a64110 + d78bde2 commit 4595169
Showing 2 changed files with 38 additions and 43 deletions.
15 changes: 6 additions & 9 deletions src/datadog-lambda.ts
Original file line number Diff line number Diff line change
@@ -130,11 +130,10 @@ export class DatadogLambda extends Construct {

addCdkConstructVersionTag(lambdaFunction);
applyEnvVariables(lambdaFunction, baseProps);
setDDEnvVariables(lambdaFunction, this.props);
setTagsForFunction(lambdaFunction, this.props);
}

setDDEnvVariables(extractedLambdaFunctions, this.props);
setTagsForFunctions(extractedLambdaFunctions, this.props);

this.transport.applyEnvVars(extractedLambdaFunctions);

if (baseProps.sourceCodeIntegration) {
@@ -177,12 +176,10 @@ export function addCdkConstructVersionTag(lambdaFunction: lambda.Function): void
});
}

function setTagsForFunctions(lambdaFunctions: lambda.Function[], props: DatadogLambdaProps): void {
lambdaFunctions.forEach((lambdaFunction) => {
if (props.forwarderArn) {
setTags(lambdaFunction, props);
}
});
function setTagsForFunction(lambdaFunction: lambda.Function, props: DatadogLambdaProps): void {
if (props.forwarderArn) {
setTags(lambdaFunction, props);
}
}

function grantReadLambda(secret: ISecret, lambdaFunction: lambda.Function): void {
66 changes: 32 additions & 34 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -120,42 +120,40 @@ export function applyEnvVariables(lam: lambda.Function, baseProps: DatadogLambda
}
}

export function setDDEnvVariables(lambdas: lambda.Function[], props: DatadogLambdaProps): void {
lambdas.forEach((lam) => {
if (props.extensionLayerVersion) {
if (props.env) {
lam.addEnvironment(DD_ENV_ENV_VAR, props.env);
}
if (props.service) {
lam.addEnvironment(DD_SERVICE_ENV_VAR, props.service);
}
if (props.version) {
lam.addEnvironment(DD_VERSION_ENV_VAR, props.version);
}
if (props.tags) {
lam.addEnvironment(DD_TAGS, props.tags);
}
}
if (props.enableColdStartTracing !== undefined) {
lam.addEnvironment(DD_COLD_START_TRACING, props.enableColdStartTracing.toString().toLowerCase());
}
if (props.minColdStartTraceDuration !== undefined) {
lam.addEnvironment(DD_MIN_COLD_START_DURATION, props.minColdStartTraceDuration.toString().toLowerCase());
}
if (props.coldStartTraceSkipLibs !== undefined) {
lam.addEnvironment(DD_COLD_START_TRACE_SKIP_LIB, props.coldStartTraceSkipLibs);
export function setDDEnvVariables(lam: lambda.Function, props: DatadogLambdaProps): void {
if (props.extensionLayerVersion) {
if (props.env) {
lam.addEnvironment(DD_ENV_ENV_VAR, props.env);
}
if (props.enableProfiling !== undefined) {
lam.addEnvironment(DD_PROFILING_ENABLED, props.enableProfiling.toString().toLowerCase());
if (props.service) {
lam.addEnvironment(DD_SERVICE_ENV_VAR, props.service);
}
if (props.encodeAuthorizerContext !== undefined) {
lam.addEnvironment(DD_ENCODE_AUTHORIZER_CONTEXT, props.encodeAuthorizerContext.toString().toLowerCase());
if (props.version) {
lam.addEnvironment(DD_VERSION_ENV_VAR, props.version);
}
if (props.decodeAuthorizerContext !== undefined) {
lam.addEnvironment(DD_DECODE_AUTHORIZER_CONTEXT, props.decodeAuthorizerContext.toString().toLowerCase());
if (props.tags) {
lam.addEnvironment(DD_TAGS, props.tags);
}
if (props.apmFlushDeadline !== undefined) {
lam.addEnvironment(DD_APM_FLUSH_DEADLINE_MILLISECONDS, props.apmFlushDeadline.toString().toLowerCase());
}
});
}
if (props.enableColdStartTracing !== undefined) {
lam.addEnvironment(DD_COLD_START_TRACING, props.enableColdStartTracing.toString().toLowerCase());
}
if (props.minColdStartTraceDuration !== undefined) {
lam.addEnvironment(DD_MIN_COLD_START_DURATION, props.minColdStartTraceDuration.toString().toLowerCase());
}
if (props.coldStartTraceSkipLibs !== undefined) {
lam.addEnvironment(DD_COLD_START_TRACE_SKIP_LIB, props.coldStartTraceSkipLibs);
}
if (props.enableProfiling !== undefined) {
lam.addEnvironment(DD_PROFILING_ENABLED, props.enableProfiling.toString().toLowerCase());
}
if (props.encodeAuthorizerContext !== undefined) {
lam.addEnvironment(DD_ENCODE_AUTHORIZER_CONTEXT, props.encodeAuthorizerContext.toString().toLowerCase());
}
if (props.decodeAuthorizerContext !== undefined) {
lam.addEnvironment(DD_DECODE_AUTHORIZER_CONTEXT, props.decodeAuthorizerContext.toString().toLowerCase());
}
if (props.apmFlushDeadline !== undefined) {
lam.addEnvironment(DD_APM_FLUSH_DEADLINE_MILLISECONDS, props.apmFlushDeadline.toString().toLowerCase());
}
}

0 comments on commit 4595169

Please sign in to comment.