# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.3] - 2026-11-10

PLAT-1362.

### Fixed
- **4xx errors marked HTTP server spans as ERROR**: `recordSpanException()` (used by the Express, Fastify and lambda-api error handlers) always set span status ERROR, even when the error mapped to a 4xx. A Fastify schema validation failure (`FST_ERR_VALIDATION` → 400) therefore produced an ERROR span for a correct 400 (clickstream-api: 329 such spans). This contradicted the SDK's own `setSpanHttpStatus()` and the OTel HTTP semconv for SERVER spans.
  - **Fix**: status ERROR is now set only for 5xx; a missing or invalid status code is treated as 500. For 4xx the status stays UNSET, and `http.response.status_code`, `error.type` and the exception event are still recorded.
  - Express and lambda-api error handlers pass the error on (`next(err)`) and the app picks the response status, so they no longer set the span status themselves: the response hook sets it from the status actually sent. An error without a status that the app answers with 400 no longer leaves an ERROR span. An Express error raised after headers were sent still sets ERROR, whatever its status code (the response is cut off).
  - Error-rate dashboards or alerts built on span status ERROR will drop these client errors; filter on `http.response.status_code` to count them. This includes unhandled upstream-client errors whose `.status` is a 4xx (e.g. an SDK error for a downstream 429) when the server replies with that 4xx: they now show only through `error.type` and the exception event.

## [0.7.2] - 2026-11-06

PLAT-1343.

### Security
- **HTTP server spans exported credentials passed in the query string**: Express and Fastify built `url.full` from the raw request URL, and Express, Fastify and Lambda-API set `url.query` to `JSON.stringify(req.query)`. `lambdaHandler()` on API Gateway events put the raw query into `url.query`, `url.full`, `http.target` and `http.url`. A request such as `GET /v1/links?apikey=...` therefore sent the API key to Coralogix. `SENSITIVE_FIELD_NAMES` (which already lists `apikey`) applied to request bodies only.
  - **Fix**: new `redactUrl(url)` and `redactQuery(objectOrString)` in `httpMiddlewareUtils`, applied in all four places.
    - A **sensitive name** keeps its name and its value becomes `[REDACTED]`. Names are fully percent-decoded (so double-encoded `c%256Fde` matches) and split on every character other than letters, digits, `_`, `.`, `-`. A name is sensitive if any segment contains a `SENSITIVE_FIELD_NAMES` entry (substring, as for bodies) or `passphrase`, `credential`, `cookie`, `hmac`, `bearer`; equals `auth`, `code`, `session`, `sessionid`, `sid`, `pass` or `otp`; or ends in `key`, `sig`, `signature`, `jwt`, `pass` or `otp`, after `.` `_` `-` or in camelCase (`private_key`, `x-hub-signature`, `db_pass`, `privateKey`, `userPass`; not `monkey`, `compass`).
    - **Every other value is checked as a whole** and becomes `[REDACTED]` if, fully decoded (up to 10 levels, tolerating malformed `%`), it contains a sensitive name followed by `=` or `:` after any punctuation, optionally with quotes, backslashes or closing brackets in between (`next=%2Fdone%3Ftoken%3Dabc`, `(sid=1)`, `{"token":"abc"}`, escaped `{\"token\":\"abc\"}`, `token:abc`), or `bearer` followed by a token. A name hiding an encoded `=` (`token%3Dabc`) is replaced too. A run of `=` at the very end of a value is base64 padding, so padded values are unchanged. Values longer than 4096 characters (checked before decoding), or still decoding after 10 levels, become `[REDACTED]`. Values without credentials are exported byte for byte.
    - Known limits: over-redaction of values with short substrings (`cvc`, `ssn`) or generic names (`{"code":200}`) in an assignment; a bare token not attached to a sensitive name, and `user:pass@` inside a value, are not inspected. **Body redaction is unchanged in 0.7.2**: it still uses only the `SENSITIVE_FIELD_NAMES` substring rule, so URL and body sensitivity differ until a follow-up aligns them.
    - Also handles relative URLs, repeated params and `user:pass@` userinfo (to the last `@`). Never throws; a URL it cannot process loses its query instead.
  - **Fragments are dropped** from `url.full` (servers never receive one), and `stripQueryParams()` / `url.path` now cut at `#` as well as `?`.
  - Other parameters, the path and the attribute shapes are unchanged. Handlers still receive the real values.
  - Request headers were already safe: `http.request.headers` captures only the `IMPORTANT_HEADERS` allow-list, which excludes `authorization`, `cookie`, `x-api-key` and `apikey`. A test now locks that in.

