@voltro/plugin-datadog 0.32.0 → 0.34.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.
@@ -5,7 +5,7 @@ property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-datadog itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (77 packages).
8
+ Generated from the resolved runtime dependency closure (76 packages).
9
9
 
10
10
  ---
11
11
 
@@ -1697,34 +1697,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1697
1697
  SOFTWARE.
1698
1698
  ```
1699
1699
 
1700
- ## @effect/opentelemetry@0.64.0
1701
-
1702
- License: MIT
1703
-
1704
- ```
1705
- MIT License
1706
-
1707
- Copyright (c) 2020-present The Contributors
1708
-
1709
- Permission is hereby granted, free of charge, to any person obtaining a copy
1710
- of this software and associated documentation files (the "Software"), to deal
1711
- in the Software without restriction, including without limitation the rights
1712
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1713
- copies of the Software, and to permit persons to whom the Software is
1714
- furnished to do so, subject to the following conditions:
1715
-
1716
- The above copyright notice and this permission notice shall be included in all
1717
- copies or substantial portions of the Software.
1718
-
1719
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1720
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1721
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1722
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1723
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1724
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1725
- SOFTWARE.
1726
- ```
1727
-
1728
1700
  ## @effect/platform-node@0.108.0
1729
1701
 
1730
1702
  License: MIT
package/dist/index.js CHANGED
@@ -2,17 +2,17 @@ import { hostname as e } from "node:os";
2
2
  import { Effect as t } from "effect";
3
3
  import { pluginEnv as n } from "@voltro/env";
4
4
  import { addSink as r, createLogger as i, makeBufferedSink as a } from "@voltro/logger";
5
- import { definePlugin as o } from "@voltro/protocol";
6
- import { snapshotMetrics as s } from "@voltro/runtime";
5
+ import { definePlugin as o, pluginInstanceName as s } from "@voltro/protocol";
6
+ import { snapshotMetrics as c } from "@voltro/runtime";
7
7
  //#region src/format.ts
8
- var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t) => {
8
+ var l = 3, u = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), d = (e, t) => {
9
9
  let n = t.prefix ?? "", r = t.globalTags ?? [], i = t.host === void 0 ? void 0 : [{
10
10
  type: "host",
11
11
  name: t.host
12
12
  }], a = [], o = (e, o, s) => {
13
13
  a.push({
14
14
  metric: `${n}${e}`,
15
- type: c,
15
+ type: l,
16
16
  points: [{
17
17
  timestamp: t.timestamp,
18
18
  value: o
@@ -22,7 +22,7 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
22
22
  });
23
23
  };
24
24
  for (let t of e) {
25
- let e = l(t.labels);
25
+ let e = u(t.labels);
26
26
  if (t.type === "counter" || t.type === "gauge") o(t.name, t.value ?? 0, e);
27
27
  else if (t.type === "histogram") {
28
28
  let n = t.count ?? 0, r = t.sum ?? 0;
@@ -30,14 +30,14 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
30
30
  }
31
31
  }
32
32
  return { series: a };
33
- }, d = (e, t = 16) => {
33
+ }, f = (e, t = 16) => {
34
34
  let n = e.length > t ? e.slice(-t) : e;
35
35
  try {
36
36
  return BigInt(`0x${n}`).toString(10);
37
37
  } catch {
38
38
  return "";
39
39
  }
40
- }, f = (e, t = {}) => {
40
+ }, p = (e, t = {}) => {
41
41
  let n = typeof e.fields.traceId == "string" ? e.fields.traceId : void 0, r = typeof e.fields.spanId == "string" ? e.fields.spanId : void 0, { traceId: i, spanId: a, ...o } = e.fields;
42
42
  return {
43
43
  message: e.message,
@@ -50,11 +50,11 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
50
50
  ...o,
51
51
  ...n ? {
52
52
  trace_id: n,
53
- "dd.trace_id": d(n)
53
+ "dd.trace_id": f(n)
54
54
  } : {},
55
- ...r ? { "dd.span_id": d(r) } : {}
55
+ ...r ? { "dd.span_id": f(r) } : {}
56
56
  };
57
- }, p = (e, t = {}) => e.map((e) => f(e, t)), m = n([
57
+ }, m = (e, t = {}) => e.map((e) => p(e, t)), h = n([
58
58
  {
59
59
  name: "DD_API_KEY",
60
60
  required: !1,
@@ -91,17 +91,17 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
91
91
  secret: !1,
92
92
  description: "Datadog Agent OTLP base URL for traces; defaults to http://localhost:4318."
93
93
  }
94
- ]), h = i({ scope: "plugin:datadog" }), g = (n = {}) => {
95
- let i = m.read("DD_API_KEY", n.apiKey), c = m.read("DD_SITE", n.site) ?? "datadoghq.com", l = n.intervalMs ?? 3e4, d = n.logsIntervalMs ?? 5e3, f = m.read("DD_SERVICE", n.service), g = m.read("DD_ENV", n.env), _ = m.read("DD_VERSION", n.version), v = m.read("DD_TRACE_AGENT_URL", n.agentUrl) ?? "http://localhost:4318", y = n.host ?? e(), b = `https://api.${c}/api/v2/series`, x = `https://http-intake.logs.${c}/api/v2/logs`, S, C, w, T = async () => {
94
+ ]), g = i({ scope: "plugin:datadog" }), _ = (n = {}) => {
95
+ let i = h.read("DD_API_KEY", n.apiKey), l = h.read("DD_SITE", n.site) ?? "datadoghq.com", u = n.intervalMs ?? 3e4, f = n.logsIntervalMs ?? 5e3, p = h.read("DD_SERVICE", n.service), _ = h.read("DD_ENV", n.env), v = h.read("DD_VERSION", n.version), y = h.read("DD_TRACE_AGENT_URL", n.agentUrl) ?? "http://localhost:4318", b = n.host ?? e(), x = `https://api.${l}/api/v2/series`, S = `https://http-intake.logs.${l}/api/v2/logs`, C, w, T, E = async () => {
96
96
  try {
97
- let e = await t.runPromise(s);
97
+ let e = await t.runPromise(c);
98
98
  if (e.length === 0) return;
99
- let r = u(e, {
99
+ let r = d(e, {
100
100
  timestamp: Math.floor(Date.now() / 1e3),
101
- host: y,
101
+ host: b,
102
102
  ...n.prefix === void 0 ? {} : { prefix: n.prefix },
103
103
  ...n.tags === void 0 ? {} : { globalTags: n.tags }
104
- }), a = await fetch(b, {
104
+ }), a = await fetch(x, {
105
105
  method: "POST",
106
106
  headers: {
107
107
  "content-type": "application/json",
@@ -109,18 +109,18 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
109
109
  },
110
110
  body: JSON.stringify(r)
111
111
  });
112
- a.ok || h.warn("datadog series POST failed", {
112
+ a.ok || g.warn("datadog series POST failed", {
113
113
  status: a.status,
114
114
  series: r.series.length
115
115
  });
116
116
  } catch (e) {
117
- h.warn("datadog metrics flush errored", { error: String(e) });
117
+ g.warn("datadog metrics flush errored", { error: String(e) });
118
118
  }
119
- }, E = async (e) => {
120
- let t = p(e, {
121
- ...f ? { service: f } : {},
119
+ }, D = async (e) => {
120
+ let t = m(e, {
121
+ ...p ? { service: p } : {},
122
122
  ...n.tags ? { tags: n.tags } : {}
123
- }), r = await fetch(x, {
123
+ }), r = await fetch(S, {
124
124
  method: "POST",
125
125
  headers: {
126
126
  "content-type": "application/json",
@@ -128,43 +128,46 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
128
128
  },
129
129
  body: JSON.stringify(t)
130
130
  });
131
- r.ok || h.warn("datadog logs POST failed", {
131
+ r.ok || g.warn("datadog logs POST failed", {
132
132
  status: r.status,
133
133
  count: e.length
134
134
  });
135
- }, D = () => ({
136
- ...f ? { "service.name": f } : {},
137
- ...g ? { "deployment.environment": g } : {},
138
- ..._ ? { "service.version": _ } : {}
139
- }), O = !!i, k = !!n.logs && !!i, A = (() => {
135
+ }, O = () => ({
136
+ ...p ? { "service.name": p } : {},
137
+ ..._ ? { "deployment.environment": _ } : {},
138
+ ...v ? { "service.version": v } : {}
139
+ }), k = !!i, A = !!n.logs && !!i, j = (() => {
140
140
  try {
141
- return new URL(v).host;
141
+ return new URL(y).host;
142
142
  } catch {
143
143
  return "localhost";
144
144
  }
145
- })(), j = [`network:outbound:${c}`, ...n.traces || n.profiling ? [`network:outbound:${A}`] : []];
145
+ })(), M = [`network:outbound:${l}`, ...n.traces || n.profiling ? [`network:outbound:${j}`] : []];
146
146
  return o({
147
- name: n.name ? `@voltro/plugin-datadog#${n.name}` : "@voltro/plugin-datadog",
147
+ name: s({
148
+ base: "@voltro/plugin-datadog",
149
+ instance: n.name
150
+ }),
148
151
  description: "Deep Datadog integration — metrics + logs + traces (OTLP→Agent) + profiling, trace-correlated.",
149
- permissions: j,
150
- declaredEnv: m.declared,
152
+ permissions: M,
153
+ declaredEnv: h.declared,
151
154
  contributeObservability: async (e) => {
152
155
  if (n.profiling) try {
153
156
  (await import("dd-trace")).default.init({
154
157
  profiling: !0,
155
158
  tracing: !1,
156
- ...f ? { service: f } : {},
157
- ...g ? { env: g } : {},
158
- ..._ ? { version: _ } : {}
159
+ ...p ? { service: p } : {},
160
+ ..._ ? { env: _ } : {},
161
+ ...v ? { version: v } : {}
159
162
  });
160
163
  } catch {
161
164
  e.logger.warn("datadog profiling requested but dd-trace is not installed");
162
165
  }
163
- let t = D();
166
+ let t = O();
164
167
  if (!n.traces) return Object.keys(t).length > 0 ? { resourceAttributes: t } : void 0;
165
168
  try {
166
- let { BatchSpanProcessor: n } = await import("@opentelemetry/sdk-trace-base"), { OTLPTraceExporter: r } = await import("@opentelemetry/exporter-trace-otlp-http"), i = new r({ url: `${v.replace(/\/$/, "")}/v1/traces` });
167
- return e.logger.info("datadog traces → agent OTLP", { url: `${v}/v1/traces` }), {
169
+ let { BatchSpanProcessor: n } = await import("@opentelemetry/sdk-trace-base"), { OTLPTraceExporter: r } = await import("@opentelemetry/exporter-trace-otlp-http"), i = new r({ url: `${y.replace(/\/$/, "")}/v1/traces` });
170
+ return e.logger.info("datadog traces → agent OTLP", { url: `${y}/v1/traces` }), {
168
171
  spanProcessors: [new n(i)],
169
172
  resourceAttributes: t
170
173
  };
@@ -173,28 +176,28 @@ var c = 3, l = (e) => Object.entries(e).map(([e, t]) => `${e}:${t}`), u = (e, t)
173
176
  }
174
177
  },
175
178
  onActivate: (e) => t.sync(() => {
176
- if (O && (S = setInterval(() => void T(), l), typeof S.unref == "function" && S.unref()), k && (C = a({
177
- intervalMs: d,
178
- send: E,
179
+ if (k && (C = setInterval(() => void E(), u), typeof C.unref == "function" && C.unref()), A && (w = a({
180
+ intervalMs: f,
181
+ send: D,
179
182
  maxBuffer: 5e3,
180
- onError: (e) => h.warn("datadog logs flush errored", { error: String(e) })
181
- }), w = r((e) => C?.push(e))), !O && !n.traces && !n.profiling) {
183
+ onError: (e) => g.warn("datadog logs flush errored", { error: String(e) })
184
+ }), T = r((e) => w?.push(e))), !k && !n.traces && !n.profiling) {
182
185
  e.logger.warn("datadog inactive — no DD_API_KEY and no traces/profiling enabled");
183
186
  return;
184
187
  }
185
188
  e.logger.info("datadog active", {
186
- metrics: O,
187
- logs: k,
189
+ metrics: k,
190
+ logs: A,
188
191
  traces: !!n.traces,
189
192
  profiling: !!n.profiling,
190
- service: f,
191
- env: g
193
+ service: p,
194
+ env: _
192
195
  });
193
196
  }),
194
197
  onDeactivate: () => t.promise(async () => {
195
- S && clearInterval(S), S = void 0, w?.(), w = void 0, await C?.dispose(), C = void 0;
198
+ C && clearInterval(C), C = void 0, T?.(), T = void 0, await w?.dispose(), w = void 0;
196
199
  })
197
200
  });
198
201
  };
199
202
  //#endregion
200
- export { g as datadogPlugin, f as toDatadogLog, p as toDatadogLogs, u as toDatadogSeries };
203
+ export { _ as datadogPlugin, p as toDatadogLog, m as toDatadogLogs, d as toDatadogSeries };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-datadog",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "Deep Datadog integration — agentless metrics push (unified Metrics-API → /api/v2/series) + opt-in log forwarding (dd.trace_id-correlated → /api/v2/logs) + traces (framework OTel spans → Datadog Agent OTLP) + the dd-trace continuous profiler, all correlated by the same trace id. Inert without DD_API_KEY.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -22,7 +22,8 @@
22
22
  "types": "./dist/index.d.ts",
23
23
  "import": "./dist/index.js",
24
24
  "default": "./dist/index.js"
25
- }
25
+ },
26
+ "./package.json": "./package.json"
26
27
  },
27
28
  "main": "./dist/index.js",
28
29
  "module": "./dist/index.js",
@@ -32,10 +33,10 @@
32
33
  "node": ">=24.0.0"
33
34
  },
34
35
  "dependencies": {
35
- "@voltro/env": "0.32.0",
36
- "@voltro/logger": "0.32.0",
37
- "@voltro/protocol": "0.32.0",
38
- "@voltro/runtime": "0.32.0"
36
+ "@voltro/env": "0.34.0",
37
+ "@voltro/logger": "0.34.0",
38
+ "@voltro/protocol": "0.34.0",
39
+ "@voltro/runtime": "0.34.0"
39
40
  },
40
41
  "optionalDependencies": {
41
42
  "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",