@effect/opentelemetry 4.0.0-beta.66 → 4.0.0-beta.68

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WebSdk.js","names":["WebTracerProvider","Effect","constant","Layer","isNonEmpty","Logger","Metrics","Resource","Tracer","layerTracerProvider","processor","config","effect","OtelTracerProvider","gen","resource","acquireRelease","sync","provider","undefined","spanProcessors","Array","isArray","ignore","promise","forceFlush","then","shutdown","layer","evaluate","unwrap","isEffect","ResourceLive","TracerLive","spanProcessor","provide","tracerConfig","empty","LoggerLive","logRecordProcessor","mergeWithExisting","loggerMergeWithExisting","layerLoggerProvider","loggerProviderConfig","MetricsLive","metricReader","temporality","metricTemporality","mergeAll","pipe","provideMerge"],"sources":["../src/WebSdk.ts"],"sourcesContent":[null],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,8BAA8B;AAEhE,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,QAAQ,QAAsB,iBAAiB;AACxD,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,OAAO,MAAM,cAAc;AACvC,OAAO,KAAKC,QAAQ,MAAM,eAAe;AACzC,OAAO,KAAKC,MAAM,MAAM,aAAa;AAqBrC;;;;AAIA,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,SAA+D,EAC/DC,MAAuC,KAEvCR,KAAK,CAACS,MAAM,CACVJ,MAAM,CAACK,kBAAkB,EACzBZ,MAAM,CAACa,GAAG,CAAC,aAAS;EAClB,MAAMC,QAAQ,GAAG,OAAOR,QAAQ,CAACA,QAAQ;EACzC,OAAO,OAAON,MAAM,CAACe,cAAc,CACjCf,MAAM,CAACgB,IAAI,CAAC,MAAK;IACf,MAAMC,QAAQ,GAAG,IAAIlB,iBAAiB,CAAC;MACrC,IAA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B,CAAC,CACnF,GACCxC,KAAK,CAACkC,KAAK;EAEf,MAAMO,WAAW,GAAGxC,UAAU,CAACO,MAAM,CAACkC,YAAY,CAAC,GAC/CvC,OAAO,CAACsB,KAAK,CAAC1B,QAAQ,CAACS,MAAM,CAACkC,YAAY,CAAC,EAAE;IAC7CC,WAAW,EAAEnC,MAAM,CAACoC;GACrB,CAAC,GACA5C,KAAK,CAACkC,KAAK;EAEf,OAAOlC,KAAK,CAAC6C,QAAQ,CAACf,UAAU,EAAEW,WAAW,EAAEN,UAAU,CAAC,CAACW,IAAI,CAC7D9C,KAAK,CAAC+C,YAAY,CAAClB,YAAY,CAAC,CACjC;AACH,CAAC,CAAC,CACH","ignoreList":[]}
1
+ {"version":3,"file":"WebSdk.js","names":["WebTracerProvider","Effect","constant","Layer","isNonEmpty","Logger","Metrics","Resource","Tracer","layerTracerProvider","processor","config","effect","OtelTracerProvider","gen","resource","acquireRelease","sync","provider","undefined","spanProcessors","Array","isArray","ignore","promise","forceFlush","then","shutdown","layer","evaluate","unwrap","isEffect","ResourceLive","TracerLive","spanProcessor","provide","tracerConfig","empty","LoggerLive","logRecordProcessor","mergeWithExisting","loggerMergeWithExisting","layerLoggerProvider","loggerProviderConfig","MetricsLive","metricReader","temporality","metricTemporality","mergeAll","pipe","provideMerge"],"sources":["../src/WebSdk.ts"],"sourcesContent":[null],"mappings":"AAiCA,SAASA,iBAAiB,QAAQ,8BAA8B;AAEhE,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,QAAQ,QAAsB,iBAAiB;AACxD,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,OAAO,MAAM,cAAc;AACvC,OAAO,KAAKC,QAAQ,MAAM,eAAe;AACzC,OAAO,KAAKC,MAAM,MAAM,aAAa;AAuBrC;;;;;;AAMA,OAAO,MAAMC,mBAAmB,GAAGA,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AC,CAC/D,GACCjC,KAAK,CAACkC,KAAK;EAEf,MAAMC,UAAU,GAAGlC,UAAU,CAACO,MAAM,CAAC4B,kBAAkB,CAAC,GACpDpC,KAAK,CAACgC,OAAO,CACb9B,MAAM,CAACuB,KAAK,CAAC;IAAEY,iBAAiB,EAAE7B,MAAM,CAAC8B;EAAuB,CAAE,CAAC,EACnEpC,MAAM,CAACqC,mBAAmB,CAAC/B,MAAM,CAAC4B,kBAAkB,EAAE5B,MAAM,CAACgC,oBAAoB,CAAC,CACnF,GACCxC,KAAK,CAACkC,KAAK;EAEf,MAAMO,WAAW,GAAGxC,UAAU,CAACO,MAAM,CAACkC,YAAY,CAAC,GAC/CvC,OAAO,CAACsB,KAAK,CAAC1B,QAAQ,CAACS,MAAM,CAACkC,YAAY,CAAC,EAAE;IAC7CC,WAAW,EAAEnC,MAAM,CAACoC;GACrB,CAAC,GACA5C,KAAK,CAACkC,KAAK;EAEf,OAAOlC,KAAK,CAAC6C,QAAQ,CAACf,UAAU,EAAEW,WAAW,EAAEN,UAAU,CAAC,CAACW,IAAI,CAC7D9C,KAAK,CAAC+C,YAAY,CAAClB,YAAY,CAAC,CACjC;AACH,CAAC,CAAC,CACH","ignoreList":[]}
package/dist/index.d.ts CHANGED
@@ -1,28 +1,147 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  /**
5
- * @since 1.0.0
5
+ * Connects Effect's logging system to the OpenTelemetry Logs SDK.
6
+ *
7
+ * This module provides a logger provider service, an Effect `Logger` that
8
+ * emits OpenTelemetry log records, and layers for installing that logger in an
9
+ * application. It is commonly used to send Effect logs to OTLP, console, or
10
+ * vendor-specific exporters through OpenTelemetry `LogRecordProcessor`s while
11
+ * keeping logs correlated with Effect fibers and spans. Emitted records include
12
+ * the current fiber id, span identifiers when a parent span is present, log
13
+ * annotations, log spans, severity text, and the matching OpenTelemetry
14
+ * severity number.
15
+ *
16
+ * Log export depends on the configured OpenTelemetry processors and exporters;
17
+ * this module creates the provider and logger, but does not choose an exporter.
18
+ * Use the `Resource` layer to attach service and deployment metadata to the
19
+ * provider rather than repeating that data on every log record. When using
20
+ * `layerLoggerProvider`, the provider is scoped and is force-flushed and shut
21
+ * down when the layer is released, with a configurable shutdown timeout. If you
22
+ * supply or manage an OpenTelemetry provider yourself, make sure it is flushed
23
+ * and shut down during application shutdown, especially when using batching
24
+ * processors that may otherwise drop buffered logs.
25
+ *
26
+ * @since 4.0.0
6
27
  */