## [0.7.1] - 2026-10-23

### Security
- **Redis spans could export command arguments, including user content and values**: the redis and ioredis instrumentations were registered with upstream's default `db.query.text` serializer (`@opentelemetry/redis-common`), which keeps **every** argument of EVAL/EVALSHA, GET, DEL, INCR and similar commands, and the first 1–2 arguments of SET/HSET. Any such command would have put Lua script bodies, script ARGV (user content — e.g. ai-chat passes a conversation title taken from the user's message), lock tokens or values into `db.query.text`, which `LegacyDbAttributesProcessor` copies to `db.statement`, and would have exported them to Coralogix.
  - **Affected**: node-redis (`redis` / `@redis/client`) from **0.2.15** (commit `7a7dee2`, when `RedisInstrumentation` was first registered with the default serializer) through **0.7.0**; ioredis in **0.7.0** (instrumentation added in that release).
  - **Observed impact**: none found. Coralogix spans for 2026-10-20 → 2026-10-23 show no Node service Redis span carrying `db.statement`, no EVAL/EVALSHA spans in any service, and only already-redacted Redis statements from Python services (`GET ?`, `SET ? ? ? ?`). This fix is preventive.
  - **Fix**: both instrumentations now use the SDK's own serializer (`redisDbStatementSerializer.js`). The default emits the **command name only** (`SET k v` → `SET`). Keys are opt-in with `initialize({ redis: { dbStatement: 'keys' } })`, which adds key arguments only for commands whose key positions are known (`EVAL <script> 1 k <argv>` → `EVAL k`) and never emits values, hash fields, script bodies, SHA1s or ARGV. A custom `initialize({ redis: { dbStatementSerializer } })` replaces both; if it throws or returns a non-string, the command name is used.

### Changed
- **Redis `db.query.text` / `db.statement` is now the command name only** by default (was the command plus arguments, e.g. `get probe-key` → `get`). Coralogix queries or alerts that matched on Redis keys in `db.statement` need `redis: { dbStatement: 'keys' }`.
- **`redis` (node-redis v4) is a devDependency**: the suite runs real ioredis and node-redis clients against a fake RESP server in a child process and asserts no value, field, script body or ARGV reaches any exported span attribute or event, in both modes.

## [0.7.0] - 2026-10-22

PLAT-1241. Found while shipping ai-chat (PLAT-1189) on 0.6.2.

### Security
- **Vulnerable OpenTelemetry dependencies upgraded**: `npm audit --omit=dev` on 0.6.2 reported 24 advisories (1 critical, 3 high, 20 moderate) that Dependabot could not fix in consumers because they came through the SDK's own ranges: `@opentelemetry/core` < 2.8.0 (W3C Baggage unbounded allocation) via every 0.203 exporter, `@opentelemetry/propagator-jaeger` < 2.9.0 (DoS) via the legacy `@opentelemetry/node`, `@opentelemetry/instrumentation-mysql`/`-mysql2` < 0.67.0, `protobufjs` (critical) and `@grpc/grpc-js` (high). Now 0 advisories. A CI step fails the build on any new moderate-or-higher advisory in production dependencies.
- **Removed `@opentelemetry/node` 0.24**: never required by the SDK's code; it only pulled in the vulnerable legacy propagators.

