Skip to content

Commit 8cb759d

Browse files
committed
fix(native-spans): let an explicit agent exporter win in a Lambda
The Lambda no-local-agent probe selected the stdout exporter whenever neither the extension layer nor the mini agent was present, without looking at what the user had configured. `getExporter` on master matched the configured name in a switch and returned before it ever reached that probe, so `exporter: 'agent'` in a Lambda kept using the agent. Restoring that precedence fixes suites that set both `DD_TRACE_EXPERIMENTAL_EXPORTER=agent` and `AWS_LAMBDA_FUNCTION_NAME` and then wait for traces at the test agent: their spans were being written to stdout instead, so every assertion timed out. The fetch plugin's "in serverless" block went from four 25s timeouts to passing, and the whole suite from 4m to 2s.
1 parent 0d5b587 commit 8cb759d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/dd-trace/src/opentracing/tracer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ class DatadogTracer {
9292
// instead. Probe for both markers exactly as the pre-native-spans exporter
9393
// selection did, otherwise these functions POST every span to a loopback port
9494
// nothing listens on (config forces flushInterval=0 there) and lose all traces.
95+
//
96+
// An explicit `exporter: 'agent'` still wins: master's `getExporter` matched
97+
// the configured name in a switch and returned before it ever reached this
98+
// probe, so a Lambda told to use the agent must use the agent.
99+
//
95100
// Kept independent of `useLambdaJsPipeline` (which excludes OTLP) so the
96101
// missing-libdatadog degrade path below can reuse it.
97102
const lambdaWithoutLocalAgent = getIsAWSLambda() &&
103+
configuredExporter !== exporters.AGENT &&
98104
!fs.existsSync(DATADOG_LAMBDA_EXTENSION_PATH) &&
99105
!fs.existsSync(DATADOG_MINI_AGENT_PATH)
100106
const useLambdaLogExporter = useLambdaJsPipeline && lambdaWithoutLocalAgent

0 commit comments

Comments
 (0)