7
28
  export * as Logger from "./Logger.ts";
8
29
  /**
9
- * @since 1.0.0
30
+ * Bridges Effect metrics into OpenTelemetry by exposing the current Effect
31
+ * metric snapshot as an OpenTelemetry `MetricProducer` and registering it with
32
+ * one or more SDK `MetricReader`s. Use this module when an application already
33
+ * records metrics with Effect and needs those counters, gauges, histograms,
34
+ * frequencies, or summaries exported through OTLP, Prometheus, or another
35
+ * OpenTelemetry-compatible reader/exporter.
36
+ *
37
+ * The `layer` constructor is the usual entry point, and is also used by the
38
+ * Node and Web SDK layers when `metricReader` configuration is supplied. Metric
39
+ * readers are acquired inside the layer scope and shut down when the scope is
40
+ * released, so periodic exporters need the runtime to stay alive long enough to
41
+ * collect and export data. The exporter or backend determines whether
42
+ * cumulative or delta aggregation is expected; this module defaults to
43
+ * cumulative temporality and can be configured with `temporality: "delta"` for
44
+ * backends that require interval-based values.
45
+ *
46
+ * @since 4.0.0
10
47
  */
11
48
  export * as Metrics from "./Metrics.ts";
12
49
  /**
13
- * @since 1.0.0
50
+ * Provides an Effect layer for configuring OpenTelemetry in Node.js
51
+ * processes. The module wires the Effect tracer, metrics producer, and logger
52
+ * into OpenTelemetry SDK providers when span processors, metric readers, or log
53
+ * record processors are supplied, and it builds the shared resource from
54
+ * `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, and optional explicit
55
+ * service metadata.
56
+ *
57
+ * Use this module in Node services, workers, CLIs, or server runtimes that need
58
+ * Effect spans, metrics, and logs exported through OpenTelemetry processors and
59
+ * exporters. Telemetry is enabled only for the configured signal types, so an
60
+ * application can install tracing alone, metrics alone, logging alone, or any
61
+ * combination of them from the same layer.
62
+ *
63
+ * The layer is scoped. Tracer and logger providers are force-flushed and shut
64
+ * down when the scope is released, metric readers are shut down with the same
65
+ * lifecycle, and all shutdown waits are bounded by `shutdownTimeout` with a
66
+ * default of three seconds. Keep the layer scope alive for the lifetime of the
67
+ * process and release it during graceful shutdown so batched exporters have a
68
+ * chance to export final telemetry. When combining this layer with Node
69
+ * auto-instrumentations, register instrumentation before importing modules that
70
+ * should be patched, because many Node instrumentations hook module loading.
71
+ *
72
+ * @since 4.0.0
14
73
  */
