@vercel/otel 1.3.1-e26a383e-20240221194233 → 1.4.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.
@@ -1,12 +1,24 @@
1
- import type { TracerProvider } from "@opentelemetry/api";
1
+ import type { Attributes, TracerProvider } from "@opentelemetry/api";
2
2
  import type { Instrumentation, InstrumentationConfig } from "@opentelemetry/instrumentation";
3
3
  /**
4
4
  * Configuration for the "fetch" instrumentation.
5
+ *
6
+ * Some of this configuration can be overriden on a per-fetch call basis by
7
+ * using the `opentelemetry` property in the `RequestInit` object (requires Next 14.1.1 or above).
8
+ * This property can include:
9
+ * - `ignore`: boolean - whether to ignore the fetch call from tracing. Overrides
10
+ * `ignoreUrls`.
11
+ * - `propagateContext: boolean`: overrides `propagateContextUrls` for this call.
12
+ * - `spanName: string`: overrides the computed span name for this call.
13
+ * - `attributes: Attributes`: overrides the computed attributes for this call.
5
14
  */
6
15
  export interface FetchInstrumentationConfig extends InstrumentationConfig {
7
16
  /**
8
17
  * A set of URL matchers (string prefix or regex) that should be ignored from tracing.
9
- * By default all URLs are traced. Example: `fetch: { ignoreUrls: [/example.com/] }`.
18
+ * By default all URLs are traced.
19
+ * Can be overriden by the `opentelemetry.ignore` property in the `RequestInit` object.
20
+ *
21
+ * Example: `fetch: { ignoreUrls: [/example.com/] }`.
10
22
  */
11
23
  ignoreUrls?: (string | RegExp)[];
12
24
  /**
@@ -15,6 +27,8 @@ export interface FetchInstrumentationConfig extends InstrumentationConfig {
15
27
  * By default the context is propagated _only_ for the
16
28
  * [deployment URLs](https://vercel.com/docs/deployments/generated-urls), all
17
29
  * other URLs should be enabled explicitly.
30
+ * Can be overriden by the `opentelemetry.propagateContext` property in the `RequestInit` object.
31
+ *
18
32
  * Example: `fetch: { propagateContextUrls: [ /my.api/ ] }`.
19
33
  */
20
34
  propagateContextUrls?: (string | RegExp)[];
@@ -22,14 +36,27 @@ export interface FetchInstrumentationConfig extends InstrumentationConfig {
22
36
  * A set of URL matchers (string prefix or regex) for which the tracing context
23
37
  * should not be propagated (see [`propagators`](Configuration#propagators)). This allows you to exclude a
24
38
  * subset of URLs allowed by the [`propagateContextUrls`](FetchInstrumentationConfig#propagateContextUrls).
39
+ * Can be overriden by the `opentelemetry.propagateContext` property in the `RequestInit` object.
25
40
  */
26
41
  dontPropagateContextUrls?: (string | RegExp)[];
27
42
  /**
28
43
  * A string for the "resource.name" attribute that can include attribute expressions in `{}`.
44
+ * Can be overriden by the `opentelemetry.attributes` property in the `RequestInit` object.
45
+ *
29
46
  * Example: `fetch: { resourceNameTemplate: "{http.host}" }`.
30
47
  */
31
48
  resourceNameTemplate?: string;
32
49
  }
50
+ declare global {
51
+ interface RequestInit {
52
+ opentelemetry?: {
53
+ ignore?: boolean;
54
+ propagateContext?: boolean;
55
+ spanName?: string;
56
+ attributes?: Attributes;
57
+ };
58
+ }
59
+ }
33
60
  export declare class FetchInstrumentation implements Instrumentation {
34
61
  instrumentationName: string;
35
62
  instrumentationVersion: string;
@@ -56,6 +56,7 @@ export interface Configuration {
56
56
  * Use the "auto" value to include all default propagators.
57
57
  * By default, `@vercel/otel` configures [W3C Trace Context](https://www.w3.org/TR/trace-context/) propagator.
58
58
  * This option can be also configured via the [`OTEL_PROPAGATORS`](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) environment variable.
59
+ *
59
60
  * Example: `{ propagators: ["auto", new MyPropagator()] }`
60
61
  */
61
62
  propagators?: PropagatorOrName[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/otel",
3
- "version": "1.3.1-e26a383e-20240221194233",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"