- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
",t};e.buildCustomizationMenuUi=t;function n(e){let t='
",t}function s(e){let n=e.filter.currentValue||e.filter.defaultValue,t='${e.filter.label}
`,e.filter.options.forEach(s=>{let o=s.id===n;t+=``}),t+="${e.filter.label}
`,t+=`This feature is in Preview.
Datadog APM can create synthetic root spans for requests that pass through Amazon API Gateway to container- or EC2-hosted services. The spans power end-to-end traces, service maps, and sampling based on the gateway itself.
Amazon API Gateway is deployed as a REST API (v1) or HTTP API (v2).
Note: If using HTTP API (v2), context.requestTimeEpoch
provides second-level granularity, unlike REST APIs (v1) which provide millisecond precision. This means span duration is approximate.
DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED
is set in the application container:
export DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=true
Or enable it through the Datadog ECS Fargate CDK construct:
new DatadogECSFargate(this, 'Datadog', {
apm: { isEnabled: true, traceInferredProxyServices: true },
});
Your underlying application is running a supported web framework.
Your application tracer meets the minimum version.
Runtime | Datadog Tracer | Tracer version | Frameworks |
---|---|---|---|
Node.js | dd-trace-js | v4.50.0+ or v5.26.0+ | express, fastify, hapi, koa, microgateway-core, next, paperplane, restify, router, apollo |
Go | dd-trace-go | v1.72.1+ | chi, httptreemux, echo, go-restful, fiber, gin, gorilla mux, httprouter, fasthttp, goji |
Python | dd-trace-py | v3.1.0+ | aiohttp, asgi, bottle, cherrypy, django, djangorestframework, falcon, fastapi, flask, molten, pyramid, sanic, starlette, tornado, wsgi |
To create inferred spans, API Gateway must pass the following headers to your backend services:
Header | Value |
---|---|
x-dd-proxy | 'aws-apigateway' Note: Single quotes must be included. |
x-dd-proxy-request-time-ms | context.requestTimeEpoch |
x-dd-proxy-domain-name | context.domainName |
x-dd-proxy-httpmethod | context.httpMethod |
x-dd-proxy-path | context.path |
x-dd-proxy-stage | context.stage |
To pass in the required headers, you can use the AWS CDK or AWS Console:
Add the headers under requestParameters
and use $context
variables:
import { DatadogAPIGatewayRequestParameters } from "datadog-cdk-constructs-v2";
// Datadog integration definition
const ddIntegration = new apigateway.Integration({
type: apigateway.IntegrationType.HTTP_PROXY,
integrationHttpMethod: "ANY",
options: {
connectionType: apigateway.ConnectionType.INTERNET,
requestParameters: DatadogAPIGatewayRequestParameters,
},
uri: `http://${loadBalancer.loadBalancerDnsName}`,
});
const api = new apigateway.RestApi(this, "MyApi", {
restApiName: "my-api-gateway",
deployOptions: { stageName: "prod" },
defaultIntegration: ddIntegration, // Datadog instrumentation applied here
});
In the AWS Management Console, navigate to API Gateway and go to your API’s Resources page.
Go to Integration request and click Edit.
Under Edit integration request, go to URL request headers parameters. Click Add request header parameter.
To create inferred spans, API Gateway must pass the following headers to your backend services:
Header | Value |
---|---|
x-dd-proxy | aws-apigateway |
x-dd-proxy-request-time-ms | ${context.requestTimeEpoch}000 |
x-dd-proxy-domain-name | $context.domainName |
x-dd-proxy-httpmethod | $context.httpMethod |
x-dd-proxy-path | $context.path |
x-dd-proxy-stage | $context.stage |
Note: context.requestTimeEpoch
returns a timestamp in seconds in v2 APIs. Datadog expects milliseconds, so you must multiply it by 1000 by appending 000
.
Attach the parameter mapping that injects the headers:
import { DatadogAPIGatewayV2ParameterMapping }
from 'datadog-cdk-constructs-v2';
const ddIntegration = new apigatewayv2_integrations.HttpUrlIntegration(
'HttpUrlIntegration',
'https://example.com',
{ parameterMapping: DatadogAPIGatewayV2ParameterMapping },
);
new apigatewayv2.HttpApi(this, 'HttpApi', {
apiName: 'my-http-api',
routes: [{
path: '/{proxy+}',
methods: [apigatewayv2.HttpMethod.ANY],
integration: ddIntegration,
}],
});
Head-based sampling still applies when using API Gateway tracing. Because the synthetic span becomes the new trace root, update your rules so the service value matches the API Gateway service name shown in Datadog.
For example, if the original sampling rule is:
# before: sampled upstream service
DD_TRACE_SAMPLING_RULES='[{"service":"pythonapp","sample_rate":0.5}]'
Update the rule in one of the following ways:
Change the service
value to match your API Gateway’s name as it appears in Datadog:
# option 1: sample the gateway root span
DD_TRACE_SAMPLING_RULES='[{"service":"my-api-gateway","sample_rate":0.5}]'
Remove the service
key to apply the rule to all root spans:
# option 2: apply to all roots
DD_TRACE_SAMPLING_RULES='[{"sample_rate":0.5}]'