autotel 7.10.0 → 8.0.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.
Files changed (80) hide show
  1. package/README.md +40 -32
  2. package/dist/auto.cjs +1 -1
  3. package/dist/auto.js +1 -1
  4. package/dist/{canonical-log-line-processor-DDGzm-wi.d.ts → canonical-log-line-processor-BaFqHO5l.d.ts} +1 -2
  5. package/dist/{canonical-log-line-processor-DLeAQjgb.d.cts → canonical-log-line-processor-C-RdV5af.d.cts} +1 -2
  6. package/dist/{canonical-log-line-processor-BU03jJeA.cjs → canonical-log-line-processor-CBRe-VsO.cjs} +0 -1
  7. package/dist/{canonical-log-line-processor-BQ6NeZAk.js → canonical-log-line-processor-CntKMtpJ.js} +0 -1
  8. package/dist/config.d.cts +1 -1
  9. package/dist/config.d.ts +1 -1
  10. package/dist/correlation-id.cjs +1 -1
  11. package/dist/correlation-id.js +1 -1
  12. package/dist/decorators.cjs +1 -1
  13. package/dist/decorators.d.cts +1 -1
  14. package/dist/decorators.d.ts +1 -1
  15. package/dist/decorators.js +1 -1
  16. package/dist/event.cjs +1 -1
  17. package/dist/event.d.cts +1 -1
  18. package/dist/event.d.ts +1 -1
  19. package/dist/event.js +1 -1
  20. package/dist/{functional-CjZT7Jur.cjs → functional-BliCZgwO.cjs} +12 -7
  21. package/dist/{functional-DHn-xGtR.js → functional-C-D0KQg6.js} +12 -7
  22. package/dist/{functional-j8Joyrwd.d.cts → functional-DDunG47Y.d.cts} +1 -1
  23. package/dist/{functional-CbcInXMJ.d.ts → functional-DU7NXyih.d.ts} +1 -1
  24. package/dist/functional.cjs +1 -1
  25. package/dist/functional.d.cts +1 -1
  26. package/dist/functional.d.ts +1 -1
  27. package/dist/functional.js +1 -1
  28. package/dist/http.cjs +1 -1
  29. package/dist/http.js +1 -1
  30. package/dist/index.cjs +3 -3
  31. package/dist/index.d.cts +4 -4
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.js +3 -3
  34. package/dist/{init-rVPOUqng.js → init-CKHEf5g2.js} +101 -27
  35. package/dist/{init-BtYaU5n9.d.cts → init-D5k8hBRg.d.cts} +25 -30
  36. package/dist/{init-zb68UvOW.cjs → init-DF4YrpSB.cjs} +106 -32
  37. package/dist/{init-DUIFqRRS.d.ts → init-DMjyzzbM.d.ts} +25 -30
  38. package/dist/instrumentation.cjs +1 -1
  39. package/dist/instrumentation.js +1 -1
  40. package/dist/{logger-B2VPcBgZ.js → logger-8Ah2EkH1.js} +10 -18
  41. package/dist/{logger-DLjHQAus.cjs → logger-C_3xDBOz.cjs} +10 -18
  42. package/dist/{logger-C9UT1aZ_.d.cts → logger-b0qgWFy7.d.cts} +10 -18
  43. package/dist/{logger-C9UT1aZ_.d.ts → logger-b0qgWFy7.d.ts} +10 -18
  44. package/dist/logger.cjs +1 -1
  45. package/dist/logger.d.cts +1 -1
  46. package/dist/logger.d.ts +1 -1
  47. package/dist/logger.js +1 -1
  48. package/dist/messaging.cjs +2 -2
  49. package/dist/messaging.js +2 -2
  50. package/dist/metric.d.cts +1 -1
  51. package/dist/metric.d.ts +1 -1
  52. package/dist/processors.cjs +1 -1
  53. package/dist/processors.d.cts +1 -1
  54. package/dist/processors.d.ts +1 -1
  55. package/dist/processors.js +1 -1
  56. package/dist/register.cjs +1 -0
  57. package/dist/register.js +1 -0
  58. package/dist/{sampling-Dud4XU2m.d.cts → sampling-CLJmXMw0.d.cts} +1 -1
  59. package/dist/{sampling-B_8orhSB.d.ts → sampling-DBlX8Nv5.d.ts} +1 -1
  60. package/dist/sampling.cjs +1 -1
  61. package/dist/sampling.d.cts +1 -1
  62. package/dist/sampling.d.ts +1 -1
  63. package/dist/sampling.js +1 -1
  64. package/dist/semantic-helpers.cjs +1 -1
  65. package/dist/semantic-helpers.js +1 -1
  66. package/dist/tail-sampling-processor.cjs +1 -1
  67. package/dist/tail-sampling-processor.js +1 -1
  68. package/dist/testing.d.cts +1 -1
  69. package/dist/testing.d.ts +1 -1
  70. package/dist/webhook.cjs +1 -1
  71. package/dist/webhook.js +1 -1
  72. package/dist/workflow-distributed.cjs +1 -1
  73. package/dist/workflow-distributed.js +1 -1
  74. package/dist/workflow.cjs +1 -1
  75. package/dist/workflow.js +1 -1
  76. package/dist/yaml-config.cjs +1 -1
  77. package/dist/yaml-config.d.cts +2 -2
  78. package/dist/yaml-config.d.ts +2 -2
  79. package/dist/yaml-config.js +1 -1
  80. package/package.json +1 -1
