autotel 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auto.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  let node_module = require("node:module");
4
4
  node_module = require_rolldown_runtime.__toESM(node_module, 1);
5
5
  let import_in_the_middle = require("import-in-the-middle");
package/dist/auto.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as loadYamlConfig, a as init } from "./init-8SISAGdE.js";
1
+ import { _ as loadYamlConfig, a as init } from "./init-C-qfxo_u.js";
2
2
  import * as nodeModule from "node:module";
3
3
  import { createAddHookMessageChannel } from "import-in-the-middle";
4
4
 
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
 
4
4
  exports.CORRELATION_ID_BAGGAGE_KEY = require_init.CORRELATION_ID_BAGGAGE_KEY;
5
5
  exports.generateCorrelationId = require_init.generateCorrelationId;
@@ -1,3 +1,3 @@
1
- import { $ as getCorrelationStorage, Q as getCorrelationId, X as CORRELATION_ID_BAGGAGE_KEY, Z as generateCorrelationId, et as getOrCreateCorrelationId, nt as setCorrelationId, rt as setCorrelationIdInBaggage, tt as runWithCorrelationId } from "./init-8SISAGdE.js";
1
+ import { $ as generateCorrelationId, Q as CORRELATION_ID_BAGGAGE_KEY, at as setCorrelationIdInBaggage, et as getCorrelationId, it as setCorrelationId, nt as getOrCreateCorrelationId, rt as runWithCorrelationId, tt as getCorrelationStorage } from "./init-C-qfxo_u.js";
2
2
 
3
3
  export { CORRELATION_ID_BAGGAGE_KEY, generateCorrelationId, getCorrelationId, getCorrelationStorage, getOrCreateCorrelationId, runWithCorrelationId, setCorrelationId, setCorrelationIdInBaggage };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  const require_values = require('./values-AxGpgYBA.cjs');
4
4
  const require_config = require('./config.cjs');
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,4 +1,4 @@
1
- import { U as createTraceContext } from "./init-8SISAGdE.js";
1
+ import { G as createTraceContext } from "./init-C-qfxo_u.js";
2
2
  import { y as splitNameOrOptions } from "./values-xBtdXtjA.js";
3
3
  import { getConfig } from "./config.js";
4
4
  import { SpanStatusCode } from "@opentelemetry/api";
package/dist/event.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
 
4
4
  exports.Event = require_init.Event;
5
5
  exports.getEvents = require_init.getEvents;
package/dist/event.js CHANGED
@@ -1,3 +1,3 @@
1
- import { d as Event, f as getEvents, p as resetEvents } from "./init-8SISAGdE.js";
1
+ import { d as Event, f as getEvents, p as resetEvents } from "./init-C-qfxo_u.js";
2
2
 
3
3
  export { Event, getEvents, resetEvents };
@@ -1,10 +1,11 @@
1
- import { C as AUTOTEL_SAMPLING_RATE, D as AlwaysSampler, G as getActiveContextWithBaggage, I as debugCaptureRequested, J as getEventQueue, K as getContextStorage, T as AUTOTEL_SAMPLING_TAIL_KEEP, U as createTraceContext, h as runInOperationContext, i as getSdk, n as getConfiguredSampler, q as hasExplicitSpanStatus, t as getConfig, w as AUTOTEL_SAMPLING_TAIL_EVALUATED, z as isForceKept } from "./init-8SISAGdE.js";
2
- import { _ as readProperty, h as isFunction, l as asString, m as isDevelopment } from "./values-xBtdXtjA.js";
1
+ import { D as AUTOTEL_SAMPLING_TAIL_KEEP, E as AUTOTEL_SAMPLING_TAIL_EVALUATED, G as createTraceContext, J as getContextStorage, R as debugCaptureRequested, T as AUTOTEL_SAMPLING_RATE, V as isForceKept, X as getEventQueue, Y as hasExplicitSpanStatus, b as getRequestSpanIn, h as runInOperationContext, i as getSdk, k as AlwaysSampler, n as getConfiguredSampler, q as getActiveContextWithBaggage, t as getConfig, x as rememberRequestAttributes } from "./init-C-qfxo_u.js";
2
+ import { l as asString, m as isDevelopment } from "./values-xBtdXtjA.js";
3
3
  import { getForceFlushableProvider } from "./tracer-provider.js";
4
4
  import { getConfig as getConfig$1 } from "./config.js";
5
+ import { a as flattenToAttributes } from "./structured-error-Y9y-1Pae.js";
5
6
  import { evidenceAttribute } from "./evidence.js";
6
7
  import { setSpanName } from "./trace-helpers.js";
