@effect/opentelemetry 4.0.0-beta.7 → 4.0.0-beta.70

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,20 +1,41 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Provides the OpenTelemetry resource used by the Effect OpenTelemetry layers.
3
+ *
4
+ * A resource describes the entity that produces telemetry, such as a service,
5
+ * process, deployment, or browser application. The tracing, metrics, logging,
6
+ * and SDK layers use this module's `Resource` service to configure providers
7
+ * and identify emitted telemetry with service-level metadata.
8
+ *
9
+ * Use `layer` when service metadata is known in code, `layerFromEnv` when
10
+ * deploying with `OTEL_SERVICE_NAME` and `OTEL_RESOURCE_ATTRIBUTES`, and
11
+ * `layerEmpty` when no resource attributes should be provided. Resource
12
+ * attributes are for stable process or service metadata, not per-span or
13
+ * per-log data. The explicit `layer` helper sets `service.name` and the
14
+ * `telemetry.sdk.*` attributes after merging custom attributes, so those keys
15
+ * are controlled by this integration. With `layerFromEnv`, `OTEL_SERVICE_NAME`
16
+ * overrides `service.name` from `OTEL_RESOURCE_ATTRIBUTES`, and additional
17
+ * attributes passed to the layer are merged last.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import type * as OtelApi from "@opentelemetry/api";
5
22
  import * as Resources from "@opentelemetry/resources";
23
+ import * as Context from "effect/Context";
6
24
  import * as Layer from "effect/Layer";
7
- import * as ServiceMap from "effect/ServiceMap";
8
- declare const Resource_base: ServiceMap.ServiceClass<Resource, "@effect/opentelemetry/Resource", Resources.Resource>;
25
+ declare const Resource_base: Context.ServiceClass<Resource, "@effect/opentelemetry/Resource", Resources.Resource>;
9
26
  /**
10
- * @since 1.0.0
11
- * @category Services
27
+ * Context service containing the OpenTelemetry `Resource` associated with emitted telemetry.
28
+ *
29
+ * @category services
30
+ * @since 4.0.0
12
31
  */
13
32
  export declare class Resource extends Resource_base {
14
33
  }
15
34
  /**
16
- * @since 1.0.0
17
- * @category Layers
35
+ * Creates a `Resource` layer from service metadata and additional OpenTelemetry attributes.
36
+ *
37
+ * @category layers
38
+ * @since 4.0.0
18
39
  */