15
74
  export * as NodeSdk from "./NodeSdk.ts";
16
75
  /**
17
- * @since 1.0.0
76
+ * Provides the OpenTelemetry resource used by the Effect OpenTelemetry layers.
77
+ *
78
+ * A resource describes the entity that produces telemetry, such as a service,
79
+ * process, deployment, or browser application. The tracing, metrics, logging,
80
+ * and SDK layers use this module's `Resource` service to configure providers
81
+ * and identify emitted telemetry with service-level metadata.
82
+ *
83
+ * Use `layer` when service metadata is known in code, `layerFromEnv` when
84
+ * deploying with `OTEL_SERVICE_NAME` and `OTEL_RESOURCE_ATTRIBUTES`, and
85
+ * `layerEmpty` when no resource attributes should be provided. Resource
86
+ * attributes are for stable process or service metadata, not per-span or
87
+ * per-log data. The explicit `layer` helper sets `service.name` and the
88
+ * `telemetry.sdk.*` attributes after merging custom attributes, so those keys
89
+ * are controlled by this integration. With `layerFromEnv`, `OTEL_SERVICE_NAME`
90
+ * overrides `service.name` from `OTEL_RESOURCE_ATTRIBUTES`, and additional
91
+ * attributes passed to the layer are merged last.
92
+ *
93
+ * @since 4.0.0
18
94
  */
19
95
  export * as Resource from "./Resource.ts";
20
96
  /**
21
- * @since 1.0.0
97
+ * Bridges Effect tracing into OpenTelemetry by installing an Effect `Tracer`
98
+ * that creates OpenTelemetry spans, records attributes, events, links, errors,
99
+ * and status, and keeps OpenTelemetry context active while traced effects run.
100
+ * Use this module when an application already has an OpenTelemetry
101
+ * `TracerProvider`, or when the Node and Web SDK layers should expose Effect
102
+ * spans to OTLP, console, or other OpenTelemetry-compatible exporters.
103
+ *
104
+ * The layer constructors wire Effect's tracer service to either the global
105
+ * OpenTelemetry tracer provider or an explicitly provided `OtelTracer`. This
106
+ * module does not create exporters or span processors by itself, so spans are
107
+ * exported only when the provider has been configured by the application or by
108
+ * the Node/Web SDK layers. Parentage is taken from Effect spans first and can
109
+ * also attach to the active OpenTelemetry context, while `makeExternalSpan` and
110
+ * `withSpanContext` are the entry points for continuing an incoming remote
111
+ * trace. Preserve `traceFlags` and `traceState` when building external spans;
112
+ * otherwise sampling defaults to sampled and trace state cannot be propagated.
113
+ *
114
+ * @since 4.0.0
22
115
  */
23
116
  export * as Tracer from "./Tracer.ts";
24
117
  /**
25
- * @since 1.0.0
118
+ * Provides an Effect layer for configuring OpenTelemetry in browser
119
+ * applications. The module builds a shared resource from explicit service
120
+ * metadata and wires Effect tracing, metrics, and logging into OpenTelemetry
121
+ * SDK providers when span processors, metric readers, or log record processors
122
+ * are supplied.
123
+ *
124
+ * Use this module in client-side applications that need Effect spans, metrics,
125
+ * and logs exported from browser runtimes, such as single-page apps,
126
+ * multi-page apps with hydrated Effect code, frontend workers, or UI flows
127
+ * that should be correlated with backend traces. Telemetry is enabled only for
128
+ * the configured signal types, so tracing, metrics, and logging can be
129
+ * installed independently from the same layer.
130
+ *
131
+ * Browser SDKs cannot rely on process environment resource configuration, so
132
+ * provide stable service metadata explicitly and use resource attributes for
133
+ * application, release, deployment, or page-shell identity rather than
134
+ * per-event data. This module does not create exporters; supply
135
+ * browser-compatible processors, readers, and exporters yourself, and make sure
136
+ * their endpoints are reachable from the browser with the required CORS and
137
+ * authentication behavior. The layer is scoped: tracer providers are
138
+ * force-flushed and shut down when the scope is released, while metric readers
139
+ * and logger providers follow their respective layer lifecycles. Keep the
140
+ * scope alive for the lifetime of the browser application and release it during
141
+ * application teardown when possible so batched exporters and periodic metric
142
+ * readers can deliver buffered telemetry before the page is unloaded.
143
+ *
144
+ * @since 4.0.0
26
145
  */
27
146
  export * as WebSdk from "./WebSdk.ts";