### Changed
- **OpenTelemetry JS 2.12 / 0.223 line**: `sdk-*`, `resources`, `core` 2.12.0; exporters, `instrumentation`, `sdk-logs`, `api-logs`, `instrumentation-grpc` 0.223.0; `instrumentation-aws-sdk` 0.78.0, `-redis` 0.71.0, `-mysql` 0.69.1, `-mysql2` 0.69.0. Deliberately **not** the 3.0 / 0.300 line, which requires Node >= 22.15 and would break Lambdas on `nodejs18.x`/`nodejs20.x`.
- **The suite now proves every signal leaves the process**, over gRPC (the default, and what most Lambdas use) and HTTP: a child process exports a log record, a span and a metric point to a local OTLP sink. Moving to sdk-logs 0.223 had silently dropped every log record — its processors take a single options object (`{ exporter }`), and the positional exporter `logs.js` passed was ignored, with the error going only to OpenTelemetry's diag logger. Caught by the layer's wrapper end-to-end tests before release, fixed, and now covered here.
- **`engines.node` declared**: `^18.19.0 || >=20.6.0`, the range of the OpenTelemetry 2.x line (0.6.2 already needed it, undeclared). CI now runs the suite on Node 18, 20, 22 and 24.
- **`@opentelemetry/resources`, `sdk-logs`, `sdk-metrics`, `sdk-trace-base` are declared dependencies**: the code required them but resolved them only through hoisting, so a consumer's tree could hand the SDK a mismatched copy.
- **Database spans use the stable semantic conventions, and keep the legacy keys**: the upgraded redis/mysql/mysql2 instrumentations emit only `db.system.name`, `db.query.text`, `db.namespace`, `server.address`, `server.port`. A new `LegacyDbAttributesProcessor` copies them back onto `db.system`, `db.statement`, `db.name`, `net.peer.name`, `net.peer.port` (never overwriting an existing value; copied at span start and again just before the span ends, for instrumentations that set `server.*` after start), so Coralogix queries and alerts on the legacy keys keep working — e.g. the `APM - Database Stats` dashboard and `RedisSpanProcessor`, which detects Redis spans by `db.system`, keeps setting `db.name`.
- **Legacy database keys with no stable counterpart are gone**: `db.connection_string` (redis, mysql, mysql2) and `db.user` (mysql, mysql2). No Coralogix alert or dashboard reads them (checked 2026-10-22). Without the connection string, `RedisSpanProcessor` can no longer derive the database index for node-redis spans: `db.name` is `redis` instead of `redis-<n>` unless `db.redis.database_index` is present.
- **mysql pool metric renamed upstream**: `db.client.connections.usage` → `db.client.connection.count`.

### Added
- **ioredis instrumentation** (`@opentelemetry/instrumentation-ioredis`): ioredis commands now produce spans. As upstream, only inside an active span (handler, middleware or your own).
- **AWS SDK v3 tracing works again on current clients**: `instrumentation-aws-sdk` 0.58 hooked `@smithy/smithy-client`/`@smithy/middleware-stack`, which current clients (e.g. 3.1146) no longer load — `Client.send` produced no span. 0.78 hooks `@smithy/core`.
- **`lambdaHandler()` wraps `awslambda.streamifyResponse()` handlers**: the wrapper keeps the runtime's streaming marker and `highWaterMark` and calls the handler as `(event, responseStream, context)`. Before, the wrapper dropped the marker (the function stopped streaming) and passed the callback where the context belongs. Layer-wrapped functions also need the layer's own auto-wrap to copy the marker: fixed in rebrandly-otel-nodejs-layer 1.0.10.

### Fixed
- **Histograms honour `advice.explicitBucketBoundaries`**: a wildcard view forced 0.001–5 buckets onto every histogram and overrode the advice, so millisecond or byte histograms had no usable percentiles. The 0.001–5 boundaries are now applied as the default advice, only when the caller passes none — on the SDK meter and on meters from `@opentelemetry/api`. Histograms without advice are unchanged.

## [0.6.2] - 2026-10-08

### Changed
- **`lambdaHandler` completion log is now debug, not info (PLAT-1143)**: `[Rebrandly OTEL] Lambda '<name>' completed in <n>ms, flushing telemetry...` was logged at info on every invocation that flushes, which with the default `flushMinIntervalMs` of 0 is every invocation. On `clickstream-to-s3-driver` it was 10.7M lines/day, about a third of the service's Coralogix log units, and it carries nothing the Lambda span doesn't. The throttled variant was already debug (0.6.0), and `awsMessageHandler`'s completion line was already debug. Set `LOG_LEVEL=debug` to see it again. `Force flush may not have completed fully` (warn) and flush errors are unchanged.

## [0.6.1] - 2026-09-03

### Fixed
- **Expected handler rejections were still logged as service errors (PLAT-992)**: some handlers must reject to signal a perfectly normal outcome — an API Gateway custom authorizer *has* to fail with the literal string `Unauthorized` for API Gateway to return a 401, so every correct denial rejects the handler promise. Such handlers declare the outcome by calling `setSpanSuccess()` before rejecting, and 0.6.0 honoured that for the **span status**. The outer catch, however, still logged `Lambda execution failed` at ERROR severity for *every* rejection, ignoring the verdict the inner catch had already reached one frame earlier.

  Measured on `rb-middleware-account-authorization` in production (2026-09-03, 08:31–09:25 UTC, running 0.6.0): **31** `Lambda execution failed` / `Unauthorized` ERROR logs against **1** genuine failure (an upstream 502), while ERROR spans were correctly down to that same single genuine failure. Roughly 800+ false ERROR logs/day on one service — enough to keep every error-rate alert, dashboard and SLO keyed on *log* severity firing on normal traffic.

  An expected rejection is now logged as `Lambda completed with an expected rejection` at **info**, carrying `function`, `reason`, `trigger` and the trace context. Unexpected rejections keep the exact same `Lambda execution failed` message, fields and ERROR severity.

