From e95e03d812c843cee41335a27090b40a31d06205 Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 7 Nov 2024 14:36:34 -0500 Subject: [PATCH] Change state machine tag key from DD_XYZ to xyz --- src/index.spec.ts | 22 +++++++++++----------- src/index.ts | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/index.spec.ts b/src/index.spec.ts index 57d1bd46..5377a6c1 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1872,7 +1872,7 @@ describe("ServerlessPlugin", () => { ); }); - it("sets DD tags for the state machine", async () => { + it("sets tags for the state machine", async () => { const serverless = { cli: { log: () => {} }, getProvider: (_name: string) => awsMock(), @@ -1912,15 +1912,15 @@ describe("ServerlessPlugin", () => { ).toHaveProperty( "Tags", expect.arrayContaining([ - { Key: "DD_ENV", Value: "prod" }, - { Key: "DD_SERVICE", Value: "my-service" }, - { Key: "DD_VERSION", Value: "1.0.0" }, + { Key: "env", Value: "prod" }, + { Key: "service", Value: "my-service" }, + { Key: "version", Value: "1.0.0" }, { Key: "dd-custom-tag", Value: "custom-tag-value" }, ]), ); }); - it("does not override existing DD tags on the state machine", async () => { + it("does not override existing tags on the state machine", async () => { const serverless = { cli: { log: () => {} }, getProvider: (_name: string) => awsMock(), @@ -1934,9 +1934,9 @@ describe("ServerlessPlugin", () => { Type: "AWS::StepFunctions::StateMachine", Properties: { Tags: [ - { Key: "DD_ENV", Value: "dev" }, - { Key: "DD_SERVICE", Value: "my-existing-service" }, - { Key: "DD_VERSION", Value: "0.0.9" }, + { Key: "env", Value: "dev" }, + { Key: "service", Value: "my-existing-service" }, + { Key: "version", Value: "0.0.9" }, { Key: "dd-custom-tag", Value: "existing-tag-value" }, ], }, @@ -1967,9 +1967,9 @@ describe("ServerlessPlugin", () => { ).toHaveProperty( "Tags", expect.arrayContaining([ - { Key: "DD_ENV", Value: "dev" }, - { Key: "DD_SERVICE", Value: "my-existing-service" }, - { Key: "DD_VERSION", Value: "0.0.9" }, + { Key: "env", Value: "dev" }, + { Key: "service", Value: "my-existing-service" }, + { Key: "version", Value: "0.0.9" }, { Key: "dd-custom-tag", Value: "existing-tag-value" }, ]), ); diff --git a/src/index.ts b/src/index.ts index cd719101..369c8344 100644 --- a/src/index.ts +++ b/src/index.ts @@ -176,7 +176,7 @@ module.exports = class ServerlessPlugin { } addDdSlsPluginTag(stateMachineObj); // obj is a state machine object addDdTraceEnabledTag(stateMachineObj, config.enableStepFunctionsTracing); - this.addDDTagsForStateMachine(stateMachineObj); + this.addTagsForStateMachine(stateMachineObj); } } } @@ -464,9 +464,9 @@ module.exports = class ServerlessPlugin { /** * Check for service, env, version, and additional tags at the custom level. - * If these don't already exsist on the state machine level, add them as DD_XXX tags. + * If these don't already exist on the state machine level, add them. */ - private addDDTagsForStateMachine(stateMachine: any): void { + private addTagsForStateMachine(stateMachine: any): void { const service = this.serverless.service as Service; const datadog = service.custom?.datadog; @@ -480,21 +480,21 @@ module.exports = class ServerlessPlugin { if (datadog.service && !tags.hasOwnProperty(TagKeys.Service)) { tags.push({ - Key: ddServiceEnvVar, + Key: TagKeys.Service, Value: datadog.service, }); } if (datadog.env && !tags.hasOwnProperty(TagKeys.Env)) { tags.push({ - Key: ddEnvEnvVar, + Key: TagKeys.Env, Value: datadog.env, }); } if (datadog.version && !tags.hasOwnProperty(TagKeys.Version)) { tags.push({ - Key: ddVersionEnvVar, + Key: TagKeys.Version, Value: datadog.version, }); }