28
147
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;GAEG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,29 +1,148 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  // @barrel: Auto-generated exports. Do not edit manually.
5
5
  /**
6
- * @since 1.0.0
6
+ * Connects Effect's logging system to the OpenTelemetry Logs SDK.
7
+ *
8
+ * This module provides a logger provider service, an Effect `Logger` that
9
+ * emits OpenTelemetry log records, and layers for installing that logger in an
10
+ * application. It is commonly used to send Effect logs to OTLP, console, or
11
+ * vendor-specific exporters through OpenTelemetry `LogRecordProcessor`s while
12
+ * keeping logs correlated with Effect fibers and spans. Emitted records include
13
+ * the current fiber id, span identifiers when a parent span is present, log
14
+ * annotations, log spans, severity text, and the matching OpenTelemetry
15
+ * severity number.
16
+ *
17
+ * Log export depends on the configured OpenTelemetry processors and exporters;
18
+ * this module creates the provider and logger, but does not choose an exporter.
19
+ * Use the `Resource` layer to attach service and deployment metadata to the
20
+ * provider rather than repeating that data on every log record. When using
21
+ * `layerLoggerProvider`, the provider is scoped and is force-flushed and shut
22
+ * down when the layer is released, with a configurable shutdown timeout. If you
23
+ * supply or manage an OpenTelemetry provider yourself, make sure it is flushed
24
+ * and shut down during application shutdown, especially when using batching
25
+ * processors that may otherwise drop buffered logs.
26
+ *
27
+ * @since 4.0.0
7
28
  */
8
29
  export * as Logger from "./Logger.js";
9
30
  /**
10
- * @since 1.0.0
31
+ * Bridges Effect metrics into OpenTelemetry by exposing the current Effect
32
+ * metric snapshot as an OpenTelemetry `MetricProducer` and registering it with
33
+ * one or more SDK `MetricReader`s. Use this module when an application already
34
+ * records metrics with Effect and needs those counters, gauges, histograms,
35
+ * frequencies, or summaries exported through OTLP, Prometheus, or another
36
+ * OpenTelemetry-compatible reader/exporter.
37
+ *
38
+ * The `layer` constructor is the usual entry point, and is also used by the
39
+ * Node and Web SDK layers when `metricReader` configuration is supplied. Metric
40
+ * readers are acquired inside the layer scope and shut down when the scope is
41
+ * released, so periodic exporters need the runtime to stay alive long enough to
42
+ * collect and export data. The exporter or backend determines whether
43
+ * cumulative or delta aggregation is expected; this module defaults to
44
+ * cumulative temporality and can be configured with `temporality: "delta"` for
45
+ * backends that require interval-based values.
46
+ *
47
+ * @since 4.0.0
11
48
  */
12
49
  export * as Metrics from "./Metrics.js";
13
50
  /**
14
- * @since 1.0.0
51
+ * Provides an Effect layer for configuring OpenTelemetry in Node.js
52
+ * processes. The module wires the Effect tracer, metrics producer, and logger
53
+ * into OpenTelemetry SDK providers when span processors, metric readers, or log
54
+ * record processors are supplied, and it builds the shared resource from
55
+ * `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, and optional explicit
56
+ * service metadata.
57
+ *
58
+ * Use this module in Node services, workers, CLIs, or server runtimes that need
59
+ * Effect spans, metrics, and logs exported through OpenTelemetry processors and
60
+ * exporters. Telemetry is enabled only for the configured signal types, so an
61
+ * application can install tracing alone, metrics alone, logging alone, or any
62
+ * combination of them from the same layer.
63
+ *
64
+ * The layer is scoped. Tracer and logger providers are force-flushed and shut
65
+ * down when the scope is released, metric readers are shut down with the same
66
+ * lifecycle, and all shutdown waits are bounded by `shutdownTimeout` with a
67
+ * default of three seconds. Keep the layer scope alive for the lifetime of the
68
+ * process and release it during graceful shutdown so batched exporters have a
69
+ * chance to export final telemetry. When combining this layer with Node
70
+ * auto-instrumentations, register instrumentation before importing modules that
71
+ * should be patched, because many Node instrumentations hook module loading.
72
+ *
73
+ * @since 4.0.0
15
74
  */
16
75
  export * as NodeSdk from "./NodeSdk.js";
17
76
  /**
18
- * @since 1.0.0
77
+ * Provides the OpenTelemetry resource used by the Effect OpenTelemetry layers.
78
+ *
79
+ * A resource describes the entity that produces telemetry, such as a service,
80
+ * process, deployment, or browser application. The tracing, metrics, logging,
81
+ * and SDK layers use this module's `Resource` service to configure providers
82
+ * and identify emitted telemetry with service-level metadata.
83
+ *
84
+ * Use `layer` when service metadata is known in code, `layerFromEnv` when
85
+ * deploying with `OTEL_SERVICE_NAME` and `OTEL_RESOURCE_ATTRIBUTES`, and
86
+ * `layerEmpty` when no resource attributes should be provided. Resource
87
+ * attributes are for stable process or service metadata, not per-span or
88
+ * per-log data. The explicit `layer` helper sets `service.name` and the
89
+ * `telemetry.sdk.*` attributes after merging custom attributes, so those keys
90
+ * are controlled by this integration. With `layerFromEnv`, `OTEL_SERVICE_NAME`
91
+ * overrides `service.name` from `OTEL_RESOURCE_ATTRIBUTES`, and additional
92
+ * attributes passed to the layer are merged last.
93
+ *
94
+ * @since 4.0.0
19
95
  */