- **`awsMessageHandler` never had the guard at all**: the span-status fix landed only in `lambdaHandler`. The message wrapper unconditionally called `recordException()` and set ERROR, and logged `Message processing failed` at ERROR, so an SQS/SNS record handler calling `setSpanSuccess()` was reported as failing on both signals. Both wrappers now behave identically; the message wrapper's expected-rejection log is `Message processing completed with an expected rejection` at info.

- **An untaggable rejection hijacked the OTEL-internal fallback path and re-invoked the handler**: the inner catch tagged rejections with `error.__otelHandlerError = true`. Neither a frozen error nor a primitive (`callback('Unauthorized')`) can carry that property — a primitive cannot hold a WeakSet entry either. That assignment throws on a frozen or sealed error (strict mode), and the resulting `TypeError` escaped as an *untagged* error — so the outer catch classified it as an OTEL-internal failure and re-ran the user's handler via `handler(event, lambdaContext)`, this time **without a callback**. A callback-style handler then failed with `callback is not a function`, and any handler with side effects executed twice. Handler-error classification and the expected-rejection verdict now travel in `WeakSet`s keyed on the error plus the identity of the value the inner catch saw, so a frozen object, a primitive and a plain object are all classified correctly, and nothing is written to a caller-owned object. The property is still set opportunistically for backward compatibility. Log fields fall back to `String(error)` so a primitive rejection no longer reports `undefined`.

### Changed
- Handlers that never call `setSpanSuccess()` are entirely unaffected: severity, message, fields and span status are unchanged. The new branch is reachable only when a handler explicitly classifies its own rejection.

## [0.6.0] - 2026-08-25

