You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bb-tracer / bb-logger: annotations and trace ids look valid locally, but on AWS NaN, Infinity and objects are dropped and log entries carry a traceId the local logger never writes #1281
I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Which package(s) are affected?
Other (@aws-blocks/bb-tracer, @aws-blocks/bb-logger)
Describe the bug
Tracer annotations.segment.addAnnotation(key, value) in the mock stores whatever it is given. X-Ray keeps only strings, finite numbers and booleans, so on AWS some annotations silently disappear:
Value
Local
Deployed
1.5, true, a 1,000- or 1,001-character string, null
kept
kept
NaN, Infinity (both type-check as number)
kept as numbers
dropped
an object
kept
dropped
A dashboard or trace filter built on an annotation that is sometimes NaN (for example a computed ratio) works locally and has gaps on AWS.
Trace ids.tracer.getTraceId() returns a random UUID locally and an X-Ray id (1-<8 hex>-<24 hex>) deployed, so code that parses or validates the id, or builds a console link from it, works only on one side.
Logger. On AWS every structured log entry has a traceId field (from _X_AMZN_TRACE_ID); locally the field is absent from every entry, even when the local tracer has an active trace. Log processing that keys on traceId (correlation, grouping) can't be tested locally.
Expected behavior
The mock tracer applies X-Ray's annotation rules: drops (and ideally warns about) non-finite numbers and non-primitive values. The AnnotationValue type could also exclude objects.
The mock tracer generates ids in the X-Ray format.
The local logger adds traceId from the mock tracer's active trace (or a generated X-Ray-format id per request), so entries have the same shape in both environments.
Reproduction steps
consttracer=newTracer(scope,'tracer');constlog=newLogger(scope,'log');exportconstapi=newApiNamespace(scope,'api',()=>({asyncwork(){awaittracer.startSegment('work',async(segment)=>{segment.addAnnotation('ratio',Number.NaN);// kept locally, dropped on AWS});log.info('done');// entry has traceId on AWS onlyreturntracer.getTraceId();// UUID locally, "1-…-…" on AWS},}));
Likely location: addAnnotation() and the randomUUID() trace ids in packages/bb-tracer/src/index.mock.ts (around lines 45, 148, 221 and 247); the traceId field in packages/bb-logger/src/serializer.ts (around lines 109–112, read only from _X_AMZN_TRACE_ID).
Activity