20
96
  export * as Resource from "./Resource.js";
21
97
  /**
22
- * @since 1.0.0
98
+ * Bridges Effect tracing into OpenTelemetry by installing an Effect `Tracer`
99
+ * that creates OpenTelemetry spans, records attributes, events, links, errors,
100
+ * and status, and keeps OpenTelemetry context active while traced effects run.
101
+ * Use this module when an application already has an OpenTelemetry
102
+ * `TracerProvider`, or when the Node and Web SDK layers should expose Effect
103
+ * spans to OTLP, console, or other OpenTelemetry-compatible exporters.
104
+ *
105
+ * The layer constructors wire Effect's tracer service to either the global
106
+ * OpenTelemetry tracer provider or an explicitly provided `OtelTracer`. This
107
+ * module does not create exporters or span processors by itself, so spans are
108
+ * exported only when the provider has been configured by the application or by
109
+ * the Node/Web SDK layers. Parentage is taken from Effect spans first and can
110
+ * also attach to the active OpenTelemetry context, while `makeExternalSpan` and
111
+ * `withSpanContext` are the entry points for continuing an incoming remote
112
+ * trace. Preserve `traceFlags` and `traceState` when building external spans;
113
+ * otherwise sampling defaults to sampled and trace state cannot be propagated.
114
+ *
115
+ * @since 4.0.0
23
116
  */
24
117
  export * as Tracer from "./Tracer.js";
25
118
  /**
26
- * @since 1.0.0
119
+ * Provides an Effect layer for configuring OpenTelemetry in browser
120
+ * applications. The module builds a shared resource from explicit service
121
+ * metadata and wires Effect tracing, metrics, and logging into OpenTelemetry
122
+ * SDK providers when span processors, metric readers, or log record processors
123
+ * are supplied.
124
+ *
125
+ * Use this module in client-side applications that need Effect spans, metrics,
126
+ * and logs exported from browser runtimes, such as single-page apps,
127
+ * multi-page apps with hydrated Effect code, frontend workers, or UI flows
128
+ * that should be correlated with backend traces. Telemetry is enabled only for
129
+ * the configured signal types, so tracing, metrics, and logging can be
130
+ * installed independently from the same layer.
131
+ *
132
+ * Browser SDKs cannot rely on process environment resource configuration, so
133
+ * provide stable service metadata explicitly and use resource attributes for
134
+ * application, release, deployment, or page-shell identity rather than
135
+ * per-event data. This module does not create exporters; supply
136
+ * browser-compatible processors, readers, and exporters yourself, and make sure
137
+ * their endpoints are reachable from the browser with the required CORS and
138
+ * authentication behavior. The layer is scoped: tracer providers are
139
+ * force-flushed and shut down when the scope is released, while metric readers
140
+ * and logger providers follow their respective layer lifecycles. Keep the
141
+ * scope alive for the lifetime of the browser application and release it during
142
+ * application teardown when possible so batched exporters and periodic metric
143
+ * readers can deliver buffered telemetry before the page is unloaded.
144
+ *
145
+ * @since 4.0.0
27
146
  */
28
147
  export * as WebSdk from "./WebSdk.js";
29
148
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Logger","Metrics","NodeSdk","Resource","Tracer","WebSdk"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,MAAM,MAAM,aAAa;AAErC;;;AAGA,OAAO,KAAKC,OAAO,MAAM,cAAc;AAEvC;;;AAGA,OAAO,KAAKC,OAAO,MAAM,cAAc;AAEvC;;;AAGA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAKC,MAAM,MAAM,aAAa;AAErC;;;AAGA,OAAO,KAAKC,MAAM,MAAM,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Logger","Metrics","NodeSdk","Resource","Tracer","WebSdk"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,OAAO,KAAKA,MAAM,MAAM,aAAa;AAErC;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,KAAKC,OAAO,MAAM,cAAc;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,KAAKC,OAAO,MAAM,cAAc;AAEvC;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,QAAQ,MAAM,eAAe;AAEzC;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKC,MAAM,MAAM,aAAa;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,KAAKC,MAAM,MAAM,aAAa","ignoreList":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@effect/opentelemetry",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.66",
4
+ "version": "4.0.0-beta.68",
5
5
  "license": "MIT",
6
6
  "description": "OpenTelemetry integration for Effect",
7
7
  "homepage": "https://effect.website",
@@ -63,7 +63,7 @@
63
63
  "@opentelemetry/sdk-trace-node": "^2.0.0",