7
- import { SpanStatusCode, context, createContextKey, propagation, trace } from "@opentelemetry/api";
8
+ import { SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
8
9
  import * as nodeFs from "node:fs";
9
10
  import * as nodeUrl from "node:url";
10
11
 
@@ -645,22 +646,6 @@ function createCtxProxy(resolve) {
645
646
  }
646
647
  const ctx = createCtxProxy(getCtxValue);
647
648
  /**
648
- * The key `@opentelemetry/core` publishes RPC metadata under. `createContextKey`
649
- * is `Symbol.for`, so this reads exactly what `instrumentation-http` (and every
650
- * framework instrumentation that renames the route) wrote, without taking a
651
- * dependency on core.
652
- */
653
- const RPC_METADATA_KEY = createContextKey("OpenTelemetry SDK Context Key RPC_METADATA");
654
- /**
655
- * The span the current request is being recorded on, or the active span when
656
- * there is no request - a queue consumer or a cron job has none, and an
657
- * attribute belongs somewhere real rather than nowhere.
658
- */
659
- function getRequestSpan() {
660
- const requestSpan = readProperty(context.active().getValue(RPC_METADATA_KEY), "span");
661
- return isFunction(readProperty(requestSpan, "spanContext")) ? requestSpan : trace.getActiveSpan();
662
- }
663
- /**
664
649
  * The ambient {@link ctx}, aimed at the **request** span rather than at
665
650
  * whatever span the calling code happens to be inside.
666
651
  *
@@ -683,8 +668,21 @@ function getRequestSpan() {
683
668
  * ```
684
669
  */
685
670
  const requestCtx = createCtxProxy(() => {
686
- const span = getRequestSpan();
687
- return span ? createTraceContext(span) : null;
671
+ const span = getRequestSpanIn() ?? trace.getActiveSpan();
672
+ if (!span) return null;
673
+ return {
674
+ ...createTraceContext(span),
675
+ setAttribute: (key, value) => {
676
+ const attrs = flattenToAttributes({ [key]: value });
677
+ span.setAttributes(attrs);
678
+ rememberRequestAttributes(span, attrs);
679
+ },
680
+ setAttributes: (attrs) => {
681
+ const flattened = flattenToAttributes(attrs);
682
+ span.setAttributes(flattened);
683
+ rememberRequestAttributes(span, flattened);
684
+ }
685
+ };
688
686
  });
689
687
  function traceImpl(fnOrNameOrOptions, maybeFn) {
690
688
  if (typeof fnOrNameOrOptions === "function") return wrapPlainWithTracing(fnOrNameOrOptions, {});
@@ -1,8 +1,9 @@
1
1
  const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  const require_values = require('./values-AxGpgYBA.cjs');
4
4
  const require_tracer_provider = require('./tracer-provider.cjs');
5
5
  const require_config = require('./config.cjs');
6
+ const require_structured_error = require('./structured-error-DynjWTTu.cjs');
6
7
  const require_evidence = require('./evidence.cjs');
7
8
  const require_trace_helpers = require('./trace-helpers.cjs');
8
9
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -648,22 +649,6 @@ function createCtxProxy(resolve) {
648
649
  }
649
650
  const ctx = createCtxProxy(getCtxValue);
650
651
  /**
651
- * The key `@opentelemetry/core` publishes RPC metadata under. `createContextKey`
652
- * is `Symbol.for`, so this reads exactly what `instrumentation-http` (and every
653
- * framework instrumentation that renames the route) wrote, without taking a
654
- * dependency on core.
655
- */
656
- const RPC_METADATA_KEY = (0, _opentelemetry_api.createContextKey)("OpenTelemetry SDK Context Key RPC_METADATA");
657
- /**
658
- * The span the current request is being recorded on, or the active span when
659
- * there is no request - a queue consumer or a cron job has none, and an
660
- * attribute belongs somewhere real rather than nowhere.
661
- */
662
- function getRequestSpan() {
663
- const requestSpan = require_values.readProperty(_opentelemetry_api.context.active().getValue(RPC_METADATA_KEY), "span");
664
- return require_values.isFunction(require_values.readProperty(requestSpan, "spanContext")) ? requestSpan : _opentelemetry_api.trace.getActiveSpan();
665
- }
666
- /**
667
652
  * The ambient {@link ctx}, aimed at the **request** span rather than at
668
653
  * whatever span the calling code happens to be inside.
669
654
  *
@@ -686,8 +671,21 @@ function getRequestSpan() {
686
671
  * ```
687
672
  */
688
673
  const requestCtx = createCtxProxy(() => {
689
- const span = getRequestSpan();
690
- return span ? require_init.createTraceContext(span) : null;
674
+ const span = require_init.getRequestSpanIn() ?? _opentelemetry_api.trace.getActiveSpan();
675
+ if (!span) return null;
676
+ return {
677
+ ...require_init.createTraceContext(span),
678
+ setAttribute: (key, value) => {
679
+ const attrs = require_structured_error.flattenToAttributes({ [key]: value });
680
+ span.setAttributes(attrs);
681
+ require_init.rememberRequestAttributes(span, attrs);
682
+ },
683
+ setAttributes: (attrs) => {
684
+ const flattened = require_structured_error.flattenToAttributes(attrs);
685
+ span.setAttributes(flattened);
686
+ require_init.rememberRequestAttributes(span, flattened);
687
+ }
688
+ };
691
689
  });
692
690
  function traceImpl(fnOrNameOrOptions, maybeFn) {
693
691
  if (typeof fnOrNameOrOptions === "function") return wrapPlainWithTracing(fnOrNameOrOptions, {});
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_functional = require('./functional-u5Qwjray.cjs');
2
+ const require_functional = require('./functional-DxHvvWc_.cjs');
3
3
 
4
4
  exports.ctx = require_functional.ctx;
5
5
  exports.getActiveTraceContext = require_functional.getActiveTraceContext;
@@ -1,3 +1,3 @@
1
- import { a as span, c as withNewContext, i as requestCtx, l as withTracing, n as getActiveTraceContext, o as trace, r as instrument, s as withBaggage, t as ctx } from "./functional-CC2BFGAO.js";
1
+ import { a as span, c as withNewContext, i as requestCtx, l as withTracing, n as getActiveTraceContext, o as trace, r as instrument, s as withBaggage, t as ctx } from "./functional-6QPJDqUW.js";
2
2
 
3
3
  export { ctx, getActiveTraceContext, instrument, requestCtx, span, trace, withBaggage, withNewContext, withTracing };
package/dist/http.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  const require_values = require('./values-AxGpgYBA.cjs');
4
4
  const require_config = require('./config.cjs');
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
package/dist/http.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G as getActiveContextWithBaggage } from "./init-8SISAGdE.js";
1
+ import { q as getActiveContextWithBaggage } from "./init-C-qfxo_u.js";
2
2
  import { _ as readProperty, h as isFunction, i as asNumber, l as asString } from "./values-xBtdXtjA.js";
3
3
  import { getConfig } from "./config.js";
4
4
  import { SpanStatusCode, context, propagation } from "@opentelemetry/api";
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
3
- const require_init = require('./init-21HWbm7_.cjs');
3
+ const require_init = require('./init-W_klPrYk.cjs');
4
4
  const require_values = require('./values-AxGpgYBA.cjs');
5
5
  const require_tracer_provider = require('./tracer-provider.cjs');
6
6
  const require_structured_error = require('./structured-error-DynjWTTu.cjs');
@@ -9,7 +9,7 @@ const require_span_name_normalizer = require('./span-name-normalizer.cjs');
9
9
  const require_attribute_redacting_processor = require('./attribute-redacting-processor.cjs');
10
10
  const require_canonical_log_line_processor = require('./canonical-log-line-processor-BU03jJeA.cjs');
11
11
  const require_metric = require('./metric.cjs');
12
- const require_functional = require('./functional-u5Qwjray.cjs');
12
+ const require_functional = require('./functional-DxHvvWc_.cjs');
13
13
  const require_trace_helpers = require('./trace-helpers.cjs');
14
14
  const require_stable_hash = require('./stable-hash-sLi1o4jj.cjs');
15
15
  const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as markForceKept, D as AlwaysSampler, E as AdaptiveSampler, F as createLinkFromHeaders, H as samplingPresets, J as getEventQueue, L as extractLinksFromBatch, M as NeverSampler, N as RandomSampler, P as UserIdSampler, Q as getCorrelationId, S as AUTOTEL_DEBUG_BAGGAGE_KEY, T as AUTOTEL_SAMPLING_TAIL_KEEP, U as createTraceContext, V as resolveSamplingPreset, W as defineBaggageSchema, X as CORRELATION_ID_BAGGAGE_KEY, Y as track, Z as generateCorrelationId, a as init, b as BaggageSpanProcessor, c as lockLogger, d as Event, et as getOrCreateCorrelationId, f as getEvents, h as runInOperationContext, l as flush, m as getOperationContext, nt as setCorrelationId, o as isInitialized, p as resetEvents, rt as setCorrelationIdInBaggage, s as isLoggerLocked, tt as runWithCorrelationId, u as shutdown, w as AUTOTEL_SAMPLING_TAIL_EVALUATED, y as createStringRedactor } from "./init-8SISAGdE.js";
1
+ import { $ as generateCorrelationId, D as AUTOTEL_SAMPLING_TAIL_KEEP, E as AUTOTEL_SAMPLING_TAIL_EVALUATED, F as RandomSampler, G as createTraceContext, H as markForceKept, I as UserIdSampler, K as defineBaggageSchema, L as createLinkFromHeaders, O as AdaptiveSampler, P as NeverSampler, Q as CORRELATION_ID_BAGGAGE_KEY, S as BaggageSpanProcessor, U as resolveSamplingPreset, W as samplingPresets, X as getEventQueue, Z as track, a as init, at as setCorrelationIdInBaggage, c as lockLogger, d as Event, et as getCorrelationId, f as getEvents, h as runInOperationContext, it as setCorrelationId, k as AlwaysSampler, l as flush, m as getOperationContext, nt as getOrCreateCorrelationId, o as isInitialized, p as resetEvents, rt as runWithCorrelationId, s as isLoggerLocked, u as shutdown, w as AUTOTEL_DEBUG_BAGGAGE_KEY, y as createStringRedactor, z as extractLinksFromBatch } from "./init-C-qfxo_u.js";
2
2
  import { g as nonEmptyString, i as asNumber, l as asString, r as asFunction, s as asRecord, x as toError } from "./values-xBtdXtjA.js";
3
3
  import { getAutotelTracer, getAutotelTracerProvider, setAutotelTracerProvider } from "./tracer-provider.js";
4
4
  import { a as flattenToAttributes, i as structuredErrorToJSON, n as getStructuredErrorAttributes, o as toAttributeValue, r as recordStructuredError, t as createStructuredError } from "./structured-error-Y9y-1Pae.js";
@@ -7,7 +7,7 @@ import { NORMALIZER_PATTERNS, NORMALIZER_PRESETS, SpanNameNormalizingProcessor }
7
7
  import { AttributeRedactingProcessor, REDACTOR_PATTERNS, REDACTOR_PRESETS, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig } from "./attribute-redacting-processor.js";
8
8
  import { n as formatDuration } from "./canonical-log-line-processor-BQ6NeZAk.js";
9
9
  import { Metric, getMetrics, resetMetrics } from "./metric.js";
10
- import { a as span, c as withNewContext, i as requestCtx, l as withTracing, n as getActiveTraceContext, o as trace$2, r as instrument, s as withBaggage, t as ctx } from "./functional-CC2BFGAO.js";
10
+ import { a as span, c as withNewContext, i as requestCtx, l as withTracing, n as getActiveTraceContext, o as trace$2, r as instrument, s as withBaggage, t as ctx } from "./functional-6QPJDqUW.js";
11
11
  import { createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan } from "./trace-helpers.js";
12
12
  import { t as hashJson } from "./stable-hash-AOUgw1DW.js";
13
13
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
@@ -10,7 +10,7 @@ import { AttributeRedactingProcessor, REDACTOR_PRESETS, normalizeAttributeRedact
10
10
  import { t as PrettyConsoleExporter } from "./pretty-console-exporter-DqKl_q9z.js";
11
11
  import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-BQ6NeZAk.js";
12
12
  import { resetMetrics } from "./metric.js";
13
- import { DiagConsoleLogger, DiagLogLevel, TraceFlags, context, diag, metrics, propagation, trace } from "@opentelemetry/api";
13
+ import { DiagConsoleLogger, DiagLogLevel, TraceFlags, context, createContextKey, diag, metrics, propagation, trace } from "@opentelemetry/api";
14
14
  import { logs } from "@opentelemetry/api-logs";
15
15
  import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
16
16
  import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from "@opentelemetry/core";
@@ -2097,6 +2097,76 @@ var BaggageSpanProcessor = class {
2097
2097
  async forceFlush() {}
2098
2098
  };
2099
2099
 
2100
+ //#endregion
2101
+ //#region src/request-attributes.ts
2102
+ /**
2103
+ * Attributes set through `requestCtx` describe the whole request, so every
2104
+ * span started inside that request carries them too - not only the request
2105
+ * span. This stays in-process: nothing rides baggage, so a `user.email` set in
2106
+ * auth middleware never leaves in a `baggage` header on an outgoing call.
2107
+ */
2108
+ /**
2109
+ * The key `@opentelemetry/core` publishes RPC metadata under. `createContextKey`
2110
+ * is `Symbol.for`, so this reads exactly what `instrumentation-http` (and every
2111
+ * framework instrumentation that renames the route) wrote, without taking a
2112
+ * dependency on core.
2113
+ */
2114
+ const RPC_METADATA_KEY = createContextKey("OpenTelemetry SDK Context Key RPC_METADATA");
2115
+ /** The server span of the request `ctx` belongs to, if it belongs to one. */
2116
+ function getRequestSpanIn(ctx = context.active()) {
2117
+ const requestSpan = readProperty(ctx.getValue(RPC_METADATA_KEY), "span");
2118
+ return isFunction(readProperty(requestSpan, "spanContext")) ? requestSpan : void 0;
2119
+ }
2120
+ const scopes = /* @__PURE__ */ new WeakMap();
2121
+ function scopeFor(span) {
2122
+ let scope = scopes.get(span);
2123
+ if (!scope) {
2124
+ scope = { attributes: {} };
2125
+ scopes.set(span, scope);
2126
+ }
2127
+ return scope;
2128
+ }
2129
+ /**
2130
+ * The request span's attributes, or else every ancestor `requestCtx` wrote to,
2131
+ * merged so the nearer one wins a key: a job span tagging `job.id` under a
2132
+ * consumer that tagged `tenant` must not hide the tenant from its children.
2133
+ */
2134
+ function sourceOf(parentContext) {
2135
+ const requestSpan = getRequestSpanIn(parentContext);
2136
+ if (requestSpan) return scopes.get(requestSpan)?.attributes;
2137
+ const nearestFirst = [];
2138
+ const parent = trace.getSpan(parentContext);
2139
+ for (let scope = parent && scopes.get(parent); scope; scope = scope.parent) nearestFirst.push(scope.attributes);
2140
+ return nearestFirst.length > 0 ? Object.assign({}, ...nearestFirst.toReversed()) : void 0;
2141
+ }
2142
+ /** Remember attributes set through `requestCtx`, for the spans started under it. */
2143
+ function rememberRequestAttributes(span, attrs) {
2144
+ Object.assign(scopeFor(span).attributes, attrs);
2145
+ }
2146
+ /**
2147
+ * Copies `requestCtx` attributes onto each span started inside the request -
2148
+ * or, outside one, under the span `requestCtx` fell back to. Only what was set
2149
+ * before the span started is copied, and a key the span already carries keeps
2150
+ * its own value.
2151
+ */
2152
+ var RequestAttributesSpanProcessor = class {
2153
+ onStart(span, parentContext) {
2154
+ const parent = trace.getSpan(parentContext);
2155
+ if (parent) scopeFor(span).parent = scopeFor(parent);
2156
+ const attrs = sourceOf(parentContext);
2157
+ if (!attrs) return;
2158
+ const own = span.attributes;
2159
+ for (const [key, value] of Object.entries(attrs)) if (value !== void 0 && !(key in own)) span.setAttribute(key, value);
2160
+ }
2161
+ onEnd() {}
2162
+ forceFlush() {
2163
+ return Promise.resolve();
2164
+ }
2165
+ shutdown() {
2166
+ return Promise.resolve();
2167
+ }
2168
+ };
2169
+
2100
2170
  //#endregion
2101
2171
  //#region src/redact-values.ts
2102
2172
  /** Standalone string redaction for use outside the span processor pipeline. */
@@ -4298,6 +4368,7 @@ function init(cfg) {
4298
4368
  mergedConfig.spanFilter = userSpanFilter ? (span) => userSpanFilter(span) && policySpanFilter(span) : policySpanFilter;
4299
4369
  }
4300
4370
  if (mergedConfig.spanFilter && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new FilteringSpanProcessor(processor, { filter: mergedConfig.spanFilter }));
4371
+ if (spanProcessors.length > 0) spanProcessors.unshift(new RequestAttributesSpanProcessor());
4301
4372
  if (mergedConfig.spanEnrichers && mergedConfig.spanEnrichers.length > 0) spanProcessors.unshift(...mergedConfig.spanEnrichers);
4302
4373
  const metricReaders = [];
4303
4374
  if (configuredMetricReaders && configuredMetricReaders.length > 0) metricReaders.push(...configuredMetricReaders);
@@ -4462,4 +4533,4 @@ function getSdk() {
4462
4533
  }
4463
4534
 
4464
4535
  //#endregion
4465
- export { getCorrelationStorage as $, FeatureFlagSampler as A, markForceKept as B, AUTOTEL_SAMPLING_RATE as C, AlwaysSampler as D, AdaptiveSampler as E, createLinkFromHeaders as F, getActiveContextWithBaggage as G, samplingPresets as H, debugCaptureRequested as I, getEventQueue as J, getContextStorage as K, extractLinksFromBatch as L, NeverSampler as M, RandomSampler as N, CompositeSampler as O, UserIdSampler as P, getCorrelationId as Q, hashUnitInterval as R, AUTOTEL_DEBUG_BAGGAGE_KEY as S, AUTOTEL_SAMPLING_TAIL_KEEP as T, createTraceContext as U, resolveSamplingPreset as V, defineBaggageSchema as W, CORRELATION_ID_BAGGAGE_KEY as X, track as Y, generateCorrelationId as Z, loadYamlConfig as _, init as a, BaggageSpanProcessor as b, lockLogger as c, Event as d, getOrCreateCorrelationId as et, getEvents as f, hasYamlConfig as g, runInOperationContext as h, getSdk as i, KeyTargetRateSampler as j, DeterministicSampler as k, flush as l, getOperationContext as m, getConfiguredSampler as n, setCorrelationId as nt, isInitialized as o, resetEvents as p, hasExplicitSpanStatus as q, getLogger as r, setCorrelationIdInBaggage as rt, isLoggerLocked as s, getConfig as t, runWithCorrelationId as tt, shutdown as u, loadYamlConfigFromFile as v, AUTOTEL_SAMPLING_TAIL_EVALUATED as w, TailSamplingSpanProcessor as x, createStringRedactor as y, isForceKept as z };
4536
+ export { generateCorrelationId as $, CompositeSampler as A, hashUnitInterval as B, TailSamplingSpanProcessor as C, AUTOTEL_SAMPLING_TAIL_KEEP as D, AUTOTEL_SAMPLING_TAIL_EVALUATED as E, RandomSampler as F, createTraceContext as G, markForceKept as H, UserIdSampler as I, getContextStorage as J, defineBaggageSchema as K, createLinkFromHeaders as L, FeatureFlagSampler as M, KeyTargetRateSampler as N, AdaptiveSampler as O, NeverSampler as P, CORRELATION_ID_BAGGAGE_KEY as Q, debugCaptureRequested as R, BaggageSpanProcessor as S, AUTOTEL_SAMPLING_RATE as T, resolveSamplingPreset as U, isForceKept as V, samplingPresets as W, getEventQueue as X, hasExplicitSpanStatus as Y, track as Z, loadYamlConfig as _, init as a, setCorrelationIdInBaggage as at, getRequestSpanIn as b, lockLogger as c, Event as d, getCorrelationId as et, getEvents as f, hasYamlConfig as g, runInOperationContext as h, getSdk as i, setCorrelationId as it, DeterministicSampler as j, AlwaysSampler as k, flush as l, getOperationContext as m, getConfiguredSampler as n, getOrCreateCorrelationId as nt, isInitialized as o, resetEvents as p, getActiveContextWithBaggage as q, getLogger as r, runWithCorrelationId as rt, isLoggerLocked as s, getConfig as t, getCorrelationStorage as tt, shutdown as u, loadYamlConfigFromFile as v, AUTOTEL_DEBUG_BAGGAGE_KEY as w, rememberRequestAttributes as x, createStringRedactor as y, extractLinksFromBatch as z };
@@ -2101,6 +2101,76 @@ var BaggageSpanProcessor = class {
2101
2101
  async forceFlush() {}
2102
2102
  };
2103
2103
 
2104
+ //#endregion
2105
+ //#region src/request-attributes.ts
2106
+ /**
2107
+ * Attributes set through `requestCtx` describe the whole request, so every
2108
+ * span started inside that request carries them too - not only the request
2109
+ * span. This stays in-process: nothing rides baggage, so a `user.email` set in
2110
+ * auth middleware never leaves in a `baggage` header on an outgoing call.
2111
+ */
2112
+ /**
2113
+ * The key `@opentelemetry/core` publishes RPC metadata under. `createContextKey`
2114
+ * is `Symbol.for`, so this reads exactly what `instrumentation-http` (and every
2115
+ * framework instrumentation that renames the route) wrote, without taking a
2116
+ * dependency on core.
2117
+ */
2118
+ const RPC_METADATA_KEY = (0, _opentelemetry_api.createContextKey)("OpenTelemetry SDK Context Key RPC_METADATA");
2119
+ /** The server span of the request `ctx` belongs to, if it belongs to one. */
2120
+ function getRequestSpanIn(ctx = _opentelemetry_api.context.active()) {
2121
+ const requestSpan = require_values.readProperty(ctx.getValue(RPC_METADATA_KEY), "span");
2122
+ return require_values.isFunction(require_values.readProperty(requestSpan, "spanContext")) ? requestSpan : void 0;
2123
+ }
2124
+ const scopes = /* @__PURE__ */ new WeakMap();
2125
+ function scopeFor(span) {
2126
+ let scope = scopes.get(span);
2127
+ if (!scope) {
2128
+ scope = { attributes: {} };
2129
+ scopes.set(span, scope);
2130
+ }
2131
+ return scope;
2132
+ }
2133
+ /**
2134
+ * The request span's attributes, or else every ancestor `requestCtx` wrote to,
2135
+ * merged so the nearer one wins a key: a job span tagging `job.id` under a
2136
+ * consumer that tagged `tenant` must not hide the tenant from its children.
2137
+ */
2138
+ function sourceOf(parentContext) {
2139
+ const requestSpan = getRequestSpanIn(parentContext);
2140
+ if (requestSpan) return scopes.get(requestSpan)?.attributes;
2141
+ const nearestFirst = [];
2142
+ const parent = _opentelemetry_api.trace.getSpan(parentContext);
2143
+ for (let scope = parent && scopes.get(parent); scope; scope = scope.parent) nearestFirst.push(scope.attributes);
2144
+ return nearestFirst.length > 0 ? Object.assign({}, ...nearestFirst.toReversed()) : void 0;
2145
+ }
2146
+ /** Remember attributes set through `requestCtx`, for the spans started under it. */
2147
+ function rememberRequestAttributes(span, attrs) {
2148
+ Object.assign(scopeFor(span).attributes, attrs);
2149
+ }
2150
+ /**
2151
+ * Copies `requestCtx` attributes onto each span started inside the request -
2152
+ * or, outside one, under the span `requestCtx` fell back to. Only what was set
2153
+ * before the span started is copied, and a key the span already carries keeps
2154
+ * its own value.
2155
+ */
2156
+ var RequestAttributesSpanProcessor = class {
2157
+ onStart(span, parentContext) {
2158
+ const parent = _opentelemetry_api.trace.getSpan(parentContext);
2159
+ if (parent) scopeFor(span).parent = scopeFor(parent);
2160
+ const attrs = sourceOf(parentContext);
2161
+ if (!attrs) return;
2162
+ const own = span.attributes;
2163
+ for (const [key, value] of Object.entries(attrs)) if (value !== void 0 && !(key in own)) span.setAttribute(key, value);
2164
+ }
2165
+ onEnd() {}
2166
+ forceFlush() {
2167
+ return Promise.resolve();
2168
+ }
2169
+ shutdown() {
2170
+ return Promise.resolve();
2171
+ }
2172
+ };
2173
+
2104
2174
  //#endregion
2105
2175
  //#region src/redact-values.ts
2106
2176
  /** Standalone string redaction for use outside the span processor pipeline. */
@@ -4302,6 +4372,7 @@ function init(cfg) {
4302
4372
  mergedConfig.spanFilter = userSpanFilter ? (span) => userSpanFilter(span) && require_policy.policySpanFilter(span) : require_policy.policySpanFilter;
4303
4373
  }
4304
4374
  if (mergedConfig.spanFilter && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new require_filtering_span_processor.FilteringSpanProcessor(processor, { filter: mergedConfig.spanFilter }));
4375
+ if (spanProcessors.length > 0) spanProcessors.unshift(new RequestAttributesSpanProcessor());
4305
4376
  if (mergedConfig.spanEnrichers && mergedConfig.spanEnrichers.length > 0) spanProcessors.unshift(...mergedConfig.spanEnrichers);
4306
4377
  const metricReaders = [];
4307
4378
  if (configuredMetricReaders && configuredMetricReaders.length > 0) metricReaders.push(...configuredMetricReaders);
@@ -4682,6 +4753,12 @@ Object.defineProperty(exports, 'getOrCreateCorrelationId', {
4682
4753
  return getOrCreateCorrelationId;
4683
4754
  }
4684
4755
  });
4756
+ Object.defineProperty(exports, 'getRequestSpanIn', {
4757
+ enumerable: true,
4758
+ get: function () {
4759
+ return getRequestSpanIn;
4760
+ }
4761
+ });
4685
4762
  Object.defineProperty(exports, 'getSdk', {
4686
4763
  enumerable: true,
4687
4764
  get: function () {
@@ -4754,6 +4831,12 @@ Object.defineProperty(exports, 'markForceKept', {
4754
4831
  return markForceKept;
4755
4832
  }
4756
4833
  });
4834
+ Object.defineProperty(exports, 'rememberRequestAttributes', {
4835
+ enumerable: true,
4836
+ get: function () {
4837
+ return rememberRequestAttributes;
4838
+ }
4839
+ });
4757
4840
  Object.defineProperty(exports, 'resetEvents', {
4758
4841
  enumerable: true,
4759
4842
  get: function () {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  const require_node_require = require('./node-require-BPsB09eC.cjs');
4
4
  let _opentelemetry_resources = require("@opentelemetry/resources");
5
5
  let _opentelemetry_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
@@ -1,4 +1,4 @@
1
- import { r as getLogger, x as TailSamplingSpanProcessor } from "./init-8SISAGdE.js";
1
+ import { C as TailSamplingSpanProcessor, r as getLogger } from "./init-C-qfxo_u.js";
2
2
  import { n as safeRequire, t as requireModule } from "./node-require-CkK_xzL-.js";
3
3
  import { detectResources, hostDetector, processDetector, resourceFromAttributes } from "@opentelemetry/resources";
4
4
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
  const require_values = require('./values-AxGpgYBA.cjs');
4
- const require_functional = require('./functional-u5Qwjray.cjs');
4
+ const require_functional = require('./functional-DxHvvWc_.cjs');
5
5
  const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
6
6
  const require_trace_factory_validation = require('./trace-factory-validation-CHU1WcjK.cjs');
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
package/dist/messaging.js CHANGED
@@ -1,6 +1,6 @@
1
- import { F as createLinkFromHeaders, L as extractLinksFromBatch } from "./init-8SISAGdE.js";
1
+ import { L as createLinkFromHeaders, z as extractLinksFromBatch } from "./init-C-qfxo_u.js";
2
2
  import { _ as readProperty, b as toAttributeValue, c as asScalar, g as nonEmptyString, h as isFunction, s as asRecord, v as resolveValue, y as splitNameOrOptions } from "./values-xBtdXtjA.js";
3
- import { l as withTracing } from "./functional-CC2BFGAO.js";
3
+ import { l as withTracing } from "./functional-6QPJDqUW.js";
4
4
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
5
5
  import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
6
6
  import { SpanKind, context, propagation } from "@opentelemetry/api";
package/dist/sampling.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
 
4
4
  exports.AUTOTEL_DEBUG_BAGGAGE_KEY = require_init.AUTOTEL_DEBUG_BAGGAGE_KEY;
5
5
  exports.AUTOTEL_SAMPLING_RATE = require_init.AUTOTEL_SAMPLING_RATE;
package/dist/sampling.js CHANGED
@@ -1,3 +1,3 @@
1
- import { A as FeatureFlagSampler, B as markForceKept, C as AUTOTEL_SAMPLING_RATE, D as AlwaysSampler, E as AdaptiveSampler, F as createLinkFromHeaders, H as samplingPresets, I as debugCaptureRequested, L as extractLinksFromBatch, M as NeverSampler, N as RandomSampler, O as CompositeSampler, P as UserIdSampler, R as hashUnitInterval, S as AUTOTEL_DEBUG_BAGGAGE_KEY, T as AUTOTEL_SAMPLING_TAIL_KEEP, V as resolveSamplingPreset, j as KeyTargetRateSampler, k as DeterministicSampler, w as AUTOTEL_SAMPLING_TAIL_EVALUATED, z as isForceKept } from "./init-8SISAGdE.js";
1
+ import { A as CompositeSampler, B as hashUnitInterval, D as AUTOTEL_SAMPLING_TAIL_KEEP, E as AUTOTEL_SAMPLING_TAIL_EVALUATED, F as RandomSampler, H as markForceKept, I as UserIdSampler, L as createLinkFromHeaders, M as FeatureFlagSampler, N as KeyTargetRateSampler, O as AdaptiveSampler, P as NeverSampler, R as debugCaptureRequested, T as AUTOTEL_SAMPLING_RATE, U as resolveSamplingPreset, V as isForceKept, W as samplingPresets, j as DeterministicSampler, k as AlwaysSampler, w as AUTOTEL_DEBUG_BAGGAGE_KEY, z as extractLinksFromBatch } from "./init-C-qfxo_u.js";
2
2
 
3
3
  export { AUTOTEL_DEBUG_BAGGAGE_KEY, AUTOTEL_SAMPLING_RATE, AUTOTEL_SAMPLING_TAIL_EVALUATED, AUTOTEL_SAMPLING_TAIL_KEEP, AdaptiveSampler, AlwaysSampler, CompositeSampler, DeterministicSampler, FeatureFlagSampler, KeyTargetRateSampler, NeverSampler, RandomSampler, UserIdSampler, createLinkFromHeaders, debugCaptureRequested, extractLinksFromBatch, hashUnitInterval, isForceKept, markForceKept, resolveSamplingPreset, samplingPresets };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_values = require('./values-AxGpgYBA.cjs');
3
- const require_functional = require('./functional-u5Qwjray.cjs');
3
+ const require_functional = require('./functional-DxHvvWc_.cjs');
4
4
  const require_trace_factory_validation = require('./trace-factory-validation-CHU1WcjK.cjs');
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { b as toAttributeValue, g as nonEmptyString, s as asRecord } from "./values-xBtdXtjA.js";
2
- import { l as withTracing } from "./functional-CC2BFGAO.js";
2
+ import { l as withTracing } from "./functional-6QPJDqUW.js";
3
3
  import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
4
4
  import { SpanKind } from "@opentelemetry/api";
5
5
 
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
 
4
4
  exports.TailSamplingSpanProcessor = require_init.TailSamplingSpanProcessor;
@@ -1,3 +1,3 @@
1
- import { x as TailSamplingSpanProcessor } from "./init-8SISAGdE.js";
1
+ import { C as TailSamplingSpanProcessor } from "./init-C-qfxo_u.js";
2
2
 
3
3
  export { TailSamplingSpanProcessor };
package/dist/webhook.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_structured_error = require('./structured-error-DynjWTTu.cjs');
3
- const require_functional = require('./functional-u5Qwjray.cjs');
3
+ const require_functional = require('./functional-DxHvvWc_.cjs');
4
4
  const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
6
6
 
package/dist/webhook.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as recordStructuredError } from "./structured-error-Y9y-1Pae.js";
2
- import { l as withTracing } from "./functional-CC2BFGAO.js";
2
+ import { l as withTracing } from "./functional-6QPJDqUW.js";
3
3
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
4
4
  import { SpanKind, trace } from "@opentelemetry/api";
5
5
 
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_values = require('./values-AxGpgYBA.cjs');
3
- const require_functional = require('./functional-u5Qwjray.cjs');
3
+ const require_functional = require('./functional-DxHvvWc_.cjs');
4
4
  const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
5
5
  const require_business_baggage = require('./business-baggage.cjs');
6
6
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -1,5 +1,5 @@
1
1
  import { h as isFunction, x as toError } from "./values-xBtdXtjA.js";
2
- import { l as withTracing } from "./functional-CC2BFGAO.js";
2
+ import { l as withTracing } from "./functional-6QPJDqUW.js";
3
3
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
4
4
  import { createSafeBaggageSchema } from "./business-baggage.js";
5
5
  import { SpanKind, context, propagation } from "@opentelemetry/api";
package/dist/workflow.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
3
3
  const require_values = require('./values-AxGpgYBA.cjs');
4
- const require_functional = require('./functional-u5Qwjray.cjs');
4
+ const require_functional = require('./functional-DxHvvWc_.cjs');
5
5
  const require_trace_helpers = require('./trace-helpers.cjs');
6
6
  const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
7
7
  const require_trace_factory_validation = require('./trace-factory-validation-CHU1WcjK.cjs');
package/dist/workflow.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { b as toAttributeValue, g as nonEmptyString, h as isFunction, l as asString, s as asRecord, x as toError } from "./values-xBtdXtjA.js";
2
- import { l as withTracing } from "./functional-CC2BFGAO.js";
2
+ import { l as withTracing } from "./functional-6QPJDqUW.js";
3
3
  import { getActiveSpan } from "./trace-helpers.js";
4
4
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
5
5
  import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-21HWbm7_.cjs');
2
+ const require_init = require('./init-W_klPrYk.cjs');
3
3
 
4
4
  exports.hasYamlConfig = require_init.hasYamlConfig;
5
5
  exports.loadYamlConfig = require_init.loadYamlConfig;
@@ -1,3 +1,3 @@
1
- import { _ as loadYamlConfig, g as hasYamlConfig, v as loadYamlConfigFromFile } from "./init-8SISAGdE.js";
1
+ import { _ as loadYamlConfig, g as hasYamlConfig, v as loadYamlConfigFromFile } from "./init-C-qfxo_u.js";
2
2
 
3
3
  export { hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel",
3
- "version": "7.8.0",
3
+ "version": "7.9.0",
4
4
  "description": "Write Once, Observe Anywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",