package/README.md CHANGED
@@ -656,6 +656,8 @@ export const createUser = withTracing({})(
656
656
 
657
657
  Available helpers: `traceId`, `spanId`, `correlationId`, `setAttribute`, `setAttributes`, `setStatus`, `getBaggage`, `setBaggage`, `deleteBaggage`, `getAllBaggage`.
658
658
 
659
+ An operation that returns normally counts as a success. To report a failure you return as a value, such as an HTTP 502, call `ctx.setStatus({ code: SpanStatusCode.ERROR })` before returning: the span gets `operation.success: false` and `error: true`, and metrics and tail sampling count it as failed.
660
+
659
661
  > **Errors and events:** prefer `recordStructuredError(ctx, error)` and the
660
662
  > request logger over the raw `Span.recordException` / `Span.addEvent` APIs.
661
663
  > See [MIGRATION.md](./MIGRATION.md) for the OTel Span Event deprecation
@@ -1631,20 +1633,28 @@ npm install pino
1631
1633
  npm install @opentelemetry/instrumentation-pino
1632
1634
  ```
1633
1635
 
1634
- ```typescript
1635
- import pino from 'pino';
1636
- import { init, trace, span, withTracing } from 'autotel';
1637
-
1638
- const logger = pino({
1639
- level: process.env.LOG_LEVEL || 'info',
1640
- });
1636
+ The instrumentation patches pino as it loads, so `init()` must run before the
1637
+ logger is created. Keep them in separate modules and import telemetry first.
1638
+ Don't pass the logger to `init()`: that forces you to create it too early.
1641
1639
 
1640
+ ```typescript
1641
+ // telemetry.ts
1642
+ import { init } from 'autotel';
1642
1643
  init({
1643
1644
  service: 'user-service',
1644
- logger,
1645
- autoInstrumentations: ['pino'], // Enable Pino instrumentation for trace context
1645
+ autoInstrumentations: ['http', 'pino'], // only these load
1646
+ logs: true, // export log records via OTLP (off by default)
1646
1647
  });
1647
1648
 
1649
+ // logger.ts
1650
+ import pino from 'pino';
1651
+ export const logger = pino({ level: process.env.LOG_LEVEL || 'info' });
1652
+
1653
+ // index.ts
1654
+ import './telemetry'; // first
1655
+ import { trace } from 'autotel';
1656
+ import { logger } from './logger';
1657
+
1648
1658
  export const createUser = trace(async (data: UserData) => {
1649
1659
  logger.info({ userId: data.id }, 'Creating user');
1650
1660
  try {
@@ -1658,29 +1668,34 @@ export const createUser = trace(async (data: UserData) => {
1658
1668
  });
1659
1669
  ```
1660
1670
 
1671
+ **ESM:** pino's entry module is loaded by `import`, which only the OTel loader
1672
+ hook can patch. Start node with `--import autotel/register` (autotel warns at
1673
+ startup if it's missing, or if pino was loaded before `init()`).
1674
+
1661
1675
  ### Using Winston
1662
1676
 
1663
- **Note:** While `@opentelemetry/auto-instrumentations-node` includes Winston instrumentation, you must install `@opentelemetry/instrumentation-winston` separately for trace context injection to work.
1677
+ **Note:** While `@opentelemetry/auto-instrumentations-node` includes Winston instrumentation, you must install `@opentelemetry/instrumentation-winston` separately for trace context injection to work. With `logs: true`, Winston records only reach OTLP if `@opentelemetry/winston-transport` is installed too.
1664
1678
 
1665
1679
  ```bash
1666
- npm install winston @opentelemetry/instrumentation-winston
1680
+ npm install winston @opentelemetry/instrumentation-winston @opentelemetry/winston-transport
1667
1681
  ```
1668
1682
 
1669
1683
  ```typescript
1670
- import winston from 'winston';
1684
+ // telemetry.ts, imported first
1671
1685
  import { init } from 'autotel';
1686
+ init({
1687
+ service: 'user-service',
1688
+ autoInstrumentations: ['winston'],
1689
+ logs: true,
1690
+ });
1672
1691
 
1673
- const logger = winston.createLogger({
1692
+ // logger.ts
1693
+ import winston from 'winston';
1694
+ export const logger = winston.createLogger({
1674
1695
  level: 'info',
1675
1696
  format: winston.format.json(),
1676
1697
  transports: [new winston.transports.Console()],
1677
1698
  });
1678
-
1679
- init({
1680
- service: 'user-service',
1681
- logger,
1682
- autoInstrumentations: ['winston'], // Enable Winston instrumentation for trace context
1683
- });
1684
1699
  ```
1685
1700
 
1686
1701
  ### Using Bunyan (or other loggers)
@@ -1692,16 +1707,13 @@ npm install bunyan @opentelemetry/instrumentation-bunyan
1692
1707
  ```
1693
1708
 
1694
1709
  ```typescript
1695
- import bunyan from 'bunyan';
1710
+ // telemetry.ts, imported first
1696
1711
  import { init } from 'autotel';
1712
+ init({ service: 'user-service', autoInstrumentations: ['bunyan'], logs: true });
1697
1713
 
1698
- const logger = bunyan.createLogger({ name: 'user-service' });
1699
-
1700
- init({
1701
- service: 'user-service',
1702
- logger,
1703
- autoInstrumentations: ['bunyan'], // Enable Bunyan instrumentation for trace context
1704
- });
1714
+ // logger.ts
1715
+ import bunyan from 'bunyan';
1716
+ export const logger = bunyan.createLogger({ name: 'user-service' });
1705
1717
  ```
1706
1718
 
1707
1719
  **Note:** For manual instrumentation configuration, you can also use:
@@ -1711,7 +1723,6 @@ import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';
1711
1723
 
1712
1724
  init({
1713
1725
  service: 'user-service',
1714
- logger,
1715
1726
  instrumentations: [new BunyanInstrumentation()], // Manual instrumentation with custom config
1716
1727
  });
1717
1728
  ```
@@ -1740,16 +1751,13 @@ init({
1740
1751
 
1741
1752
  ```typescript
1742
1753
  import { init, trace, span, withTracing, setUser, httpServer } from 'autotel';
1743
- import pino from 'pino';
1744
1754
 
1745
- const logger = pino();
1746
1755
  init({
1747
1756
  service: 'checkout-api',
1748
- logger,
1749
1757
  canonicalLogLines: {
1750
1758
  enabled: true,
1751
1759
  rootSpansOnly: true, // One canonical log line per request
1752
- logger, // Use Pino for canonical log lines
1760
+ pretty: true, // Also print each line to the console
1753
1761
  },
1754
1762
  });
1755
1763
 
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-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.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-rVPOUqng.js";
1
+ import { _ as loadYamlConfig, a as init } from "./init-CKHEf5g2.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
  import { t as UnknownRecord } from "./values-CeMH-mYG.js";
2
- import { s as Logger } from "./logger-C9UT1aZ_.js";
2
+ import { s as Logger } from "./logger-b0qgWFy7.js";
3
3
  import { AttributeValue } from "@opentelemetry/api";
4
4
  import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
5
5
  //#region src/processors/canonical-log-line-processor.d.ts
@@ -105,7 +105,6 @@ interface CanonicalLogLineOptions {
105
105
  * const logger = pino();
106
106
  * init({
107
107
  * service: 'my-app',
108
- * logger,
109
108
  * canonicalLogLines: {
110
109
  * enabled: true,
111
110
  * logger, // Use Pino for canonical log lines
@@ -1,5 +1,5 @@
1
1
  import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
2
- import { s as Logger } from "./logger-C9UT1aZ_.cjs";
2
+ import { s as Logger } from "./logger-b0qgWFy7.cjs";
3
3
  import { ReadableSpan, SpanProcessor } from "@opentelemetry/sdk-trace-base";
4
4
  import { AttributeValue } from "@opentelemetry/api";
5
5
  //#region src/processors/canonical-log-line-processor.d.ts
@@ -105,7 +105,6 @@ interface CanonicalLogLineOptions {
105
105
  * const logger = pino();
106
106
  * init({
107
107
  * service: 'my-app',
108
- * logger,
109
108
  * canonicalLogLines: {
110
109
  * enabled: true,
111
110
  * logger, // Use Pino for canonical log lines
@@ -209,7 +209,6 @@ const SEVERITY_NUMBERS = /* @__PURE__ */ new Map([
209
209
  * const logger = pino();
210
210
  * init({
211
211
  * service: 'my-app',
212
- * logger,
213
212
  * canonicalLogLines: {
214
213
  * enabled: true,
215
214
  * logger, // Use Pino for canonical log lines
@@ -209,7 +209,6 @@ const SEVERITY_NUMBERS = /* @__PURE__ */ new Map([
209
209
  * const logger = pino();
210
210
  * init({
211
211
  * service: 'my-app',
212
- * logger,
213
212
  * canonicalLogLines: {
214
213
  * enabled: true,
215
214
  * logger, // Use Pino for canonical log lines
package/dist/config.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as ILogger } from "./logger-C9UT1aZ_.cjs";
1
+ import { t as ILogger } from "./logger-b0qgWFy7.cjs";
2
2
  import { Meter, Tracer } from "@opentelemetry/api";
3
3
  //#region src/config.d.ts
4
4
  export declare const FEATURE_FLAGS: {
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as ILogger } from "./logger-C9UT1aZ_.js";
1
+ import { t as ILogger } from "./logger-b0qgWFy7.js";
2
2
  import { Meter, Tracer } from "@opentelemetry/api";
3
3
  //#region src/config.d.ts
4
4
  export declare const FEATURE_FLAGS: {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.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 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-rVPOUqng.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-CKHEf5g2.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-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.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,5 +1,5 @@
1
1
  import { n as TraceContext } from "./trace-context-f7Xq0Q2q.cjs";
2
- import { h as TracingOptions } from "./functional-j8Joyrwd.cjs";
2
+ import { h as TracingOptions } from "./functional-DDunG47Y.cjs";
3
3
  //#region src/decorators.d.ts
4
4
  /**
5
5
  * Options for @Trace method decorator
@@ -1,5 +1,5 @@
1
1
  import { n as TraceContext } from "./trace-context-CqCblIQE.js";
2
- import { h as TracingOptions } from "./functional-CbcInXMJ.js";
2
+ import { h as TracingOptions } from "./functional-DU7NXyih.js";
3
3
  //#region src/decorators.d.ts
4
4
  /**
5
5
  * Options for @Trace method decorator
@@ -1,4 +1,4 @@
1
- import { G as createTraceContext } from "./init-rVPOUqng.js";
1
+ import { G as createTraceContext } from "./init-CKHEf5g2.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-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.cjs');
3
3
 
4
4
  exports.Event = require_init.Event;
5
5
  exports.getEvents = require_init.getEvents;
package/dist/event.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { s as Logger } from "./logger-C9UT1aZ_.cjs";
1
+ import { s as Logger } from "./logger-b0qgWFy7.cjs";
2
2
  import { c as FunnelStatus, i as EventAttributesInput, l as OutcomeStatus, o as EventSubscriber, r as EventAttributes } from "./event-subscriber-DMACQA-1.cjs";
3
3
  import { t as EventCollector } from "./event-testing-CBtnJXE5.cjs";
4
4
  //#region src/event.d.ts
package/dist/event.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { s as Logger } from "./logger-C9UT1aZ_.js";
1
+ import { s as Logger } from "./logger-b0qgWFy7.js";
2
2
  import { c as FunnelStatus, i as EventAttributesInput, l as OutcomeStatus, o as EventSubscriber, r as EventAttributes } from "./event-subscriber-DMACQA-1.js";
3
3
  import { t as EventCollector } from "./event-testing-CkPgV3Ii.js";
4
4
  //#region src/event.d.ts
package/dist/event.js CHANGED
@@ -1,3 +1,3 @@
1
- import { d as Event, f as getEvents, p as resetEvents } from "./init-rVPOUqng.js";
1
+ import { d as Event, f as getEvents, p as resetEvents } from "./init-CKHEf5g2.js";
2
2
 
3
3
  export { Event, getEvents, resetEvents };
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
2
- const require_init = require('./init-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.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');
@@ -376,7 +376,8 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
376
376
  return promiseFromThenable(unsampled) ?? unsampled;
377
377
  }
378
378
  const startTime = performance.now();
379
- const flushRootTelemetry = createRootTelemetryFlusher(options, options.startNewRoot || _opentelemetry_api.trace.getActiveSpan() === void 0);
379
+ const activeSpan = _opentelemetry_api.trace.getActiveSpan();
380
+ const flushRootTelemetry = createRootTelemetryFlusher(options, options.startNewRoot || activeSpan === void 0 || activeSpan.spanContext().isRemote === true);
380
381
  const spanOptions = {};
381
382
  if (options.startNewRoot) spanOptions.root = true;
382
383
  if (options.spanKind !== void 0) spanOptions.kind = options.spanKind;
@@ -403,28 +404,32 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
403
404
  };
404
405
  const onSuccess = (result) => {
405
406
  const duration = performance.now() - startTime;
407
+ const explicitStatus = require_init.explicitSpanStatus(span);
408
+ const success = explicitStatus !== _opentelemetry_api.SpanStatusCode.ERROR;
409
+ const status = success ? "success" : "error";
406
410
  callCounter?.add(1, {
407
411
  operation: spanName,
408
- status: "success"
412
+ status
409
413
  });
410
414
  durationHistogram?.record(duration, {
411
415
  operation: spanName,
412
- status: "success"
416
+ status
413
417
  });
414
418
  const resultAttributes = {
415
419
  ...captureOutputAttrs(result, options.captureOutput),
416
420
  ...options.attributesFromResult?.(result)
417
421
  };
418
- if (!require_init.hasExplicitSpanStatus(span)) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
422
+ if (explicitStatus === void 0) span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
419
423
  span.setAttributes({
420
424
  ...argsAttributes,
421
425
  ...resultAttributes,
422
426
  "operation.name": spanName,
423
427
  "code.function": spanName,
424
428
  "operation.duration": duration,
425
- "operation.success": true
429
+ "operation.success": success,
430
+ ...success ? {} : { error: true }
426
431
  });
427
- handleTailSampling(true, duration);
432
+ handleTailSampling(success, duration);
428
433
  span.end();
429
434
  return result;
430
435
  };
@@ -1,4 +1,4 @@
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-rVPOUqng.js";
1
+ import { D as AUTOTEL_SAMPLING_TAIL_KEEP, E as AUTOTEL_SAMPLING_TAIL_EVALUATED, G as createTraceContext, J as getActiveContextWithBaggage, R as debugCaptureRequested, T as AUTOTEL_SAMPLING_RATE, V as isForceKept, X as getEventQueue, Y as getContextStorage, b as getRequestSpanIn, h as runInOperationContext, i as getSdk, k as AlwaysSampler, n as getConfiguredSampler, q as explicitSpanStatus, t as getConfig, x as rememberRequestAttributes } from "./init-CKHEf5g2.js";
2
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";
@@ -373,7 +373,8 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
373
373
  return promiseFromThenable(unsampled) ?? unsampled;
374
374
  }
375
375
  const startTime = performance.now();
376
- const flushRootTelemetry = createRootTelemetryFlusher(options, options.startNewRoot || trace.getActiveSpan() === void 0);
376
+ const activeSpan = trace.getActiveSpan();
377
+ const flushRootTelemetry = createRootTelemetryFlusher(options, options.startNewRoot || activeSpan === void 0 || activeSpan.spanContext().isRemote === true);
377
378
  const spanOptions = {};
378
379
  if (options.startNewRoot) spanOptions.root = true;
379
380
  if (options.spanKind !== void 0) spanOptions.kind = options.spanKind;
@@ -400,28 +401,32 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
400
401
  };
401
402
  const onSuccess = (result) => {
402
403
  const duration = performance.now() - startTime;
404
+ const explicitStatus = explicitSpanStatus(span);
405
+ const success = explicitStatus !== SpanStatusCode.ERROR;
406
+ const status = success ? "success" : "error";
403
407
  callCounter?.add(1, {
404
408
  operation: spanName,
405
- status: "success"
409
+ status
406
410
  });
407
411
  durationHistogram?.record(duration, {
408
412
  operation: spanName,
409
- status: "success"
413
+ status
410
414
  });
411
415
  const resultAttributes = {
412
416
  ...captureOutputAttrs(result, options.captureOutput),
413
417
  ...options.attributesFromResult?.(result)
414
418
  };
415
- if (!hasExplicitSpanStatus(span)) span.setStatus({ code: SpanStatusCode.OK });
419
+ if (explicitStatus === void 0) span.setStatus({ code: SpanStatusCode.OK });
416
420
  span.setAttributes({
417
421
  ...argsAttributes,
418
422
  ...resultAttributes,
419
423
  "operation.name": spanName,
420
424
  "code.function": spanName,
421
425
  "operation.duration": duration,
422
- "operation.success": true
426
+ "operation.success": success,
427
+ ...success ? {} : { error: true }
423
428
  });
424
- handleTailSampling(true, duration);
429
+ handleTailSampling(success, duration);
425
430
  span.end();
426
431
  return result;
427
432
  };
@@ -1,5 +1,5 @@
1
1
  import { n as TraceContext } from "./trace-context-f7Xq0Q2q.cjs";
2
- import { m as Sampler$1 } from "./sampling-Dud4XU2m.cjs";
2
+ import { m as Sampler$1 } from "./sampling-CLJmXMw0.cjs";
3
3
  import { Attributes, Span, SpanKind } from "@opentelemetry/api";
4
4
  //#region src/functional-wrapper.d.ts
5
5
  type WrappedFunction<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn | Promise<TReturn>;
@@ -1,5 +1,5 @@
1
1
  import { n as TraceContext } from "./trace-context-CqCblIQE.js";
2
- import { m as Sampler$1 } from "./sampling-B_8orhSB.js";
2
+ import { m as Sampler$1 } from "./sampling-DBlX8Nv5.js";
3
3
  import { Attributes, Span, SpanKind } from "@opentelemetry/api";
4
4
  //#region src/functional-wrapper.d.ts
5
5
  type WrappedFunction<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn | Promise<TReturn>;
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_functional = require('./functional-CjZT7Jur.cjs');
2
+ const require_functional = require('./functional-BliCZgwO.cjs');
3
3
 
4
4
  exports.ctx = require_functional.ctx;
5
5
  exports.getActiveTraceContext = require_functional.getActiveTraceContext;
@@ -1,3 +1,3 @@
1
1
  import { n as TraceContext } from "./trace-context-f7Xq0Q2q.cjs";
2
- import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, h as TracingOptions, i as ctx, l as trace, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-j8Joyrwd.cjs";
2
+ import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, h as TracingOptions, i as ctx, l as trace, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-DDunG47Y.cjs";
3
3
  export { type InstrumentOptions, type SingleInstrumentOptions, SpanOptions, type TraceContext, type TracingOptions, WithBaggageOptions, WithNewContextOptions, ctx, getActiveTraceContext, instrument, requestCtx, span, trace, withBaggage, withNewContext, withTracing };
@@ -1,3 +1,3 @@
1
1
  import { n as TraceContext } from "./trace-context-CqCblIQE.js";
2
- import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, h as TracingOptions, i as ctx, l as trace, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-CbcInXMJ.js";
2
+ import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, h as TracingOptions, i as ctx, l as trace, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-DU7NXyih.js";
3
3
  export { type InstrumentOptions, type SingleInstrumentOptions, SpanOptions, type TraceContext, type TracingOptions, WithBaggageOptions, WithNewContextOptions, ctx, getActiveTraceContext, instrument, requestCtx, span, trace, withBaggage, withNewContext, withTracing };
@@ -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-DHn-xGtR.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-C-D0KQg6.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-zb68UvOW.cjs');
2
+ const require_init = require('./init-DF4YrpSB.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 { q as getActiveContextWithBaggage } from "./init-rVPOUqng.js";
1
+ import { J as getActiveContextWithBaggage } from "./init-CKHEf5g2.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,15 +1,15 @@
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-zb68UvOW.cjs');
3
+ const require_init = require('./init-DF4YrpSB.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');
7
7
  const require_filtering_span_processor = require('./filtering-span-processor.cjs');
8
8
  const require_span_name_normalizer = require('./span-name-normalizer.cjs');
9
9
  const require_attribute_redacting_processor = require('./attribute-redacting-processor.cjs');
10
- const require_canonical_log_line_processor = require('./canonical-log-line-processor-BU03jJeA.cjs');
10
+ const require_canonical_log_line_processor = require('./canonical-log-line-processor-CBRe-VsO.cjs');
11
11
  const require_metric = require('./metric.cjs');
12
- const require_functional = require('./functional-CjZT7Jur.cjs');
12
+ const require_functional = require('./functional-BliCZgwO.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.d.cts CHANGED
@@ -4,15 +4,15 @@ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
4
4
  import { n as TraceContext$1, r as defineBaggageSchema, t as AttributeValue$2 } from "./trace-context-f7Xq0Q2q.cjs";
5
5
  import { BaggageError, BaggageFieldDefinition, BaggageFieldType, BusinessBaggage, BusinessBaggageValues, SafeBaggageOptions, SafeBaggageSchema, createSafeBaggageSchema } from "./business-baggage.cjs";
6
6
  import { CORRELATION_ID_BAGGAGE_KEY, generateCorrelationId, getCorrelationId, getOrCreateCorrelationId, runWithCorrelationId, setCorrelationId, setCorrelationIdInBaggage } from "./correlation-id.cjs";
7
- import { T as samplingPresets, _ as UserIdSampler, a as AdaptiveSampler, b as extractLinksFromBatch, d as NeverSampler, g as SamplingPreset, h as SamplingContext, i as AUTOTEL_SAMPLING_TAIL_KEEP, m as Sampler, o as AlwaysSampler, p as RandomSampler, r as AUTOTEL_SAMPLING_TAIL_EVALUATED, t as AUTOTEL_DEBUG_BAGGAGE_KEY, v as createLinkFromHeaders, w as resolveSamplingPreset } from "./sampling-Dud4XU2m.cjs";
8
- import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, i as ctx, l as trace$2, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-j8Joyrwd.cjs";
7
+ import { T as samplingPresets, _ as UserIdSampler, a as AdaptiveSampler, b as extractLinksFromBatch, d as NeverSampler, g as SamplingPreset, h as SamplingContext, i as AUTOTEL_SAMPLING_TAIL_KEEP, m as Sampler, o as AlwaysSampler, p as RandomSampler, r as AUTOTEL_SAMPLING_TAIL_EVALUATED, t as AUTOTEL_DEBUG_BAGGAGE_KEY, v as createLinkFromHeaders, w as resolveSamplingPreset } from "./sampling-CLJmXMw0.cjs";
8
+ import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, i as ctx, l as trace$2, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-DDunG47Y.cjs";
9
9
  import { DrainPipelineOptions, PipelineDrainFn, createDrainPipeline } from "./drain-pipeline.cjs";
10
10
  import { a as EventSchemaMetadata, c as FunnelStatus, l as OutcomeStatus, n as EventAttributeValue, o as EventSubscriber, r as EventAttributes, s as EventTrackingOptions, t as AutotelEventContext } from "./event-subscriber-DMACQA-1.cjs";
11
11
  import { Event, EventsOptions, getEvents, resetEvents } from "./event.cjs";
12
12
  import { n as FilteringSpanProcessorOptions, r as SpanFilterPredicate, t as FilteringSpanProcessor } from "./filtering-span-processor-BYvLMiNz.cjs";
13
- import { a as AutotelConfig, c as StringRedactor, i as lockLogger, l as createStringRedactor, n as isInitialized, r as isLoggerLocked, s as ProcessHandlersConfig, t as init } from "./init-BtYaU5n9.cjs";
13
+ import { a as AutotelConfig, c as StringRedactor, i as lockLogger, l as createStringRedactor, n as isInitialized, r as isLoggerLocked, s as ProcessHandlersConfig, t as init } from "./init-D5k8hBRg.cjs";
14
14
  import { a as SpanNameNormalizerPreset, i as SpanNameNormalizerFn, n as NORMALIZER_PRESETS, o as SpanNameNormalizingProcessor, r as SpanNameNormalizerConfig, s as SpanNameNormalizingProcessorOptions, t as NORMALIZER_PATTERNS } from "./span-name-normalizer-CN1-8C76.cjs";
15
- import "./canonical-log-line-processor-DLeAQjgb.cjs";
15
+ import "./canonical-log-line-processor-C-RdV5af.cjs";
16
16
  import { i as defineEvent, n as DefinedEvent, r as SchemaLike, t as DefineEventOptions } from "./define-event-BNeuKUPv.cjs";
17
17
  import { ParsedError, parseError } from "./parse-error.cjs";
18
18
  import { Metric, MetricsOptions, getMetrics, resetMetrics } from "./metric.cjs";
package/dist/index.d.ts CHANGED
@@ -4,15 +4,15 @@ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
4
4
  import { n as TraceContext$1, r as defineBaggageSchema, t as AttributeValue$2 } from "./trace-context-CqCblIQE.js";
5
5
  import { BaggageError, BaggageFieldDefinition, BaggageFieldType, BusinessBaggage, BusinessBaggageValues, SafeBaggageOptions, SafeBaggageSchema, createSafeBaggageSchema } from "./business-baggage.js";
6
6
  import { CORRELATION_ID_BAGGAGE_KEY, generateCorrelationId, getCorrelationId, getOrCreateCorrelationId, runWithCorrelationId, setCorrelationId, setCorrelationIdInBaggage } from "./correlation-id.js";
7
- import { T as samplingPresets, _ as UserIdSampler, a as AdaptiveSampler, b as extractLinksFromBatch, d as NeverSampler, g as SamplingPreset, h as SamplingContext, i as AUTOTEL_SAMPLING_TAIL_KEEP, m as Sampler, o as AlwaysSampler, p as RandomSampler, r as AUTOTEL_SAMPLING_TAIL_EVALUATED, t as AUTOTEL_DEBUG_BAGGAGE_KEY, v as createLinkFromHeaders, w as resolveSamplingPreset } from "./sampling-B_8orhSB.js";
8
- import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, i as ctx, l as trace$2, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-CbcInXMJ.js";
7
+ import { T as samplingPresets, _ as UserIdSampler, a as AdaptiveSampler, b as extractLinksFromBatch, d as NeverSampler, g as SamplingPreset, h as SamplingContext, i as AUTOTEL_SAMPLING_TAIL_KEEP, m as Sampler, o as AlwaysSampler, p as RandomSampler, r as AUTOTEL_SAMPLING_TAIL_EVALUATED, t as AUTOTEL_DEBUG_BAGGAGE_KEY, v as createLinkFromHeaders, w as resolveSamplingPreset } from "./sampling-DBlX8Nv5.js";
8
+ import { a as getActiveTraceContext, c as span, d as withNewContext, f as withTracing, i as ctx, l as trace$2, m as SingleInstrumentOptions, n as WithBaggageOptions, o as instrument, p as InstrumentOptions, r as WithNewContextOptions, s as requestCtx, t as SpanOptions, u as withBaggage } from "./functional-DU7NXyih.js";
9
9
  import { DrainPipelineOptions, PipelineDrainFn, createDrainPipeline } from "./drain-pipeline.js";
10
10
  import { a as EventSchemaMetadata, c as FunnelStatus, l as OutcomeStatus, n as EventAttributeValue, o as EventSubscriber, r as EventAttributes, s as EventTrackingOptions, t as AutotelEventContext } from "./event-subscriber-DMACQA-1.js";
11
11
  import { Event, EventsOptions, getEvents, resetEvents } from "./event.js";
12
12
  import { n as FilteringSpanProcessorOptions, r as SpanFilterPredicate, t as FilteringSpanProcessor } from "./filtering-span-processor-BDGe1myy.js";
13
- import { a as AutotelConfig, c as StringRedactor, i as lockLogger, l as createStringRedactor, n as isInitialized, r as isLoggerLocked, s as ProcessHandlersConfig, t as init } from "./init-DUIFqRRS.js";
13
+ import { a as AutotelConfig, c as StringRedactor, i as lockLogger, l as createStringRedactor, n as isInitialized, r as isLoggerLocked, s as ProcessHandlersConfig, t as init } from "./init-DMjyzzbM.js";
14
14
  import { a as SpanNameNormalizerPreset, i as SpanNameNormalizerFn, n as NORMALIZER_PRESETS, o as SpanNameNormalizingProcessor, r as SpanNameNormalizerConfig, s as SpanNameNormalizingProcessorOptions, t as NORMALIZER_PATTERNS } from "./span-name-normalizer-DHcg1bSP.js";
15
- import "./canonical-log-line-processor-DDGzm-wi.js";
15
+ import "./canonical-log-line-processor-BaFqHO5l.js";
16
16
  import { i as defineEvent, n as DefinedEvent, r as SchemaLike, t as DefineEventOptions } from "./define-event-Bd8f8mST.js";
17
17
  import { ParsedError, parseError } from "./parse-error.js";
18
18
  import { Metric, MetricsOptions, getMetrics, resetMetrics } from "./metric.js";
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
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-rVPOUqng.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-CKHEf5g2.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, hasTracerProvider, 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";
5
5
  import { FilteringSpanProcessor } from "./filtering-span-processor.js";
6
6
  import { NORMALIZER_PATTERNS, NORMALIZER_PRESETS, SpanNameNormalizingProcessor } from "./span-name-normalizer.js";
7
7
  import { AttributeRedactingProcessor, REDACTOR_PATTERNS, REDACTOR_PRESETS, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig } from "./attribute-redacting-processor.js";
8
- import { n as formatDuration } from "./canonical-log-line-processor-BQ6NeZAk.js";
8
+ import { n as formatDuration } from "./canonical-log-line-processor-CntKMtpJ.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-DHn-xGtR.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-C-D0KQg6.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";