### Added
- **Adaptive flush throttling for Lambda handlers (PLAT-937)**: `lambdaHandler()` ran `forceFlush(1000)` in its `finally` on every invocation — three parallel OTLP HTTP round trips (traces, metrics, logs) regardless of how fast the handler was. On `rb-lambda-queue-elasticsearch-master` (~500k invocations/day) this added ~210ms of flush latency to a 31ms function, ~7x the useful work.

  New option `flushMinIntervalMs` on `lambdaHandler(options)` and `awsMessageHandler(options)`, falling back to the `OTEL_FLUSH_MIN_INTERVAL_MS` environment variable when not passed explicitly. When set, the auto-flush runs at most once per interval: the first invocation of a cold container always flushes, invocations inside the interval skip the flush entirely (a debug-level log line, not info, so log volume doesn't grow), and the first invocation past the interval flushes again. Skipped telemetry stays in the Batch* processors and is exported by the next qualifying flush or by the batch timers during warm idle time.

  The throttle tracks the last flush **attempt** (successful or not), so a failing collector is not hammered on every invocation. Invalid or negative values collapse to 0 so a misconfigured env var can never silently stop flushing.

  **Default is 0 — flush on every invocation, exactly as before.** Nothing changes fleet-wide until a function opts in by setting `OTEL_FLUSH_MIN_INTERVAL_MS` (the layer's auto-wrap wrapper needs no change: the SDK reads the env var itself).

## [0.5.7] - 2026-08-21

### Fixed
- **`setupFastify` and `awsMessageSpan` were missing from `index.d.ts`**: both are exported at runtime, documented, and covered by tests, but neither was declared — so no TypeScript consumer could call either without casting the module. `setupFastify` in particular meant every Fastify service instrumenting from TypeScript hit `TS2305: Module '"rebrandly-otel"' has no exported member 'setupFastify'`, despite `fastifyMiddleware.js`, `FASTIFY_INTEGRATION.md`, `examples/fastify/` and `tests/fastifyMiddleware.test.js` all shipping. Found while instrumenting `scraper-service` (PLAT-706), which is Fastify on ECS.

  `awsMessageSpan` is used throughout `DOCUMENTATION.md` and the `rebrandly-instrumentation` skill's SNS/SQS patterns, so the documented approach was unavailable to typed callers.

### Added
- **`tests/typeDeclarations.test.js`** — asserts every runtime export has a value-level declaration in `index.d.ts`, and that no declaration outlives its export. Type declarations drift silently because nothing fails when one is forgotten; this fails. Verified to fail against the previous `index.d.ts`.

## [0.5.6] - 2026-08-07

### Fixed
- **`deployment.environment` no longer defaults to `local` (PLAT-813)**: `createResource()` read `ENV`/`ENVIRONMENT`/`NODE_ENV` and fell back to the literal `'local'`, passing any value straight through. In practice 69 instrumented Lambdas set none of those variables, so real production traffic — 2,361,505 spans/day, 16% of all trace volume, including `dashboard-app-logging-master` and `url-query-params-api-master` serving `templating.rebrandly.com` — was reported as `local` and was invisible to every production-filtered dashboard, alert, SLO and TCO trace policy. A further 11 functions set `ENV` to a branch slug and reported `master`/`develop`/`dev` verbatim.

  Resolution is now, in order: `ENV`/`ENVIRONMENT`/`NODE_ENV` mapped through an alias table (`master`/`main`/`prod` → `production`; `develop`/`dev`/`staging`/`test`/`qa` → `development`), then the `AWS_LAMBDA_FUNCTION_NAME` branch suffix, then the `OTEL_EXPORTER_OTLP_ENDPOINT` host (the two collectors are environment-specific), then `'unknown'`. Function-name and endpoint inference together cover all 69 previously-unresolved functions.

  The minimal resource built on the `createResource()` error path also went out hardcoded as `local`; it now resolves too.

  New exports: `getDeploymentEnvironment()` and `normalizeEnvironment()`.

### Changed
- **Default is `unknown`, not `local`**: an unresolved environment is a configuration gap and now looks like one in the data. `local` is reported only when a service sets it explicitly.
- **Branch slugs are normalised rather than echoed**: `ENV=master` now reports `production`. This is telemetry-only — nothing is written back to `process.env`, so services that overload `ENV` as a routing key (S3 prefixes, `isProduction()` checks) are unaffected.
- `OTEL_RESOURCE_ATTRIBUTES=deployment.environment=...` continues to override everything above.

## [0.5.2] - 2026-06-26

### Fixed
- **Knex spans always timed out at ~60s (ERROR)**: The in-flight span tracking added in 0.4.24 keyed its `WeakMap` on the `queryData` object reference. But knex emits a **fresh shallow clone** of the query object to every event — `query`, `query-response`, and `query-error` each get their own `Object.assign({ __knexUid, __knexTxId }, obj)` (see `knex/lib/execution/runner.js`). So the object handed to `query-response`/`query-error` was never the one stored on `query`, `finalize()` always missed, and **every** `knex.query` span only ended via the `OTEL_KNEX_QUERY_TIMEOUT_MS` fallback (~60s) and was marked ERROR — even though the underlying query succeeded in milliseconds. This produced large volumes of fake 60s ERROR spans, polluting error-rate and p99 latency and fragmenting traces (spans exceeding the gateway's `tail_sampling decision_wait`). Fix: key in-flight spans on `queryData.__knexQueryUid` (a per-query id set via nanoid in the query compiler / raw builder that survives the clones), with a WeakMap fallback on object identity when no uid is present. The existing unit tests passed only because they re-emit the *same* mock object, which real knex never does; added regression tests that emit distinct objects sharing `__knexQueryUid`.

## [0.5.1] - 2026-05-18

### Fixed
- **Express aborted request visibility**: Added `res.on('close', ...)` handler in `appAfterRequest`. When a client disconnects before the server sends a response (e.g. upstream hang causing client timeout), the request is now logged as `Request aborted METHOD /path` with `http.response.status_code: 0` and the span is ended. Previously these requests were completely invisible in Coralogix.

## [0.4.24] - 2026-04-18

### Fixed
- **Knex span lifecycle (N1)**: Active query spans are now tracked in a private `WeakMap` inside the instrumentation closure rather than being stashed on the user's `queryData` object (`queryData.__otel_span`). Benefits: (a) query objects can be GC'd normally; (b) a configurable timeout (`OTEL_KNEX_QUERY_TIMEOUT_MS`, default 30 s) ends abandoned spans that never receive a `query-response` or `query-error` event, preventing span leaks when the connection is torn down mid-query; (c) `finalize()` is idempotent — double-ending a span (e.g. both `query-response` and `query-error` firing) is a no-op. The timeout is called with `.unref()` so it does not block Lambda process exit.
- **Knex `extractOperation` CPU cost (N2)**: Replaced `sql.toUpperCase().startsWith(...)` (O(n) on full query string) with `sql.trimStart().slice(0, 10).toUpperCase()` (O(1)), eliminating wasted CPU on long SQL strings in hot query paths.
- **Knex `db.name` for dynamic connection config (N3)**: Added a guard for Knex pools configured with `connection` as a function (e.g. dynamic credentials from Secrets Manager). Previously, `knexInstance.client?.config?.connection?.database` would be `undefined`, and the attribute was set to `undefined`. Now falls back to `"unknown"` only when the connection config is not a plain object with a `database` property.

### Changed (behavioral)
- **Header attribute size cap (N6)**: `filterImportantHeaders` now truncates individual header values that exceed `OTEL_MAX_HEADER_VALUE_BYTES` (default **2048 bytes**). Truncated values get a `...[truncated N bytes]` suffix. This prevents pathological `x-forwarded-for` proxy chains from inflating span attributes without bound.
  - `authorization`, `cookie`, and `x-amzn-*` headers are NOT in the captured whitelist and are unaffected.
  - `traceparent` is always 55 bytes — safely under the cap.
  - To raise the cap for legitimate large headers: `OTEL_MAX_HEADER_VALUE_BYTES=4096`.
  - **Dashboard impact**: Coralogix/Grafana queries that regex-match `http.request.headers.x-forwarded-for` on requests behind long proxy chains may now see the truncation suffix. Update queries if needed.

### Tests
- Added `tests/phaseA.hypotheses.test.js` — 12 tests encoding Phase A hypothesis verification results:
  - **N4 (refuted)**: Lambda callback-style handler span lifecycle is correct; background work that runs after `cb()` inherits the ended span via `AsyncLocalStorage` (Lambda contract, not an SDK bug).
  - **N6 (confirmed → fixed)**: Header size cap now asserted in both directions (whitelist blocks sensitive headers; overlong values truncated).
  - **N8 (refuted)**: W3C traceparent malformed-header handling is compliant — malformed values produce no trusted parent span context, matching the spec.
  - **N9 (refuted)**: `awsMessageHandler` correctly ends all spans under concurrent record processing and per-record error conditions.

### Safety
- All changes are safe for Lambda (warm-container reuse, `unref` on timeouts) and ECS deployments. The `WeakMap` for Knex span tracking prevents unbounded memory growth across Lambda invocations.

## [0.4.23] - 2026-04-17

### Fixed
- **Critical**: Fixed `span_name` cardinality explosion when requests hit paths that match no registered route. Applied consistently across all HTTP integrations: Fastify, Express, lambda-api, and direct API Gateway Lambda handlers.
  - Previously, unmatched URLs were run through `autoDetectRoutePattern` as a last-resort fallback. That helper only normalizes UUIDs and numeric IDs, so arbitrary paths like `/phpinfo.php` or `/.env.local` were preserved verbatim and became unique span names.
  - A path-scanning bot hitting `c-tracking-api` with ~15,000 unique scanner URLs on 2026-04-16 produced ~191k metric series for `duration_ms_bucket` (~80x baseline) and doubled Coralogix metrics ingestion for the day.
  - Fix aligns with OpenTelemetry HTTP semantic conventions: when `http.route` cannot be determined, the span name is the HTTP method alone (e.g. `GET`), and the `http.route` attribute is left unset. Matched-route behavior, manual `otelRoutePattern` overrides, and wildcard routes are unchanged.
  - Affected files: `fastifyMiddleware.js`, `expressMiddleware.js`, `lambdaApiMiddleware.js`, `apiGatewayUtils.js`. The last one also protects Lambda Function URL invocations, which have no `event.resource` or `event.routeKey`.
- Removed unused `reconstructRoutePattern` import from `expressMiddleware.js` and `lambdaApiMiddleware.js`, and unused `autoDetectRoutePattern` import from `apiGatewayUtils.js` (only referenced by the removed fallbacks).

## [0.4.20] - 2026-01-28

### Fixed
- **Critical**: Fixed trace context (traceId, spanId) missing from error logs in Lambda handlers
  - Error logs now correctly include trace context for correlation with distributed traces
  - Trace context is captured while span is active and propagated to all error/warning logs
  - Enables filtering error logs by traceId in Coralogix and other observability platforms
  - Affects logs in Lambda execution error handler and flush-related error/warning logs

### Added
- Integration test example (`examples/lambda/error-handling.js`) demonstrating trace context in both success and error scenarios

## [0.4.19] - 2026-01-XX

### Changed
- Tweaked callback parameters in Lambda handler wrapper

## Earlier Versions

See git history for changes in versions prior to 0.4.19.