64
64
  "@opentelemetry/sdk-trace-web": "^2.0.0",
65
65
  "@opentelemetry/semantic-conventions": "^1.33.0",
66
- "effect": "^4.0.0-beta.66"
66
+ "effect": "^4.0.0-beta.68"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@opentelemetry/api": {
@@ -93,18 +93,18 @@
93
93
  },
94
94
  "devDependencies": {
95
95
  "@opentelemetry/api": "^1.9.1",
96
- "@opentelemetry/api-logs": "^0.214.0",
97
- "@opentelemetry/context-async-hooks": "^2.6.1",
98
- "@opentelemetry/exporter-metrics-otlp-http": "0.214.0",
99
- "@opentelemetry/exporter-prometheus": "^0.214.0",
100
- "@opentelemetry/exporter-trace-otlp-http": "^0.214.0",
101
- "@opentelemetry/otlp-exporter-base": "^0.214.0",
102
- "@opentelemetry/resources": "^2.6.1",
103
- "@opentelemetry/sdk-logs": "^0.214.0",
104
- "@opentelemetry/sdk-metrics": "^2.6.1",
105
- "@opentelemetry/sdk-trace-base": "^2.6.1",
106
- "@opentelemetry/sdk-trace-node": "^2.6.1",
107
- "@opentelemetry/sdk-trace-web": "^2.6.1",
96
+ "@opentelemetry/api-logs": "^0.217.0",
97
+ "@opentelemetry/context-async-hooks": "^2.7.1",
98
+ "@opentelemetry/exporter-metrics-otlp-http": "0.217.0",
99
+ "@opentelemetry/exporter-prometheus": "^0.217.0",
100
+ "@opentelemetry/exporter-trace-otlp-http": "^0.217.0",
101
+ "@opentelemetry/otlp-exporter-base": "^0.217.0",
102
+ "@opentelemetry/resources": "^2.7.1",
103
+ "@opentelemetry/sdk-logs": "^0.217.0",
104
+ "@opentelemetry/sdk-metrics": "^2.7.1",
105
+ "@opentelemetry/sdk-trace-base": "^2.7.1",
106
+ "@opentelemetry/sdk-trace-node": "^2.7.1",
107
+ "@opentelemetry/sdk-trace-web": "^2.7.1",
108
108
  "@opentelemetry/semantic-conventions": "^1.40.0"
109
109
  },
110
110
  "scripts": {
package/src/Logger.ts CHANGED
@@ -1,5 +1,26 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Connects Effect's logging system to the OpenTelemetry Logs SDK.
3
+ *
4
+ * This module provides a logger provider service, an Effect `Logger` that
5
+ * emits OpenTelemetry log records, and layers for installing that logger in an
6
+ * application. It is commonly used to send Effect logs to OTLP, console, or
7
+ * vendor-specific exporters through OpenTelemetry `LogRecordProcessor`s while
8
+ * keeping logs correlated with Effect fibers and spans. Emitted records include
9
+ * the current fiber id, span identifiers when a parent span is present, log
10
+ * annotations, log spans, severity text, and the matching OpenTelemetry
11
+ * severity number.
12
+ *
13
+ * Log export depends on the configured OpenTelemetry processors and exporters;
14
+ * this module creates the provider and logger, but does not choose an exporter.
15
+ * Use the `Resource` layer to attach service and deployment metadata to the
16
+ * provider rather than repeating that data on every log record. When using
17
+ * `layerLoggerProvider`, the provider is scoped and is force-flushed and shut
18
+ * down when the layer is released, with a configurable shutdown timeout. If you
19
+ * supply or manage an OpenTelemetry provider yourself, make sure it is flushed
20
+ * and shut down during application shutdown, especially when using batching
21
+ * processors that may otherwise drop buffered logs.
22
+ *
23
+ * @since 4.0.0
3
24
  */
4
25
  import { SeverityNumber } from "@opentelemetry/api-logs"
5
26
  import * as Otel from "@opentelemetry/sdk-logs"
@@ -19,8 +40,10 @@ import { nanosToHrTime, unknownToAttributeValue } from "./internal/attributes.ts
19
40
  import { Resource } from "./Resource.ts"
20
41
 
21
42
  /**
22
- * @since 1.0.0
23
- * @category Services
43
+ * Context service containing the OpenTelemetry `LoggerProvider` used to emit Effect log records.
44
+ *
45
+ * @category services
46
+ * @since 4.0.0
24
47
  */
25
48
  export class OtelLoggerProvider extends Context.Service<
26
49
  OtelLoggerProvider,
@@ -35,8 +58,8 @@ export class OtelLoggerProvider extends Context.Service<
35
58
  * (e.g. Info=20000), which falls outside the OTel spec — backends that
36
59
  * validate the field map such values to `UNSPECIFIED`.
37
60
  *
38
- * @since 1.0.0
39
- * @category Conversions
61
+ * @category converting
62
+ * @since 4.0.0
40
63
  */
41
64
  export const logLevelToSeverityNumber = (level: LogLevel.LogLevel): SeverityNumber => {
42
65
  switch (level) {
@@ -58,8 +81,10 @@ export const logLevelToSeverityNumber = (level: LogLevel.LogLevel): SeverityNumb
58
81
  }
59
82
 
60
83
  /**
61
- * @since 1.0.0
62
- * @category Constructors
84
+ * Creates an Effect logger that emits log records through the configured OpenTelemetry logger provider.
85
+ *
86
+ * @category constructors
87
+ * @since 4.0.0
63
88
  */
64
89
  export const make: Effect.Effect<
65
90
  Logger.Logger<unknown, void>,
@@ -104,8 +129,10 @@ export const make: Effect.Effect<
104
129
  })
