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

Change state machine tag key from DD_XYZ to xyz #553

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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" },
],
},
Expand Down Expand Up @@ -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" },
]),
);
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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,
});
}
Expand Down
Loading