@0xchain/telemetry 1.1.0-beta.10 → 1.1.0-beta.12

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":"Instrumentations.d.ts","sourceRoot":"","sources":["../src/Instrumentations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA4B/C,6DAA6D;AAC7D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,eAAe,mDAoElE"}
1
+ {"version":3,"file":"Instrumentations.d.ts","sourceRoot":"","sources":["../src/Instrumentations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA4B/C,6DAA6D;AAC7D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,eAAe,mDA2ElE"}
@@ -1,14 +1,14 @@
1
1
  import { NodeSDK as b } from "@opentelemetry/sdk-node";
2
2
  import { OTLPTraceExporter as v } from "@opentelemetry/exporter-trace-otlp-http";
3
3
  import { resourceFromAttributes as Y } from "@opentelemetry/resources";
4
- import { ATTR_SERVICE_VERSION as F, ATTR_SERVICE_NAME as q } from "@opentelemetry/semantic-conventions";
5
- import { SamplingDecision as d, TraceIdRatioBasedSampler as N, AlwaysOnSampler as U, BatchSpanProcessor as z } from "@opentelemetry/sdk-trace-base";
6
- import { trace as B, TraceFlags as M, propagation as I, context as V, SpanStatusCode as G } from "@opentelemetry/api";
4
+ import { ATTR_SERVICE_VERSION as F, ATTR_SERVICE_NAME as U } from "@opentelemetry/semantic-conventions";
5
+ import { SamplingDecision as R, TraceIdRatioBasedSampler as L, AlwaysOnSampler as G, BatchSpanProcessor as q } from "@opentelemetry/sdk-trace-base";
6
+ import { trace as z, TraceFlags as M, propagation as I, context as V, SpanStatusCode as B } from "@opentelemetry/api";
7
7
  import { readFile as k } from "node:fs/promises";
8
8
  import { HttpInstrumentation as j } from "@opentelemetry/instrumentation-http";
9
9
  import { UndiciInstrumentation as Q } from "@opentelemetry/instrumentation-undici";
10
- import { c as X, m as W, d as J } from "./ignore-B1KXtl12.js";
11
- const K = "deployment.environment.name", f = (t, e) => {
10
+ import { c as X, m as $, d as W } from "./ignore-B1KXtl12.js";
11
+ const J = "deployment.environment.name", f = (t, e) => {
12
12
  if (!t) return;
13
13
  const r = t[e.toLowerCase()];
14
14
  if (Array.isArray(r)) {
@@ -16,7 +16,7 @@ const K = "deployment.environment.name", f = (t, e) => {
16
16
  return typeof n == "string" ? n : void 0;
17
17
  }
18
18
  return typeof r == "string" ? r : void 0;
19
- }, T = (t) => {
19
+ }, d = (t) => {
20
20
  if (!t) return "";
21
21
  try {
22
22
  return t.startsWith("http://") || t.startsWith("https://") ? new URL(t).pathname : new URL(t, "http://localhost").pathname;
@@ -24,39 +24,41 @@ const K = "deployment.environment.name", f = (t, e) => {
24
24
  return t.split("?")[0] || t;
25
25
  }
26
26
  }, w = /* @__PURE__ */ new WeakMap();
27
- function $(t) {
28
- const e = X(t.ignore), r = (t.inspectionHeader ?? "x-inspection").toLowerCase(), n = (t.userTypeHeader ?? "x-telemetry-user-type").toLowerCase(), o = (t.requestStartHeader ?? "x-telemetry-start").toLowerCase();
27
+ function K(t) {
28
+ const e = X(t.ignore), r = (t.inspectionHeader ?? "x-inspection").toLowerCase(), n = (t.userTypeHeader ?? "x-telemetry-user-type").toLowerCase(), i = (t.requestStartHeader ?? "x-telemetry-start").toLowerCase();
29
29
  return [
30
30
  new j({
31
- startIncomingSpanHook: (s) => {
32
- const i = "headers" in s ? s.headers : void 0, a = f(i, r), c = f(i, n), u = f(i, o), l = "method" in s ? s.method : void 0, C = T("url" in s ? s.url : void 0), L = Number(u || Date.now()), m = {
33
- "telemetry.request.start_time_ms": Number.isFinite(L) ? L : Date.now()
31
+ startIncomingSpanHook: (o) => {
32
+ const s = "headers" in o ? o.headers : void 0, a = f(s, r), c = f(s, n), u = f(s, i), p = "method" in o ? o.method : void 0, l = d("url" in o ? o.url : void 0), N = Number(u || Date.now()), m = {
33
+ "telemetry.request.start_time_ms": Number.isFinite(N) ? N : Date.now()
34
34
  };
35
- return C && (m["url.path"] = C), l && (m["http.request.method"] = l), a && (m["telemetry.request.inspection"] = !0, m["http.request.header.x-inspection"] = a), c && (m["enduser.type"] = c, m["telemetry.request.user_type"] = c), m;
35
+ return l && (m["url.path"] = l), p && (m["http.request.method"] = p), a && (m["telemetry.request.inspection"] = !0, m["http.request.header.x-inspection"] = a), c && (m["enduser.type"] = c, m["telemetry.request.user_type"] = c), m;
36
36
  },
37
- requestHook: (s, i) => {
38
- const a = "headers" in i ? i.headers : void 0, c = f(a, o), u = Number(c || Date.now());
39
- w.set(s, Number.isFinite(u) ? u : Date.now());
37
+ requestHook: (o, s) => {
38
+ const a = "headers" in s ? s.headers : void 0, c = f(a, i), u = Number(c || Date.now());
39
+ w.set(o, Number.isFinite(u) ? u : Date.now());
40
+ const p = "method" in s && s.method || "GET", l = d("url" in s ? s.url : void 0);
41
+ l && o.updateName(`${p} ${l}`);
40
42
  },
41
- responseHook: (s, i) => {
42
- const a = "statusCode" in i ? i.statusCode : void 0;
43
- typeof a == "number" && (s.setAttribute("http.response.status_code", a), s.setAttribute("telemetry.response.status_code", a), a >= 500 && s.setAttribute("telemetry.request.error", !0));
44
- const c = w.get(s);
45
- typeof c == "number" && s.setAttribute("telemetry.request.duration_ms", Date.now() - c);
43
+ responseHook: (o, s) => {
44
+ const a = "statusCode" in s ? s.statusCode : void 0;
45
+ typeof a == "number" && (o.setAttribute("http.response.status_code", a), o.setAttribute("telemetry.response.status_code", a), a >= 500 && o.setAttribute("telemetry.request.error", !0));
46
+ const c = w.get(o);
47
+ typeof c == "number" && o.setAttribute("telemetry.request.duration_ms", Date.now() - c);
46
48
  },
47
- ignoreIncomingRequestHook: (s) => {
48
- const i = "url" in s ? s.url : void 0, a = T(i), c = "method" in s ? s.method : void 0;
49
+ ignoreIncomingRequestHook: (o) => {
50
+ const s = "url" in o ? o.url : void 0, a = d(s), c = "method" in o ? o.method : void 0;
49
51
  return e(a, c);
50
52
  },
51
- ignoreOutgoingRequestHook: (s) => {
52
- const i = typeof s == "string" ? s : s.path || "";
53
- return e(T(i));
53
+ ignoreOutgoingRequestHook: (o) => {
54
+ const s = typeof o == "string" ? o : o.path || "";
55
+ return e(d(s));
54
56
  }
55
57
  }),
56
58
  new Q()
57
59
  ];
58
60
  }
59
- const R = (t) => {
61
+ const _ = (t) => {
60
62
  if (typeof t == "string") return t;
61
63
  if (Array.isArray(t)) {
62
64
  const e = t[0];
@@ -72,28 +74,28 @@ const R = (t) => {
72
74
  const e = t[0];
73
75
  return x(e);
74
76
  }
75
- }, E = (t, e) => {
77
+ }, h = (t, e) => {
76
78
  for (const r of e)
77
79
  if (r in t)
78
80
  return t[r];
79
81
  }, Z = (t) => {
80
- const e = E(t, ["url.path", "http.target", "http.route"]), r = E(t, ["http.request.method", "http.method"]), n = E(t, ["enduser.type", "telemetry.request.user_type"]), o = E(t, [
82
+ const e = h(t, ["url.path", "http.target", "http.route"]), r = h(t, ["http.request.method", "http.method"]), n = h(t, ["enduser.type", "telemetry.request.user_type"]), i = h(t, [
81
83
  "http.response.status_code",
82
84
  "http.status_code",
83
85
  "telemetry.response.status_code"
84
- ]), s = E(t, [
86
+ ]), o = h(t, [
85
87
  "telemetry.request.inspection",
86
88
  "http.request.header.x-inspection",
87
89
  "x-inspection"
88
- ]), i = s === !0 || s === "true" || s === "1" || s === 1;
90
+ ]), s = o === !0 || o === "true" || o === "1" || o === 1;
89
91
  return {
90
- path: R(e),
91
- method: R(r),
92
- userType: R(n),
93
- statusCode: x(o),
94
- inspection: i
92
+ path: _(e),
93
+ method: _(r),
94
+ userType: _(n),
95
+ statusCode: x(i),
96
+ inspection: s
95
97
  };
96
- }, O = (t, e) => !t || !(e != null && e.length) ? !1 : e.some((r) => r.toLowerCase() === t.toLowerCase()), tt = (t, e) => !t || !(e != null && e.length) ? !1 : e.some((r) => W(r, t)), et = (t, e) => {
98
+ }, O = (t, e) => !t || !(e != null && e.length) ? !1 : e.some((r) => r.toLowerCase() === t.toLowerCase()), tt = (t, e) => !t || !(e != null && e.length) ? !1 : e.some((r) => $(r, t)), et = (t, e) => {
97
99
  const r = t.when;
98
100
  if (!r) return !0;
99
101
  if (r.inspection !== void 0 && r.inspection !== e.inspection || r.path && !tt(e.path, r.path) || r.method && !O(e.method, r.method) || r.userType && !O(e.userType, r.userType))
@@ -104,48 +106,48 @@ const R = (t) => {
104
106
  } else if (r.statusCode && r.statusCode.length)
105
107
  return !1;
106
108
  return !(typeof r.minStatusCode == "number" && (typeof e.statusCode != "number" || e.statusCode < r.minStatusCode) || typeof r.maxStatusCode == "number" && (typeof e.statusCode != "number" || e.statusCode > r.maxStatusCode));
107
- }, _ = (t) => Math.max(0, Math.min(1, t)), rt = (t, e, r) => {
108
- if (!(t != null && t.length)) return _(r);
109
+ }, g = (t) => Math.max(0, Math.min(1, t)), rt = (t, e, r) => {
110
+ if (!(t != null && t.length)) return g(r);
109
111
  for (const n of t)
110
112
  if (et(n, e))
111
- return _(n.ratio);
112
- return _(r);
113
+ return g(n.ratio);
114
+ return g(r);
113
115
  }, A = /* @__PURE__ */ new Map(), nt = (t) => {
114
116
  if (t <= 0)
115
- return new N(0);
117
+ return new L(0);
116
118
  if (t >= 1)
117
- return new U();
119
+ return new G();
118
120
  const e = Number(t.toFixed(6)), r = A.get(e);
119
121
  if (r) return r;
120
- const n = new N(e);
122
+ const n = new L(e);
121
123
  return A.set(e, n), n;
122
- }, st = (t) => ({
123
- shouldSample(e, r, n, o, s, i) {
124
- const a = B.getSpanContext(e);
124
+ }, ot = (t) => ({
125
+ shouldSample(e, r, n, i, o, s) {
126
+ const a = z.getSpanContext(e);
125
127
  if (a)
126
- return (a.traceFlags & M.SAMPLED) === M.SAMPLED ? { decision: d.RECORD_AND_SAMPLED } : { decision: d.NOT_RECORD };
127
- const c = t.getConfig(), u = Z(s);
128
+ return (a.traceFlags & M.SAMPLED) === M.SAMPLED ? { decision: R.RECORD_AND_SAMPLED } : { decision: R.NOT_RECORD };
129
+ const c = t.getConfig(), u = Z(o);
128
130
  if (u.inspection)
129
- return { decision: d.RECORD_AND_SAMPLED };
130
- const l = rt(
131
+ return { decision: R.RECORD_AND_SAMPLED };
132
+ const p = rt(
131
133
  c.samplingRules,
132
134
  u,
133
135
  c.defaultSamplingRatio ?? 0.01
134
136
  );
135
- return nt(l).shouldSample(e, r, n, o, s, i);
137
+ return nt(p).shouldSample(e, r, n, i, o, s);
136
138
  },
137
139
  toString: () => "RuleBasedSampler"
138
- }), ot = (t) => t;
139
- let h, p;
140
- const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.split(",").map((e) => e.trim()).filter(Boolean)) ?? [], it = (t) => {
140
+ }), st = (t) => t;
141
+ let T, E;
142
+ const S = (t) => Array.from(new Set(t)), y = (t) => (t == null ? void 0 : t.split(",").map((e) => e.trim()).filter(Boolean)) ?? [], it = (t) => {
141
143
  if (!t) return;
142
144
  const e = {};
143
145
  for (const r of t.split(",")) {
144
- const [n, ...o] = r.split("="), s = n == null ? void 0 : n.trim();
145
- s && (e[s] = o.join("=").trim());
146
+ const [n, ...i] = r.split("="), o = n == null ? void 0 : n.trim();
147
+ o && (e[o] = i.join("=").trim());
146
148
  }
147
149
  return e;
148
- }, y = (t) => {
150
+ }, C = (t) => {
149
151
  if (t)
150
152
  try {
151
153
  return JSON.parse(t);
@@ -156,19 +158,19 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
156
158
  if (t)
157
159
  try {
158
160
  const e = await k(t, "utf8");
159
- return y(e);
161
+ return C(e);
160
162
  } catch {
161
163
  return;
162
164
  }
163
165
  }, H = (t, e) => {
164
- const r = g([...(t == null ? void 0 : t.paths) ?? [], ...(e == null ? void 0 : e.paths) ?? []]), n = g([
166
+ const r = S([...(t == null ? void 0 : t.paths) ?? [], ...(e == null ? void 0 : e.paths) ?? []]), n = S([
165
167
  ...(t == null ? void 0 : t.extensions) ?? [],
166
168
  ...(e == null ? void 0 : e.extensions) ?? []
167
- ]), o = g([...(t == null ? void 0 : t.methods) ?? [], ...(e == null ? void 0 : e.methods) ?? []]);
169
+ ]), i = S([...(t == null ? void 0 : t.methods) ?? [], ...(e == null ? void 0 : e.methods) ?? []]);
168
170
  return {
169
171
  paths: r.length ? r : void 0,
170
172
  extensions: n.length ? n : void 0,
171
- methods: o.length ? o : void 0
173
+ methods: i.length ? i : void 0
172
174
  };
173
175
  }, ct = (t) => {
174
176
  if (t != null && t.length)
@@ -177,7 +179,7 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
177
179
  ratio: Number.isFinite(e.ratio) ? Math.max(0, Math.min(1, e.ratio)) : 0
178
180
  })).filter((e) => e.ratio >= 0);
179
181
  }, ut = async (t = process.env) => {
180
- const e = await at(t.TELEMETRY_CONFIG_FILE), r = S(t.TELEMETRY_IGNORE_PATHS), n = S(t.TELEMETRY_IGNORE_EXTENSIONS), o = S(t.TELEMETRY_IGNORE_METHODS), s = y(t.TELEMETRY_SAMPLING_RULES), i = typeof (e == null ? void 0 : e.samplingRules) == "string" ? y(e.samplingRules) : e == null ? void 0 : e.samplingRules, a = {
182
+ const e = await at(t.TELEMETRY_CONFIG_FILE), r = y(t.TELEMETRY_IGNORE_PATHS), n = y(t.TELEMETRY_IGNORE_EXTENSIONS), i = y(t.TELEMETRY_IGNORE_METHODS), o = C(t.TELEMETRY_SAMPLING_RULES), s = typeof (e == null ? void 0 : e.samplingRules) == "string" ? C(e.samplingRules) : e == null ? void 0 : e.samplingRules, a = {
181
183
  serviceName: t.OTEL_SERVICE_NAME || t.TELEMETRY_SERVICE_NAME,
182
184
  serviceVersion: t.OTEL_SERVICE_VERSION || t.TELEMETRY_SERVICE_VERSION,
183
185
  environment: t.OTEL_RESOURCE_ATTRIBUTES || t.TELEMETRY_ENVIRONMENT || (t.VERCEL ? t.VERCEL_ENV : void 0),
@@ -187,25 +189,25 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
187
189
  inspectionHeader: t.TELEMETRY_INSPECTION_HEADER,
188
190
  userTypeHeader: t.TELEMETRY_USER_TYPE_HEADER,
189
191
  requestStartHeader: t.TELEMETRY_REQUEST_START_HEADER,
190
- samplingRules: s || i,
191
- ignore: r.length || n.length || o.length ? {
192
+ samplingRules: o || s,
193
+ ignore: r.length || n.length || i.length ? {
192
194
  paths: r.length ? r : void 0,
193
195
  extensions: n.length ? n : void 0,
194
- methods: o.length ? o : void 0
196
+ methods: i.length ? i : void 0
195
197
  } : void 0
196
198
  };
197
199
  return e && typeof e == "object" ? { ...e, ...a } : a;
198
200
  }, mt = (t) => {
199
201
  if (!t) return process.env.NODE_ENV || "development";
200
202
  if (t.includes("deployment.environment")) {
201
- const r = t.split(",").find((o) => o.includes("deployment.environment"));
203
+ const r = t.split(",").find((i) => i.includes("deployment.environment"));
202
204
  if (!r) return t;
203
205
  const [, n] = r.split("=");
204
206
  return (n == null ? void 0 : n.trim()) || t;
205
207
  }
206
208
  return t;
207
209
  }, pt = (t, e) => {
208
- var n, o;
210
+ var n, i;
209
211
  const r = [
210
212
  { name: "inspection", ratio: 1, when: { inspection: !0 } },
211
213
  { name: "error", ratio: 1, when: { minStatusCode: 500 } }
@@ -214,27 +216,27 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
214
216
  name: "critical-path",
215
217
  ratio: 1,
216
218
  when: { path: t.criticalPaths }
217
- }), (o = t == null ? void 0 : t.criticalUserTypes) != null && o.length && r.push({
219
+ }), (i = t == null ? void 0 : t.criticalUserTypes) != null && i.length && r.push({
218
220
  name: "critical-user",
219
221
  ratio: 1,
220
222
  when: { userType: t.criticalUserTypes }
221
223
  }), t != null && t.pathSampling)
222
- for (const [s, i] of Object.entries(t.pathSampling))
224
+ for (const [o, s] of Object.entries(t.pathSampling))
223
225
  r.push({
224
- name: `path:${s}`,
225
- ratio: i,
226
- when: { path: [s] }
226
+ name: `path:${o}`,
227
+ ratio: s,
228
+ when: { path: [o] }
227
229
  });
228
230
  if (t != null && t.userTypeSampling)
229
- for (const [s, i] of Object.entries(t.userTypeSampling))
231
+ for (const [o, s] of Object.entries(t.userTypeSampling))
230
232
  r.push({
231
- name: `user:${s}`,
232
- ratio: i,
233
- when: { userType: [s] }
233
+ name: `user:${o}`,
234
+ ratio: s,
235
+ when: { userType: [o] }
234
236
  });
235
237
  return r.push({ name: "default", ratio: e }), r;
236
238
  }, D = (t) => {
237
- const e = mt(t.environment), r = H(J, t.ignore), n = typeof t.defaultSamplingRatio == "number" ? Math.max(0, Math.min(1, t.defaultSamplingRatio)) : 0.01, o = ct(t.samplingRules) ?? pt(t.layeredSampling, n);
239
+ const e = mt(t.environment), r = H(W, t.ignore), n = typeof t.defaultSamplingRatio == "number" ? Math.max(0, Math.min(1, t.defaultSamplingRatio)) : 0.01, i = ct(t.samplingRules) ?? pt(t.layeredSampling, n);
238
240
  return {
239
241
  ...t,
240
242
  serviceName: t.serviceName || "unknown-service",
@@ -242,7 +244,7 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
242
244
  environment: e,
243
245
  defaultSamplingRatio: n,
244
246
  ignore: r,
245
- samplingRules: o,
247
+ samplingRules: i,
246
248
  inspectionHeader: t.inspectionHeader ?? "x-inspection",
247
249
  userTypeHeader: t.userTypeHeader ?? "x-telemetry-user-type",
248
250
  requestStartHeader: t.requestStartHeader ?? "x-telemetry-start",
@@ -266,12 +268,12 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
266
268
  });
267
269
  }
268
270
  };
269
- }, lt = (t) => t[0] * 1e3 + t[1] / 1e6, ft = (t, e) => {
271
+ }, lt = (t) => t[0] * 1e3 + t[1] / 1e6, ht = (t, e) => {
270
272
  for (const r of e) {
271
273
  const n = t.attributes[r];
272
274
  if (typeof n == "number") return n;
273
275
  }
274
- }, ht = (t) => {
276
+ }, ft = (t) => {
275
277
  const e = t.events.find((n) => n.name === "exception");
276
278
  if (!(e != null && e.attributes)) return;
277
279
  const r = e.attributes["exception.message"];
@@ -282,68 +284,68 @@ const g = (t) => Array.from(new Set(t)), S = (t) => (t == null ? void 0 : t.spli
282
284
  onEnd: (t) => {
283
285
  const e = lt(t.duration);
284
286
  t.attributes["telemetry.request.duration_ms"] = Math.round(e), typeof t.attributes["telemetry.request.start_time_ms"] != "number" && (t.attributes["telemetry.request.start_time_ms"] = Date.now() - Math.round(e));
285
- const r = ft(t, [
287
+ const r = ht(t, [
286
288
  "http.response.status_code",
287
289
  "http.status_code",
288
290
  "telemetry.response.status_code"
289
291
  ]);
290
- if (typeof r == "number" && (t.attributes["telemetry.response.status_code"] = r), t.status.code === G.ERROR || typeof r == "number" && r >= 500) {
292
+ if (typeof r == "number" && (t.attributes["telemetry.response.status_code"] = r), t.status.code === B.ERROR || typeof r == "number" && r >= 500) {
291
293
  t.attributes["telemetry.request.error"] = !0;
292
- const o = t.status.message || ht(t);
293
- o && (t.attributes["telemetry.request.error_message"] = o);
294
+ const i = t.status.message || ft(t);
295
+ i && (t.attributes["telemetry.request.error_message"] = i);
294
296
  }
295
297
  },
296
298
  shutdown: () => Promise.resolve(),
297
299
  forceFlush: () => Promise.resolve()
298
300
  }), wt = async (t) => {
299
301
  const e = await P(t);
300
- p = await Et(e);
302
+ E = await Et(e);
301
303
  const r = process.env, n = {
302
- [q]: e.serviceName,
304
+ [U]: e.serviceName,
303
305
  [F]: e.serviceVersion || "1.0.0",
304
- [K]: e.environment || r.VERCEL_ENV || r.NODE_ENV || "development"
306
+ [J]: e.environment || r.VERCEL_ENV || r.NODE_ENV || "development"
305
307
  };
306
308
  r.VERCEL && (r.VERCEL_REGION && (n["vercel.region"] = r.VERCEL_REGION), r.NEXT_RUNTIME && (n["vercel.runtime"] = r.NEXT_RUNTIME), r.VERCEL_GIT_COMMIT_SHA && (n["vercel.sha"] = r.VERCEL_GIT_COMMIT_SHA), r.VERCEL_URL && (n["vercel.host"] = r.VERCEL_URL), r.VERCEL_BRANCH_URL && (n["vercel.branch_host"] = r.VERCEL_BRANCH_URL), r.VERCEL_DEPLOYMENT_ID && (n["vercel.deployment_id"] = r.VERCEL_DEPLOYMENT_ID));
307
- const o = Y(n), s = new v(e), i = ot(s), a = [
309
+ const i = Y(n), o = new v(e), s = st(o), a = [
308
310
  dt(),
309
- new z(i, {
311
+ new q(s, {
310
312
  scheduledDelayMillis: e.scheduledDelayMillis,
311
313
  maxQueueSize: e.maxQueueSize,
312
314
  maxExportBatchSize: e.maxExportBatchSize,
313
315
  exportTimeoutMillis: e.exporterTimeoutMillis
314
316
  })
315
317
  ];
316
- h = new b({
318
+ T = new b({
317
319
  serviceName: e.serviceName,
318
- resource: o,
320
+ resource: i,
319
321
  spanProcessors: a,
320
- sampler: st(p),
321
- instrumentations: $(e)
322
+ sampler: ot(E),
323
+ instrumentations: K(e)
322
324
  });
323
325
  try {
324
- await h.start();
326
+ await T.start();
325
327
  } catch (c) {
326
328
  console.warn("Telemetry start failed:", c);
327
329
  }
328
- return p;
330
+ return E;
329
331
  }, Ot = (t) => {
330
- p == null || p.updateConfig(t);
332
+ E == null || E.updateConfig(t);
331
333
  }, At = (t) => (I.inject(V.active(), t), t), It = (t = fetch) => async (e, r) => {
332
- const n = (r == null ? void 0 : r.headers) ?? (e instanceof Request ? e.headers : void 0), o = new Headers(n);
333
- return I.inject(V.active(), o, {
334
- set: (s, i, a) => {
335
- s.set(i, a);
334
+ const n = (r == null ? void 0 : r.headers) ?? (e instanceof Request ? e.headers : void 0), i = new Headers(n);
335
+ return I.inject(V.active(), i, {
336
+ set: (o, s, a) => {
337
+ o.set(s, a);
336
338
  }
337
- }), t(e, { ...r, headers: o });
339
+ }), t(e, { ...r, headers: i });
338
340
  }, Vt = async () => {
339
- h && await h.shutdown();
341
+ T && await T.shutdown();
340
342
  };
341
343
  export {
342
344
  Z as buildSamplingContextFromAttributes,
343
345
  X as createIgnoreMatcher,
344
346
  It as createPropagatingFetch,
345
347
  Et as createTelemetryRuntime,
346
- J as defaultIgnoreConfig,
348
+ W as defaultIgnoreConfig,
347
349
  At as injectTraceHeaders,
348
350
  ut as loadTelemetryConfigFromEnv,
349
351
  et as matchSamplingRule,
@@ -1,4 +1,4 @@
1
- import { startTelemetry as a } from "./index";
1
+ import { startTelemetry as a } from "./index.js";
2
2
  const o = async (t) => {
3
3
  const e = typeof t == "function" ? await t() : t;
4
4
  await a(e ?? {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xchain/telemetry",
3
- "version": "1.1.0-beta.10",
3
+ "version": "1.1.0-beta.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
File without changes
File without changes