105
130
 
106
131
  /**
107
- * @since 1.0.0
108
- * @category Layers
132
+ * Creates a layer that installs the OpenTelemetry-backed Effect logger, merging with existing loggers by default.
133
+ *
134
+ * @category layers
135
+ * @since 4.0.0
109
136
  */
110
137
  export const layer = (options: {
111
138
  /**
@@ -124,8 +151,10 @@ export const layer = (options: {
124
151
  })
125
152
 
126
153
  /**
127
- * @since 1.0.0
128
- * @category Layers
154
+ * Creates a scoped OpenTelemetry logger provider from one or more log record processors, using the current `Resource` and flushing and shutting down the provider when the layer is released.
155
+ *
156
+ * @category layers
157
+ * @since 4.0.0
129
158
  */
130
159
  export const layerLoggerProvider = (
131
160
  processor: Otel.LogRecordProcessor | NonEmptyReadonlyArray<Otel.LogRecordProcessor>,
package/src/Metrics.ts CHANGED
@@ -1,5 +1,21 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Bridges Effect metrics into OpenTelemetry by exposing the current Effect
3
+ * metric snapshot as an OpenTelemetry `MetricProducer` and registering it with
4
+ * one or more SDK `MetricReader`s. Use this module when an application already
5
+ * records metrics with Effect and needs those counters, gauges, histograms,
6
+ * frequencies, or summaries exported through OTLP, Prometheus, or another
7
+ * OpenTelemetry-compatible reader/exporter.
8
+ *
9
+ * The `layer` constructor is the usual entry point, and is also used by the
10
+ * Node and Web SDK layers when `metricReader` configuration is supplied. Metric
11
+ * readers are acquired inside the layer scope and shut down when the scope is
12
+ * released, so periodic exporters need the runtime to stay alive long enough to
13
+ * collect and export data. The exporter or backend determines whether
14
+ * cumulative or delta aggregation is expected; this module defaults to
15
+ * cumulative temporality and can be configured with `temporality: "delta"` for
16
+ * backends that require interval-based values.
17
+ *
18
+ * @since 4.0.0
3
19
  */
4
20
  import type { MetricProducer, MetricReader } from "@opentelemetry/sdk-metrics"
5
21
  import type * as Arr from "effect/Array"
@@ -21,16 +37,16 @@ import { Resource } from "./Resource.ts"
21
37
  * - `delta`: Reports changes since the last export. Each interval is
22
38
  * independent with no dependency on previous measurements.
23
39
  *
24
- * @since 1.0.0
25
- * @category Models
40
+ * @category models
41
+ * @since 4.0.0
26
42
  */
27
43
  export type TemporalityPreference = "cumulative" | "delta"
28
44
 
29
45
  /**
30
46
  * Creates an OpenTelemetry metric producer from Effect metrics.
31
47
  *
32
- * @since 1.0.0
33
- * @category Constructors
48
+ * @category constructors
49
+ * @since 4.0.0
34
50
  */
35
51
  export const makeProducer = (temporality?: TemporalityPreference): Effect.Effect<MetricProducer, never, Resource> =>
36
52
  Effect.gen(function*() {
@@ -42,8 +58,8 @@ export const makeProducer = (temporality?: TemporalityPreference): Effect.Effect
42
58
  /**
43
59
  * Registers a metric producer with one or more metric readers.
44
60
  *
45
- * @since 1.0.0
46
- * @category Constructors
61
+ * @category constructors
62
+ * @since 4.0.0
47
63
  */
48
64
  export const registerProducer = (
49
65
  self: MetricProducer,
@@ -74,7 +90,8 @@ export const registerProducer = (
74
90
  /**
75
91
  * Creates a Layer that registers a metric producer with metric readers.
76
92
  *
77
- * @example
93
+ * **Example** (Creating a metrics layer with temporality)
94
+ *
78
95
  * ```ts
79
96
  * import { Metrics } from "@effect/opentelemetry"
80
97
  * import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"
@@ -98,8 +115,8 @@ export const registerProducer = (
98
115
  * )
99
116
  * ```
100
117
  *
101
- * @since 1.0.0
102
- * @category Layers
118
+ * @category layers
119
+ * @since 4.0.0
103
120
  */
104
121
  export const layer = (
105
122
  evaluate: LazyArg<MetricReader | Arr.NonEmptyReadonlyArray<MetricReader>>,
package/src/NodeSdk.ts CHANGED
@@ -1,5 +1,27 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Provides an Effect layer for configuring OpenTelemetry in Node.js
3
+ * processes. The module wires the Effect tracer, metrics producer, and logger
4
+ * into OpenTelemetry SDK providers when span processors, metric readers, or log
5
+ * record processors are supplied, and it builds the shared resource from
6
+ * `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, and optional explicit
7
+ * service metadata.
8
+ *
9
+ * Use this module in Node services, workers, CLIs, or server runtimes that need
10
+ * Effect spans, metrics, and logs exported through OpenTelemetry processors and
11
+ * exporters. Telemetry is enabled only for the configured signal types, so an
12
+ * application can install tracing alone, metrics alone, logging alone, or any
13
+ * combination of them from the same layer.
14
+ *
15
+ * The layer is scoped. Tracer and logger providers are force-flushed and shut
16
+ * down when the scope is released, metric readers are shut down with the same
17
+ * lifecycle, and all shutdown waits are bounded by `shutdownTimeout` with a
18
+ * default of three seconds. Keep the layer scope alive for the lifetime of the
19
+ * process and release it during graceful shutdown so batched exporters have a
20
+ * chance to export final telemetry. When combining this layer with Node
21
+ * auto-instrumentations, register instrumentation before importing modules that
22
+ * should be patched, because many Node instrumentations hook module loading.
23
+ *
24
+ * @since 4.0.0
3
25
  */
4
26
  import type * as Otel from "@opentelemetry/api"
5
27
  import type { LoggerProviderConfig, LogRecordProcessor } from "@opentelemetry/sdk-logs"
@@ -18,8 +40,10 @@ import * as Resource from "./Resource.ts"
18
40
  import * as Tracer from "./Tracer.ts"
19
41
 
20
42
  /**
21
- * @since 1.0.0
22
- * @category Models
43
+ * Configuration for the Node OpenTelemetry layer, including optional tracing, metrics, logging, resource, and shutdown settings.
44
+ *
45
+ * @category models
46
+ * @since 4.0.0
23
47
  */
24
48
  export interface Configuration {
25
49
  readonly spanProcessor?: SpanProcessor | ReadonlyArray<SpanProcessor> | undefined
@@ -38,8 +62,10 @@ export interface Configuration {
38
62
  }
39
63
 
40
64
  /**
41
- * @since 1.0.0
42
- * @category Layers
65
+ * Creates a scoped Node OpenTelemetry tracer provider from one or more span processors and shuts it down when the layer is released.
66
+ *
67
+ * @category layers
68
+ * @since 4.0.0
43
69
  */
44
70
  export const layerTracerProvider = (
45
71
  processor: SpanProcessor | NonEmptyReadonlyArray<SpanProcessor>,
@@ -71,18 +97,24 @@ export const layerTracerProvider = (
71
97
  )
72
98
 
73
99
  /**
74
- * @since 1.0.0
75
- * @category Layers
100
+ * Creates a Node OpenTelemetry layer from configuration, enabling tracing, metrics, and logging only when their processors or readers are supplied.
101
+ *
102
+ * @category layers
103
+ * @since 4.0.0
76
104
  */
77
105
  export const layer: {
78
106
  /**
79
- * @since 1.0.0
80
- * @category Layers
107
+ * Creates a Node OpenTelemetry layer from configuration, enabling tracing, metrics, and logging only when their processors or readers are supplied.
108
+ *
109
+ * @category layers
110
+ * @since 4.0.0
81
111
  */
82
112
  (evaluate: LazyArg<Configuration>): Layer.Layer<Resource.Resource>
83
113
  /**
84
- * @since 1.0.0
85
- * @category Layers
114
+ * Creates a Node OpenTelemetry layer from configuration, enabling tracing, metrics, and logging only when their processors or readers are supplied.
115
+ *
116
+ * @category layers
117
+ * @since 4.0.0
86
118
  */
87
119
  <R, E>(evaluate: Effect.Effect<Configuration, E, R>): Layer.Layer<Resource.Resource, E, R>
88
120
  } = (
@@ -130,7 +162,9 @@ export const layer: {
130
162
  )
131
163
 
132
164
  /**
165
+ * Layer that provides an empty OpenTelemetry `Resource`.
166
+ *
167
+ * @category layers
133
168
  * @since 2.0.0
134
- * @category layer
135
169
  */
136
170
  export const layerEmpty: Layer.Layer<Resource.Resource> = Resource.layerEmpty