Commit b86a291
authored
OTEL: Update Operation Name to Match Frontend Usage (#1033)
## Overview
OTEL Lambda spans emitted by the
`opentelemetry.instrumentation.aws_lambda` Python instrumentation come
through the Extension with `name: server.request` — the OTEL
semantic-convention generic-server fallback. The Datadog Serverless page
invocation table filters by:
```
operation_name:("aws.lambda" OR "aws.lambda.function"
OR "opentelemetry_instrumentation_aws_lambda.server"
OR "opentelemetry.instrumentation.aws_lambda.server")
```
`server.request` matches none of those, so OTEL Lambda functions show 0
traces on the Serverless page even though the spans land in APM
correctly.
This PR overrides the operation name to `aws.lambda` for OTEL Lambda
root-invocation spans on the Extension side. Detection is gated on the
instrumentation scope being `opentelemetry.instrumentation.aws_lambda`
AND span kind being `Server`, so other spans in the trace (HTTP clients,
internal spans, custom spans) are not touched.
## What Changed
`bottlecap/src/otlp/transform.rs` — `get_otel_operation_name_v2`:
- Threads the OTEL `InstrumentationScope` reference through to the
operation-name resolver
- Adds an early branch: `lib.name ==
"opentelemetry.instrumentation.aws_lambda"` AND `span.kind == Server` →
`"aws.lambda"`
- All other spans continue to resolve via the existing HTTP / DB /
messaging / RPC / FAAS / generic fallback chain
- The `lib` parameter was already available at the call site in
`otel_span_to_dd_span`; the change just plumbs it into
`get_otel_operation_name_v2`
## Why on the Extension (vs. logs-backend)
The complementary path — spans arriving through the OTLP endpoint
without going through the Extension — is handled by
DataDog/logs-backend#134974, which performs the
same `server.request → aws.lambda` override in
`SpansOTLPProtobufPayloadParser` along with the broader OTEL → Datadog
field remap (`cloud.resource_id → function_arn`, `faas.invocation_id →
request_id`, etc.).
Doing the override on the Extension side for the Extension-forwarded
path is preferred because:
1. The override is closer to the source of truth — the Extension is the
only component that knows the span came from the OTEL `aws_lambda`
instrumentation
2. APM stats / error tracking / rule-based sampling all see the same
`aws.lambda` name, avoiding "named differently in different places" bugs
3. Mirrors how the Extension already overrides other OTEL-side fields
with Datadog conventions
## Testing
Existing `test_otel_operation_name_*` extended to assert
`server.request` is still produced when the lib name does **not** match
the AWS Lambda scope (regression coverage for the threading change).
New `test_otel_operation_name_aws_lambda` covers three cases:
1. AWS Lambda scope + `Server` kind → `aws.lambda`
2. AWS Lambda scope + `Internal` kind (handler child spans) → unchanged
(`SPAN_KIND_INTERNAL`)
3. Different scope (e.g., `handler`) + `Server` kind → unchanged
(`server.request`)
## Companion PRs
- **logs-backend**
[#134974](DataDog/logs-backend#134974) — same
operation-name override for the OTLP-endpoint path, plus the OTEL →
Datadog field remap
- **web-ui** [#300855](DataDog/web-ui#300855) —
defensive `request_id` fallback in the trace list hook + widened log
queries that match OTLP-ingested logs alongside Datadog Forwarder logs
Together with this PR, OTEL-instrumented AWS Lambda functions (both
endpoint-only and Extension-forwarded) work end-to-end on the Datadog
Serverless page: trace discovery, invocation correlation, function-level
log discovery, error filter, log count.1 parent 47d70b3 commit b86a291
1 file changed
Lines changed: 66 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| |||
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
254 | | - | |
| 257 | + | |
255 | 258 | | |
256 | 259 | | |
257 | 260 | | |
| |||
261 | 264 | | |
262 | 265 | | |
263 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
264 | 278 | | |
265 | 279 | | |
266 | 280 | | |
| |||
894 | 908 | | |
895 | 909 | | |
896 | 910 | | |
897 | | - | |
| 911 | + | |
898 | 912 | | |
899 | 913 | | |
900 | 914 | | |
| |||
1325 | 1339 | | |
1326 | 1340 | | |
1327 | 1341 | | |
1328 | | - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
1329 | 1392 | | |
1330 | 1393 | | |
0 commit comments