Skip to content

Commit 3f22432

Browse files
committed
Expose profiling config in interface
1 parent bba4df0 commit 3f22432

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/ecs/fargate/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ For more general information, reference the [Datadog ECS Fargate Docs](https://d
184184
| `isEnabled` | `boolean` | Enables APM. |
185185
| `isSocketEnabled` | `boolean` | Enables APM traces traffic over Unix Domain Socket. Falls back to TCP when false. |
186186
| `traceInferredProxyServices` | `boolean` | Enables inferred spans for proxy services like AWS API Gateway. When enabled, the tracer will create spans for proxy services by using headers passed from the proxy service to the application. |
187+
| `isProfilingEnabled` | `boolean` | Enables Profiling. (Requires APM SSI on application containers) |
187188

188189
### CWSFeatureConfig
189190

src/ecs/fargate/datadog-ecs-fargate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ export class DatadogECSFargateTaskDefinition extends ecs.FargateTaskDefinition {
218218
});
219219
}
220220

221+
if (this.datadogProps.apm!.isEnabled) {
222+
if (this.datadogProps.apm!.isProfilingEnabled) {
223+
container.addEnvironment("DD_PROFILING_ENABLED", "true");
224+
}
225+
}
226+
221227
// Universal Service Tagging configuration:
222228
if (this.datadogProps.env) {
223229
container.addEnvironment("DD_ENV", this.datadogProps.env);

src/ecs/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ export interface APMFeatureConfig {
157157
* passed from the proxy service to the application.
158158
*/
159159
readonly traceInferredProxyServices?: boolean;
160+
/**
161+
* Enables Profile collection.
162+
* Requires Datadog APM SSI instrumentation on your application containers.
163+
*/
164+
readonly isProfilingEnabled?: boolean;
160165
}
161166

162167
/**

test/ecs/fargate/apm-dsd.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,38 @@ describe("DatadogECSFargateTaskDefinition", () => {
169169
});
170170
});
171171

172+
it("should inject DD_PROFILING_ENABLED when profiling is enabled", () => {
173+
datadogProps = {
174+
...datadogProps,
175+
apm: {
176+
isEnabled: true,
177+
isProfilingEnabled: true,
178+
},
179+
};
180+
const taskDefinition = new ecsDatadog.DatadogECSFargateTaskDefinition(scope, id, props, datadogProps);
181+
taskDefinition.addContainer("app-container", {
182+
containerName: "app-container",
183+
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
184+
memoryLimitMiB: 512,
185+
});
186+
const template = Template.fromStack(stack);
187+
188+
// Validate that the ports are configured on the datadog-agent container
189+
template.hasResourceProperties("AWS::ECS::TaskDefinition", {
190+
ContainerDefinitions: Match.arrayWith([
191+
Match.objectLike({
192+
Name: "app-container",
193+
Environment: Match.arrayWith([
194+
Match.objectLike({
195+
Name: "DD_PROFILING_ENABLED",
196+
Value: "true",
197+
}),
198+
]),
199+
}),
200+
]),
201+
});
202+
});
203+
172204
it("should enable origin detection when isOriginDetectionEnabled is true", () => {
173205
datadogProps = {
174206
...datadogProps,

0 commit comments

Comments
 (0)