.agents/skills/serverless-integrations/references/architecture.md
Serverless APM is a thin, platform-aware layer over the normal dd-trace-js tracer and plugin system. The main difference is ownership: a serverless platform integration owns the function invocation as the root operation, while ordinary APM integrations create child spans for library calls that happen during that invocation.
The normal dd-trace-js path is:
The serverless root path adds stricter lifecycle constraints:
Ask "what owns the unit of work?"
AWS Lambda is currently special-cased in packages/dd-trace/src/lambda/. It resolves DD_LAMBDA_HANDLER when
available, otherwise hooks datadog-lambda-js, then wraps the handler to manage timeout protection and crash flush.
Treat this as legacy/runtime bootstrap behavior rather than the template for ordinary integrations.
Azure Functions is closer to the preferred plugin model. packages/datadog-plugin-azure-functions extends
TracingPlugin, declares kind = 'server' and type = 'serverless', handles HTTP and non-HTTP triggers, and uses
web helpers for inferred proxy behavior.
Serverless detection and configuration live primarily in:
packages/dd-trace/src/serverless.jspackages/dd-trace/src/config/index.jspackages/dd-trace/src/service-naming/schemas/*/serverless.jsImportant effects include serverless service-name fallback, immediate flush behavior when no mini-agent ready file is available, and reduced startup work in code paths that must stay cheap during cold start.