19
40
  export declare const layer: (config: {
20
41
  readonly serviceName: string;
@@ -22,8 +43,10 @@ export declare const layer: (config: {
22
43
  readonly attributes?: OtelApi.Attributes;
23
44
  }) => Layer.Layer<Resource, never, never>;
24
45
  /**
25
- * @since 1.0.0
26
- * @category Configuration
46
+ * Converts resource configuration into OpenTelemetry attributes, adding service name, optional service version, and telemetry SDK metadata.
47
+ *
48
+ * @category configuration
49
+ * @since 4.0.0
27
50
  */
28
51
  export declare const configToAttributes: (options: {
29
52
  readonly serviceName: string;
@@ -31,13 +54,17 @@ export declare const configToAttributes: (options: {
31
54
  readonly attributes?: OtelApi.Attributes;
32
55
  }) => Record<string, string>;
33
56
  /**
34
- * @since 1.0.0
35
- * @category Layers
57
+ * Creates a `Resource` layer from OpenTelemetry environment variables, optionally merging additional attributes.
58
+ *
59
+ * @category layers
60
+ * @since 4.0.0
36
61
  */
37
62
  export declare const layerFromEnv: (additionalAttributes?: OtelApi.Attributes | undefined) => Layer.Layer<Resource>;
38
63
  /**
39
- * @since 1.0.0
40
- * @category Layers
64
+ * Layer that provides an empty OpenTelemetry resource.
65
+ *
66
+ * @category layers
67
+ * @since 4.0.0
41
68
  */
42
69
  export declare const layerEmpty: Layer.Layer<Resource, never, never>;
43
70
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../src/Resource.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAA;AAKrD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;;AAE/C;;;GAGG;AACH,qBAAa,QAAS,SAAQ,aAGO;CAAG;AAExC;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,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AM,kBAAkB,GAAI,SAAS;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAA;CACzC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAaxB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,uBACI,OAAO,CAAC,UAAU,GAClB,SAAS,KACZ,KAAK,CAAC,KAAK,CAAC,QAAQ,CA2BpB,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,UAAU,qCAGtB,CAAA"}
package/dist/Resource.js CHANGED
@@ -2,22 +2,28 @@ import * as Resources from "@opentelemetry/resources";
2
2
  import * as OtelSemConv from "@opentelemetry/semantic-conventions";
3
3
  import * as Arr from "effect/Array";
4
4
  import * as Config from "effect/Config";
5
+ import * as Context from "effect/Context";
5
6
  import * as Effect from "effect/Effect";
6
7
  import * as Layer from "effect/Layer";
7
- import * as ServiceMap from "effect/ServiceMap";
8
8
  /**
9
- * @since 1.0.0
10
- * @category Services
9
+ * Context service containing the OpenTelemetry `Resource` associated with emitted telemetry.
10
+ *
11
+ * @category services
12
+ * @since 4.0.0
11
13
  */
12
- export class Resource extends /*#__PURE__*/ServiceMap.Service()("@effect/opentelemetry/Resource") {}
14
+ export class Resource extends /*#__PURE__*/Context.Service()("@effect/opentelemetry/Resource") {}
13
15
  /**
14
- * @since 1.0.0
15
- * @category Layers
16
+ * Creates a `Resource` layer from service metadata and additional OpenTelemetry attributes.
17
+ *
18
+ * @category layers
19
+ * @since 4.0.0
16
20
  */
17
21
  export const layer = config => Layer.succeed(Resource, Resources.resourceFromAttributes(configToAttributes(config)));
18
22
  /**
19
- * @since 1.0.0
20
- * @category Configuration
23
+ * Converts resource configuration into OpenTelemetry attributes, adding service name, optional service version, and telemetry SDK metadata.
24
+ *
25
+ * @category configuration
26
+ * @since 4.0.0
21
27
  */
22
28
  export const configToAttributes = options => {
23
29
  const attributes = {
@@ -32,12 +38,14 @@ export const configToAttributes = options => {
32
38
  return attributes;
33
39
  };
34
40
  /**
35
- * @since 1.0.0
36
- * @category Layers
41
+ * Creates a `Resource` layer from OpenTelemetry environment variables, optionally merging additional attributes.
42
+ *
43
+ * @category layers
44
+ * @since 4.0.0
37
45
  */
38
46
  export const layerFromEnv = additionalAttributes => Layer.effect(Resource, Effect.gen(function* () {
39
47
  const serviceName = yield* Config.option(Config.string("OTEL_SERVICE_NAME"));
40
- const attributes = yield* Config.string("OTEL_RESOURCE_ATTRIBUTES").pipe(Config.withDefault(() => ""), Config.map(s => {
48
+ const attributes = yield* Config.string("OTEL_RESOURCE_ATTRIBUTES").pipe(Config.withDefault(""), Config.map(s => {
41
49
  const attrs = s.split(",");
42
50
  return Arr.reduce(attrs, {}, (acc, attr) => {
43
51
  const parts = attr.split("=");
@@ -57,8 +65,10 @@ export const layerFromEnv = additionalAttributes => Layer.effect(Resource, Effec
57
65
  return Resources.resourceFromAttributes(attributes);
58
66
  }).pipe(Effect.orDie));
59
67
  /**
60
- * @since 1.0.0
61
- * @category Layers
68
+ * Layer that provides an empty OpenTelemetry resource.
69
+ *
70
+ * @category layers
71
+ * @since 4.0.0
62
72
  */
63
73
  export const layerEmpty = /*#__PURE__*/Layer.succeed(Resource, /*#__PURE__*/Resources.emptyResource());
64
74
  //# sourceMappingURL=Resource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","names":["Resources","OtelSemConv","Arr","Config","Effect","Layer","ServiceMap","Resource","Service","layer","config","succeed","resourceFromAttributes","configToAttributes","options","attributes","undefined","ATTR_SERVICE_NAME","serviceName","ATTR_TELEMETRY_SDK_NAME","ATTR_TELEMETRY_SDK_LANGUAGE","globalThis","document","TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS","TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS","serviceVersion","ATTR_SERVICE_VERSION","layerFromEnv","additionalAttributes","effect","gen","option","string","pipe","withDefault","map","s","attrs","split","reduce","acc","attr","parts","length","trim","_tag","value","Object","assign","orDie","layerEmpty","emptyResource"],"sources":["../src/Resource.ts"],"sourcesContent":[null],"mappings":"AAIA,OAAO,KAAKA,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,WAAW,MAAM,qCAAqC;AAClE,OAAO,KAAKC,GAAG,MAAM,cAAc;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAE/C;;;;AAIA,OAAM,MAAOC,QAAS,sBAAQD,UAAU,CAACE,OAAO,EAG7C,CAAC,gCAAgC,CAAC;AAErC;;;;AAIA,OAAO,MAAMC,KAAK,GAAIC,MAIrB,IACCL,KAAK,CAACM,OAAO,CACXJ,QAAQ,EACRP,SAAS,CAACY,sBAAsB,CAACC,kBAAkB,CAACH,MAAM,CAAC,CAAC,CAC7D;AAEH;;;;AAIA,OAAO,MAAMG,kBAAkB,GAAIC,OAIlC,IAA4B;EAC3B,MAAMC,UAAU,GAA2B;IACzC,IAAID,OAAO,CAACC,UAAU,IAAIC,SAAS,CAAC;IACpC,CAACf,WAAW,CAACgB,iBAAiB,GAAGH,OAAO,CAACI,WAAW;IACpD,CAACjB,WAAW,CAACkB,uBAAuB,GAAG,uBAAuB;IAC9D,CAAClB,WAAW,CAACmB,2BAA2B,GAAG,OAAQC,UAAkB,CAACC,QAAQ,KAAK,WAAW,GAC1FrB,WAAW,CAACsB,mCAAmC,GAC/CtB,WAAW,CAACuB;GACjB;EACD,IAAIV,OAAO,CAACW,cAAc,EAAE;IAC1BV,UAAU,CAACd,WAAW,CAACyB,oBAAoB,CAAC,GAAGZ,OAAO,CAACW,cAAc;EACvE;EACA,OAAOV,UAAU;AACnB,CAAC;AAED;;;;AAIA,OAAO,MAAMY,YAAY,GACvBC,oB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O,MAAMC,UAAU,gBAAG7C,KAAK,CAACM,OAAO,CACrCJ,QAAQ,eACRP,SAAS,CAACmD,aAAa,EAAE,CAC1B","ignoreList":[]}
1
+ {"version":3,"file":"Resource.js","names":["Resources","OtelSemConv","Arr","Config","Context","Effect","Layer","Resource","Service","layer","config","succeed","resourceFromAttributes","configToAttributes","options","attributes","undefined","ATTR_SERVICE_NAME","serviceName","ATTR_TELEMETRY_SDK_NAME","ATTR_TELEMETRY_SDK_LANGUAGE","globalThis","document","TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS","TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS","serviceVersion","ATTR_SERVICE_VERSION","layerFromEnv","additionalAttributes","effect","gen","option","string","pipe","withDefault","map","s","attrs","split","reduce","acc","attr","parts","length","trim","_tag","value","Object","assign","orDie","layerEmpty","emptyResource"],"sources":["../src/Resource.ts"],"sourcesContent":[null],"mappings":"AAqBA,OAAO,KAAKA,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,WAAW,MAAM,qCAAqC;AAClE,OAAO,KAAKC,GAAG,MAAM,cAAc;AACnC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC;;;;;;AAMA,OAAM,MAAOC,QAAS,sBAAQH,OAAO,CAACI,OAAO,EAG1C,CAAC,gCAAgC,CAAC;AAErC;;;;;;AAMA,OAAO,MAAMC,KAAK,GAAIC,MAIrB,IACCJ,KAAK,CAACK,OAAO,CACXJ,QAAQ,EACRP,SAAS,CAACY,sBAAsB,CAACC,kBAAkB,CAACH,MAAM,CAAC,CAAC,CAC7D;AAEH;;;;;;AAMA,OAAO,MAAMG,kBAAkB,GAAIC,OAIlC,IAA4B;EAC3B,MAAMC,UAAU,GAA2B;IACzC,IAAID,OAAO,CAACC,UAAU,IAAIC,SAAS,CAAC;IAC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tC,OAAOJ,GAAG;IACZ,CAAC,CAAC;EACJ,CAAC,CAAC,CACH;EACD,IAAItB,WAAW,CAAC2B,IAAI,KAAK,MAAM,EAAE;IAC/B9B,UAAU,CAACd,WAAW,CAACgB,iBAAiB,CAAC,GAAGC,WAAW,CAAC4B,KAAK;EAC/D;EACA,IAAIlB,oBAAoB,EAAE;IACxBmB,MAAM,CAACC,MAAM,CAACjC,UAAU,EAAEa,oBAAoB,CAAC;EACjD;EACA,OAAO5B,SAAS,CAACY,sBAAsB,CAACG,UAAU,CAAC;AACrD,CAAC,CAAC,CAACkB,IAAI,CAAC5B,MAAM,CAAC4C,KAAK,CAAC,CACtB;AAEH;;;;;;AAMA,OAAO,MAAMC,UAAU,gBAAG5C,KAAK,CAACK,OAAO,CACrCJ,QAAQ,eACRP,SAAS,CAACmD,aAAa,EAAE,CAC1B","ignoreList":[]}
package/dist/Tracer.d.ts CHANGED
@@ -1,49 +1,78 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Bridges Effect tracing into OpenTelemetry by installing an Effect `Tracer`
3
+ * that creates OpenTelemetry spans, records attributes, events, links, errors,
4
+ * and status, and keeps OpenTelemetry context active while traced effects run.
5
+ * Use this module when an application already has an OpenTelemetry
6
+ * `TracerProvider`, or when the Node and Web SDK layers should expose Effect
7
+ * spans to OTLP, console, or other OpenTelemetry-compatible exporters.
8
+ *
9
+ * The layer constructors wire Effect's tracer service to either the global
10
+ * OpenTelemetry tracer provider or an explicitly provided `OtelTracer`. This
11
+ * module does not create exporters or span processors by itself, so spans are
12
+ * exported only when the provider has been configured by the application or by
13
+ * the Node/Web SDK layers. Parentage is taken from Effect spans first and can
14
+ * also attach to the active OpenTelemetry context, while `makeExternalSpan` and
15
+ * `withSpanContext` are the entry points for continuing an incoming remote
16
+ * trace. Preserve `traceFlags` and `traceState` when building external spans;
17
+ * otherwise sampling defaults to sampled and trace state cannot be propagated.
18
+ *
19
+ * @since 4.0.0
3
20
  */
4
21
  import * as Otel from "@opentelemetry/api";
5
22
  import * as Cause from "effect/Cause";
23
+ import * as Context from "effect/Context";
6
24
  import * as Effect from "effect/Effect";
7
25
  import * as Layer from "effect/Layer";
8
- import * as ServiceMap from "effect/ServiceMap";
9
26
  import * as Tracer from "effect/Tracer";
10
27
  import { Resource } from "./Resource.ts";
11
- declare const OtelTracer_base: ServiceMap.ServiceClass<OtelTracer, "@effect/opentelemetry/Tracer", Otel.Tracer>;
28
+ declare const OtelTracer_base: Context.ServiceClass<OtelTracer, "@effect/opentelemetry/Tracer", Otel.Tracer>;
12
29
  /**
13
- * @since 1.0.0
14
- * @category Services
30
+ * Context service containing the OpenTelemetry `Tracer` used to create spans for Effect tracing.
31
+ *
32
+ * @category services
33
+ * @since 4.0.0
15
34
  */
16
35
  export declare class OtelTracer extends OtelTracer_base {
17
36
  }
18
- declare const OtelTracerProvider_base: ServiceMap.ServiceClass<OtelTracerProvider, "@effect/opentelemetry/Tracer/OtelTracerProvider", Otel.TracerProvider>;
37
+ declare const OtelTracerProvider_base: Context.ServiceClass<OtelTracerProvider, "@effect/opentelemetry/Tracer/OtelTracerProvider", Otel.TracerProvider>;
19
38
  /**
20
- * @since 1.0.0
21
- * @category Services
39
+ * Context service containing the OpenTelemetry `TracerProvider` used to obtain tracers.
40
+ *
41
+ * @category services
42
+ * @since 4.0.0
22
43
  */
23
44
  export declare class OtelTracerProvider extends OtelTracerProvider_base {
24
45
  }
25
- declare const OtelTraceFlags_base: ServiceMap.ServiceClass<OtelTraceFlags, "@effect/opentelemetry/Tracer/OtelTraceFlags", Otel.TraceFlags>;
46
+ declare const OtelTraceFlags_base: Context.ServiceClass<OtelTraceFlags, "@effect/opentelemetry/Tracer/OtelTraceFlags", Otel.TraceFlags>;
26
47
  /**
27
- * @since 1.0.0
28
- * @category Services
48
+ * Context service containing OpenTelemetry trace flags used when constructing external span contexts.
49
+ *
50
+ * @category services
51
+ * @since 4.0.0
29
52
  */
30
53
  export declare class OtelTraceFlags extends OtelTraceFlags_base {
31
54
  }
32
- declare const OtelTraceState_base: ServiceMap.ServiceClass<OtelTraceState, "@effect/opentelemetry/Tracer/OtelTraceState", Otel.TraceState>;
55
+ declare const OtelTraceState_base: Context.ServiceClass<OtelTraceState, "@effect/opentelemetry/Tracer/OtelTraceState", Otel.TraceState>;
33
56
  /**
34
- * @since 1.0.0
35
- * @category Services
57
+ * Context service containing OpenTelemetry trace state used when constructing external span contexts.
58
+ *
59
+ * @category services
60
+ * @since 4.0.0
36
61
  */
37
62
  export declare class OtelTraceState extends OtelTraceState_base {
38
63
  }
39
64
  /**
40
- * @since 1.0.0
41
- * @category Constructors
65
+ * Creates an Effect `Tracer` implementation backed by the configured OpenTelemetry tracer.
66
+ *
67
+ * @category constructors
68
+ * @since 4.0.0
42
69
  */
43
70
  export declare const make: Effect.Effect<Tracer.Tracer, never, OtelTracer>;
44
71
  /**
45
- * @since 1.0.0
46
- * @category Constructors
72
+ * Creates an Effect external span from an OpenTelemetry span context, preserving trace flags and trace state when provided.
73
+ *
74
+ * @category constructors
75
+ * @since 4.0.0
47
76
  */
48
77
  export declare const makeExternalSpan: (options: {
49
78
  readonly traceId: string;
@@ -52,76 +81,95 @@ export declare const makeExternalSpan: (options: {
52
81
  readonly traceState?: string | Otel.TraceState | undefined;
53
82
  }) => Tracer.ExternalSpan;
54
83
  /**
55
- * @since 1.0.0
56
- * @category Layers
84
+ * Layer that provides the current global OpenTelemetry tracer provider.
85
+ *
86
+ * @category layers
87
+ * @since 4.0.0
57
88
  */
58
89
  export declare const layerGlobalProvider: Layer.Layer<OtelTracerProvider>;
59
90
  /**
60
- * @since 1.0.0
61
- * @category Layers
91
+ * Layer that creates an OpenTelemetry tracer from the provided tracer provider and resource metadata.
92
+ *
93
+ * @category layers
94
+ * @since 4.0.0
62
95
  */
63
96
  export declare const layerTracer: Layer.Layer<OtelTracer, never, OtelTracerProvider | Resource>;
64
97
  /**
65
- * @since 1.0.0
66
- * @category Layers
98
+ * Layer that creates an OpenTelemetry tracer from the global tracer provider and the current resource.
99
+ *
100
+ * @category layers
101
+ * @since 4.0.0
67
102
  */
68
103
  export declare const layerGlobalTracer: Layer.Layer<OtelTracer, never, Resource>;
69
104
  /**
70
- * @since 1.0.0
71
- * @category Layers
105
+ * Layer that installs an Effect tracer backed by the global OpenTelemetry tracer provider.
106
+ *
107
+ * @category layers
108
+ * @since 4.0.0
72
109
  */
73
110
  export declare const layerGlobal: Layer.Layer<OtelTracer, never, Resource>;
74
111
  /**
75
- * @since 1.0.0
76
- * @category Layers
112
+ * Layer that installs the Effect tracer using an `OtelTracer` already provided in the environment.
113
+ *
114
+ * @category layers
115
+ * @since 4.0.0
77
116
  */
78
117
  export declare const layerWithoutOtelTracer: Layer.Layer<never, never, OtelTracer>;
79
118
  /**
80
- * @since 1.0.0
81
- * @category Layers
119
+ * Layer that creates an OpenTelemetry tracer from a provider and resource, then installs it as the Effect tracer.
120
+ *
121
+ * @category layers
122
+ * @since 4.0.0
82
123
  */
83
124
  export declare const layer: Layer.Layer<OtelTracer, never, OtelTracerProvider | Resource>;
84
125
  /**
85
- * Get the current OpenTelemetry span.
126
+ * Gets the current OpenTelemetry span.
86
127
  *
87
- * Works with both the official OpenTelemetry API (via `Tracer.layer`,
88
- * `NodeSdk.layer`, etc.) and the lightweight OTLP module (`OtlpTracer.layer`).
128
+ * **Details**
89
129
  *
90
- * When using OTLP, the returned span is a wrapper that conforms to the
91
- * OpenTelemetry `Span` interface.
130
+ * This accessor works with both the official OpenTelemetry API, such as
131
+ * `Tracer.layer` and `NodeSdk.layer`, and the lightweight OTLP module, such as
132
+ * `OtlpTracer.layer`. When using OTLP, the returned span is a wrapper that
133
+ * conforms to the OpenTelemetry `Span` interface.
92
134
  *
93
- * @since 1.0.0
94
135
  * @category accessors
136
+ * @since 4.0.0
95
137
  */
96
138
  export declare const currentOtelSpan: Effect.Effect<Otel.Span, Cause.NoSuchElementError>;
97
139
  /**
98
- * Set the effect's parent span from the given opentelemetry `SpanContext`.
140
+ * Sets an effect's parent span from the given OpenTelemetry `SpanContext`.
141
+ *
142
+ * **When to use**
99
143
  *
100
- * This is handy when you set up OpenTelemetry outside of Effect and want to
101
- * attach to a parent span.
144
+ * Use this when OpenTelemetry instrumentation outside Effect has already
145
+ * produced a parent span context and an effect should continue that trace.
102
146
  *
103
- * @since 1.0.0
104
- * @category Propagation
147
+ * @category propagation
148
+ * @since 4.0.0
105
149
  */
106
150
  export declare const withSpanContext: {
107
151
  /**
108
- * Set the effect's parent span from the given opentelemetry `SpanContext`.
152
+ * Sets an effect's parent span from the given OpenTelemetry `SpanContext`.
109
153
  *
110
- * This is handy when you set up OpenTelemetry outside of Effect and want to
111
- * attach to a parent span.
154
+ * **When to use**
112
155
  *
113
- * @since 1.0.0
114
- * @category Propagation
156
+ * Use this when OpenTelemetry instrumentation outside Effect has already
157
+ * produced a parent span context and an effect should continue that trace.
158
+ *
159
+ * @category propagation
160
+ * @since 4.0.0
115
161
  */
116
162
  (spanContext: Otel.SpanContext): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
117
163
  /**
118
- * Set the effect's parent span from the given opentelemetry `SpanContext`.
164
+ * Sets an effect's parent span from the given OpenTelemetry `SpanContext`.
165
+ *
166
+ * **When to use**
119
167
  *
120
- * This is handy when you set up OpenTelemetry outside of Effect and want to
121
- * attach to a parent span.
168
+ * Use this when OpenTelemetry instrumentation outside Effect has already
169
+ * produced a parent span context and an effect should continue that trace.
122
170
  *
123
- * @since 1.0.0
124
- * @category Propagation
171
+ * @category propagation
172
+ * @since 4.0.0
125
173
  */
126
174
  <A, E, R>(self: Effect.Effect<A, E, R>, spanContext: Otel.SpanContext): Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
127
175
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Tracer.d.ts","sourceRoot":"","sources":["../src/Tracer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,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