autotel-backends 2.12.43 → 2.13.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.
Files changed (50) hide show
  1. package/README.md +75 -0
  2. package/dist/datadog.cjs +0 -2
  3. package/dist/datadog.d.cts +1 -2
  4. package/dist/datadog.d.ts +1 -2
  5. package/dist/datadog.js +0 -2
  6. package/dist/google-cloud.cjs +0 -2
  7. package/dist/google-cloud.d.cts +1 -2
  8. package/dist/google-cloud.d.ts +1 -2
  9. package/dist/google-cloud.js +0 -2
  10. package/dist/grafana.cjs +0 -2
  11. package/dist/grafana.d.cts +1 -2
  12. package/dist/grafana.d.ts +1 -2
  13. package/dist/grafana.js +0 -2
  14. package/dist/honeycomb.cjs +0 -2
  15. package/dist/honeycomb.d.cts +1 -2
  16. package/dist/honeycomb.d.ts +1 -2
  17. package/dist/honeycomb.js +0 -2
  18. package/dist/index.cjs +6 -0
  19. package/dist/index.d.cts +4 -1
  20. package/dist/index.d.ts +4 -1
  21. package/dist/index.js +4 -1
  22. package/dist/langfuse.cjs +43 -0
  23. package/dist/langfuse.d.cts +68 -0
  24. package/dist/langfuse.d.ts +68 -0
  25. package/dist/langfuse.js +42 -0
  26. package/dist/logfire.cjs +43 -0
  27. package/dist/logfire.d.cts +76 -0
  28. package/dist/logfire.d.ts +76 -0
  29. package/dist/logfire.js +42 -0
  30. package/dist/posthog.cjs +42 -0
  31. package/dist/posthog.d.cts +63 -0
  32. package/dist/posthog.d.ts +63 -0
  33. package/dist/posthog.js +41 -0
  34. package/package.json +25 -10
  35. package/dist/datadog.cjs.map +0 -1
  36. package/dist/datadog.d.cts.map +0 -1
  37. package/dist/datadog.d.ts.map +0 -1
  38. package/dist/datadog.js.map +0 -1
  39. package/dist/google-cloud.cjs.map +0 -1
  40. package/dist/google-cloud.d.cts.map +0 -1
  41. package/dist/google-cloud.d.ts.map +0 -1
  42. package/dist/google-cloud.js.map +0 -1
  43. package/dist/grafana.cjs.map +0 -1
  44. package/dist/grafana.d.cts.map +0 -1
  45. package/dist/grafana.d.ts.map +0 -1
  46. package/dist/grafana.js.map +0 -1
  47. package/dist/honeycomb.cjs.map +0 -1
  48. package/dist/honeycomb.d.cts.map +0 -1
  49. package/dist/honeycomb.d.ts.map +0 -1
  50. package/dist/honeycomb.js.map +0 -1
package/README.md CHANGED
@@ -136,6 +136,81 @@ init(
136
136
 
137
137
  [View full Datadog configuration options →](./src/datadog.ts)
138
138
 
139
+ ### 🔥 Logfire
140
+
141
+ [Pydantic Logfire](https://pydantic.dev/logfire) keeps `gen_ai.*` semantic-convention attributes and W3C trace IDs intact on the read path, so GenAI traces come back the shape you emitted them.
142
+
143
+ ```typescript
144
+ import { createLogfireConfig } from 'autotel-backends/logfire';
145
+
146
+ init(
147
+ createLogfireConfig({
148
+ writeToken: process.env.LOGFIRE_WRITE_TOKEN!,
149
+ service: 'my-app',
150
+ region: 'eu', // or 'us' — required
151
+ }),
152
+ );
153
+ ```
154
+
155
+ **Features**:
156
+
157
+ - Forces OTLP/HTTP **protobuf** — Logfire rejects gRPC and silently drops a JSON body, so either default loses your traces without an error
158
+ - `region` is required, because both ingest and the query API are region-specific and a mismatch returns a bare 401 that names neither cause. Override `endpoint` for self-hosted.
159
+ - Sends the write token bare, as Logfire's ingest expects (its query API wants `Bearer <read-token>` instead — different credential, different format)
160
+
161
+ [View full Logfire configuration options →](./src/logfire.ts)
162
+
163
+ ### 🦔 PostHog
164
+
165
+ [PostHog](https://posthog.com) ingests OTLP traces, logs and metrics, so product analytics and distributed traces can share a destination. (For product _events_, see `autotel-subscribers/posthog` — a separate path.)
166
+
167
+ ```typescript
168
+ import { createPostHogConfig } from 'autotel-backends/posthog';
169
+
170
+ init(
171
+ createPostHogConfig({
172
+ projectToken: process.env.POSTHOG_PROJECT_TOKEN!,
173
+ service: 'my-app',
174
+ region: 'eu', // or 'us'
175
+ }),
176
+ );
177
+ ```
178
+
179
+ **Features**:
180
+
181
+ - OTLP/HTTP **protobuf** — PostHog's docs steer away from the JSON exporter, and a JSON body is dropped rather than rejected
182
+ - Handles the `/i` path prefix its OTLP receiver lives under, so signals land on `/i/v1/traces`, `/i/v1/logs` and `/i/v1/metrics`
183
+ - US and EU cloud regions, plus a self-hosted `host` override
184
+ - Bearer auth with the `phc_…` project token
185
+
186
+ [View full PostHog configuration options →](./src/posthog.ts)
187
+
188
+ ### 🪢 Langfuse
189
+
190
+ [Langfuse](https://langfuse.com) ingests plain OTLP, so autotel's GenAI spans land without a Langfuse SDK in your app.
191
+
192
+ ```typescript
193
+ import { createLangfuseConfig } from 'autotel-backends/langfuse';
194
+
195
+ init(
196
+ createLangfuseConfig({
197
+ publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
198
+ secretKey: process.env.LANGFUSE_SECRET_KEY!,
199
+ service: 'my-app',
200
+ region: 'eu', // or 'us'
201
+ }),
202
+ );
203
+ ```
204
+
205
+ **Features**:
206
+
207
+ - OTLP/HTTP only — Langfuse does not support gRPC
208
+ - EU and US cloud regions, plus a self-hosted `baseUrl` override
209
+ - Basic auth built from your public/secret key pair
210
+ - Opts into v4 ingestion, which keeps traces queryable promptly
211
+
212
+ [View full Langfuse configuration options →](./src/langfuse.ts)
213
+
139
214
  ## Why Use Backend Configs?
140
215
 
141
216
  ### Without backend configs (manual):
package/dist/datadog.cjs CHANGED
@@ -134,5 +134,3 @@ function createDatadogConfig(config) {
134
134
  }
135
135
  //#endregion
136
136
  exports.createDatadogConfig = createDatadogConfig;
137
-
138
- //# sourceMappingURL=datadog.cjs.map
@@ -142,5 +142,4 @@ interface DatadogPresetConfig {
142
142
  */
143
143
  declare function createDatadogConfig(config: DatadogPresetConfig): AutotelConfig;
144
144
  //#endregion
145
- export { DatadogPresetConfig, DatadogSite, createDatadogConfig };
146
- //# sourceMappingURL=datadog.d.cts.map
145
+ export { DatadogPresetConfig, DatadogSite, createDatadogConfig };
package/dist/datadog.d.ts CHANGED
@@ -142,5 +142,4 @@ interface DatadogPresetConfig {
142
142
  */
143
143
  declare function createDatadogConfig(config: DatadogPresetConfig): AutotelConfig;
144
144
  //#endregion
145
- export { DatadogPresetConfig, DatadogSite, createDatadogConfig };
146
- //# sourceMappingURL=datadog.d.ts.map
145
+ export { DatadogPresetConfig, DatadogSite, createDatadogConfig };
package/dist/datadog.js CHANGED
@@ -133,5 +133,3 @@ function createDatadogConfig(config) {
133
133
  }
134
134
  //#endregion
135
135
  export { createDatadogConfig };
136
-
137
- //# sourceMappingURL=datadog.js.map
@@ -118,5 +118,3 @@ var GcpAuthSpanExporter = class {
118
118
  };
119
119
  //#endregion
120
120
  exports.createGoogleCloudConfig = createGoogleCloudConfig;
121
-
122
- //# sourceMappingURL=google-cloud.cjs.map
@@ -66,5 +66,4 @@ interface GoogleCloudPresetConfig {
66
66
  */
67
67
  declare function createGoogleCloudConfig(config: GoogleCloudPresetConfig): AutotelConfig;
68
68
  //#endregion
69
- export { GoogleCloudPresetConfig, createGoogleCloudConfig };
70
- //# sourceMappingURL=google-cloud.d.cts.map
69
+ export { GoogleCloudPresetConfig, createGoogleCloudConfig };
@@ -66,5 +66,4 @@ interface GoogleCloudPresetConfig {
66
66
  */
67
67
  declare function createGoogleCloudConfig(config: GoogleCloudPresetConfig): AutotelConfig;
68
68
  //#endregion
69
- export { GoogleCloudPresetConfig, createGoogleCloudConfig };
70
- //# sourceMappingURL=google-cloud.d.ts.map
69
+ export { GoogleCloudPresetConfig, createGoogleCloudConfig };
@@ -117,5 +117,3 @@ var GcpAuthSpanExporter = class {
117
117
  };
118
118
  //#endregion
119
119
  export { createGoogleCloudConfig };
120
-
121
- //# sourceMappingURL=google-cloud.js.map
package/dist/grafana.cjs CHANGED
@@ -77,5 +77,3 @@ function createGrafanaConfig(config) {
77
77
  }
78
78
  //#endregion
79
79
  exports.createGrafanaConfig = createGrafanaConfig;
80
-
81
- //# sourceMappingURL=grafana.cjs.map
@@ -60,5 +60,4 @@ interface GrafanaPresetConfig {
60
60
  */
61
61
  declare function createGrafanaConfig(config: GrafanaPresetConfig): AutotelConfig;
62
62
  //#endregion
63
- export { GrafanaPresetConfig, createGrafanaConfig };
64
- //# sourceMappingURL=grafana.d.cts.map
63
+ export { GrafanaPresetConfig, createGrafanaConfig };
package/dist/grafana.d.ts CHANGED
@@ -60,5 +60,4 @@ interface GrafanaPresetConfig {
60
60
  */
61
61
  declare function createGrafanaConfig(config: GrafanaPresetConfig): AutotelConfig;
62
62
  //#endregion
63
- export { GrafanaPresetConfig, createGrafanaConfig };
64
- //# sourceMappingURL=grafana.d.ts.map
63
+ export { GrafanaPresetConfig, createGrafanaConfig };
package/dist/grafana.js CHANGED
@@ -76,5 +76,3 @@ function createGrafanaConfig(config) {
76
76
  }
77
77
  //#endregion
78
78
  export { createGrafanaConfig };
79
-
80
- //# sourceMappingURL=grafana.js.map
@@ -60,5 +60,3 @@ function createHoneycombConfig(config) {
60
60
  }
61
61
  //#endregion
62
62
  exports.createHoneycombConfig = createHoneycombConfig;
63
-
64
- //# sourceMappingURL=honeycomb.cjs.map
@@ -103,5 +103,4 @@ interface HoneycombPresetConfig {
103
103
  */
104
104
  declare function createHoneycombConfig(config: HoneycombPresetConfig): AutotelConfig;
105
105
  //#endregion
106
- export { HoneycombPresetConfig, createHoneycombConfig };
107
- //# sourceMappingURL=honeycomb.d.cts.map
106
+ export { HoneycombPresetConfig, createHoneycombConfig };
@@ -103,5 +103,4 @@ interface HoneycombPresetConfig {
103
103
  */
104
104
  declare function createHoneycombConfig(config: HoneycombPresetConfig): AutotelConfig;
105
105
  //#endregion
106
- export { HoneycombPresetConfig, createHoneycombConfig };
107
- //# sourceMappingURL=honeycomb.d.ts.map
106
+ export { HoneycombPresetConfig, createHoneycombConfig };
package/dist/honeycomb.js CHANGED
@@ -59,5 +59,3 @@ function createHoneycombConfig(config) {
59
59
  }
60
60
  //#endregion
61
61
  export { createHoneycombConfig };
62
-
63
- //# sourceMappingURL=honeycomb.js.map
package/dist/index.cjs CHANGED
@@ -3,7 +3,13 @@ const require_honeycomb = require("./honeycomb.cjs");
3
3
  const require_datadog = require("./datadog.cjs");
4
4
  const require_google_cloud = require("./google-cloud.cjs");
5
5
  const require_grafana = require("./grafana.cjs");
6
+ const require_logfire = require("./logfire.cjs");
7
+ const require_posthog = require("./posthog.cjs");
8
+ const require_langfuse = require("./langfuse.cjs");
6
9
  exports.createDatadogConfig = require_datadog.createDatadogConfig;
7
10
  exports.createGoogleCloudConfig = require_google_cloud.createGoogleCloudConfig;
8
11
  exports.createGrafanaConfig = require_grafana.createGrafanaConfig;
9
12
  exports.createHoneycombConfig = require_honeycomb.createHoneycombConfig;
13
+ exports.createLangfuseConfig = require_langfuse.createLangfuseConfig;
14
+ exports.createLogfireConfig = require_logfire.createLogfireConfig;
15
+ exports.createPostHogConfig = require_posthog.createPostHogConfig;
package/dist/index.d.cts CHANGED
@@ -2,4 +2,7 @@ import { DatadogPresetConfig, DatadogSite, createDatadogConfig } from "./datadog
2
2
  import { GoogleCloudPresetConfig, createGoogleCloudConfig } from "./google-cloud.cjs";
3
3
  import { GrafanaPresetConfig, createGrafanaConfig } from "./grafana.cjs";
4
4
  import { HoneycombPresetConfig, createHoneycombConfig } from "./honeycomb.cjs";
5
- export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig };
5
+ import { LogfirePresetConfig, LogfireRegion, createLogfireConfig } from "./logfire.cjs";
6
+ import { PostHogPresetConfig, PostHogRegion, createPostHogConfig } from "./posthog.cjs";
7
+ import { LangfusePresetConfig, LangfuseRegion, createLangfuseConfig } from "./langfuse.cjs";
8
+ export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, type LangfusePresetConfig, type LangfuseRegion, type LogfirePresetConfig, type LogfireRegion, type PostHogPresetConfig, type PostHogRegion, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig, createLangfuseConfig, createLogfireConfig, createPostHogConfig };
package/dist/index.d.ts CHANGED
@@ -2,4 +2,7 @@ import { DatadogPresetConfig, DatadogSite, createDatadogConfig } from "./datadog
2
2
  import { GoogleCloudPresetConfig, createGoogleCloudConfig } from "./google-cloud.js";
3
3
  import { GrafanaPresetConfig, createGrafanaConfig } from "./grafana.js";
4
4
  import { HoneycombPresetConfig, createHoneycombConfig } from "./honeycomb.js";
5
- export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig };
5
+ import { LogfirePresetConfig, LogfireRegion, createLogfireConfig } from "./logfire.js";
6
+ import { PostHogPresetConfig, PostHogRegion, createPostHogConfig } from "./posthog.js";
7
+ import { LangfusePresetConfig, LangfuseRegion, createLangfuseConfig } from "./langfuse.js";
8
+ export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, type LangfusePresetConfig, type LangfuseRegion, type LogfirePresetConfig, type LogfireRegion, type PostHogPresetConfig, type PostHogRegion, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig, createLangfuseConfig, createLogfireConfig, createPostHogConfig };
package/dist/index.js CHANGED
@@ -2,4 +2,7 @@ import { createHoneycombConfig } from "./honeycomb.js";
2
2
  import { createDatadogConfig } from "./datadog.js";
3
3
  import { createGoogleCloudConfig } from "./google-cloud.js";
4
4
  import { createGrafanaConfig } from "./grafana.js";
5
- export { createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig };
5
+ import { createLogfireConfig } from "./logfire.js";
6
+ import { createPostHogConfig } from "./posthog.js";
7
+ import { createLangfuseConfig } from "./langfuse.js";
8
+ export { createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig, createLangfuseConfig, createLogfireConfig, createPostHogConfig };
@@ -0,0 +1,43 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/langfuse.ts
3
+ /** Langfuse Cloud regions and their base URLs. */
4
+ const REGION_BASE_URLS = {
5
+ eu: "https://cloud.langfuse.com",
6
+ us: "https://us.cloud.langfuse.com"
7
+ };
8
+ /** OTLP receiver path, appended to whichever base URL is in play. */
9
+ const OTEL_PATH = "/api/public/otel";
10
+ /**
11
+ * Create an autotel configuration for Langfuse.
12
+ *
13
+ * This preset handles:
14
+ * - OTLP/HTTP protocol — Langfuse does not support gRPC
15
+ * - The regional (or self-hosted) OTLP receiver URL
16
+ * - Basic auth over the public/secret key pair
17
+ * - Opting into v4 ingestion, which keeps traces queryable promptly
18
+ *
19
+ * @param config - Langfuse-specific configuration options
20
+ * @returns AutotelConfig ready to pass to init()
21
+ */
22
+ function createLangfuseConfig(config) {
23
+ const { publicKey, secretKey, service, region = "eu", environment, version, baseUrl } = config;
24
+ if (!publicKey) throw new Error("Langfuse public key is required. Find it under Settings → API Keys.");
25
+ if (!secretKey) throw new Error("Langfuse secret key is required. Find it under Settings → API Keys.");
26
+ const regionBaseUrl = REGION_BASE_URLS[region];
27
+ if (!regionBaseUrl) throw new Error(`Unknown Langfuse region "${region}". Supported regions: ${Object.keys(REGION_BASE_URLS).join(", ")}.`);
28
+ const root = (baseUrl ?? regionBaseUrl).replace(/\/+$/, "");
29
+ const credentials = Buffer.from(`${publicKey}:${secretKey}`).toString("base64");
30
+ return {
31
+ service,
32
+ environment,
33
+ version,
34
+ protocol: "http",
35
+ endpoint: `${root}${OTEL_PATH}`,
36
+ headers: {
37
+ Authorization: `Basic ${credentials}`,
38
+ "x-langfuse-ingestion-version": "4"
39
+ }
40
+ };
41
+ }
42
+ //#endregion
43
+ exports.createLangfuseConfig = createLangfuseConfig;
@@ -0,0 +1,68 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/langfuse.d.ts
3
+ /** Langfuse Cloud regions and their base URLs. */
4
+ declare const REGION_BASE_URLS: {
5
+ readonly eu: "https://cloud.langfuse.com";
6
+ readonly us: "https://us.cloud.langfuse.com";
7
+ };
8
+ type LangfuseRegion = keyof typeof REGION_BASE_URLS;
9
+ /**
10
+ * Configuration options for the Langfuse preset
11
+ */
12
+ interface LangfusePresetConfig {
13
+ /**
14
+ * Langfuse public key, `pk-lf-...` (required).
15
+ * Found under Settings → API Keys.
16
+ */
17
+ publicKey: string;
18
+ /**
19
+ * Langfuse secret key, `sk-lf-...` (required).
20
+ * Found under Settings → API Keys.
21
+ */
22
+ secretKey: string;
23
+ /**
24
+ * Service name (required).
25
+ * Appears as service.name on every span.
26
+ */
27
+ service: string;
28
+ /**
29
+ * Langfuse Cloud region the project lives in.
30
+ *
31
+ * @default 'eu'
32
+ */
33
+ region?: LangfuseRegion;
34
+ /**
35
+ * Deployment environment (e.g., 'production', 'staging', 'development').
36
+ *
37
+ * @default process.env.NODE_ENV || 'development'
38
+ */
39
+ environment?: string;
40
+ /**
41
+ * Service version for deployment tracking.
42
+ *
43
+ * @default process.env.VERSION || auto-detected from package.json
44
+ */
45
+ version?: string;
46
+ /**
47
+ * Base URL of a self-hosted Langfuse instance, without the OTLP path.
48
+ * Takes precedence over `region`.
49
+ *
50
+ * @default the base URL for the selected region
51
+ */
52
+ baseUrl?: string;
53
+ }
54
+ /**
55
+ * Create an autotel configuration for Langfuse.
56
+ *
57
+ * This preset handles:
58
+ * - OTLP/HTTP protocol — Langfuse does not support gRPC
59
+ * - The regional (or self-hosted) OTLP receiver URL
60
+ * - Basic auth over the public/secret key pair
61
+ * - Opting into v4 ingestion, which keeps traces queryable promptly
62
+ *
63
+ * @param config - Langfuse-specific configuration options
64
+ * @returns AutotelConfig ready to pass to init()
65
+ */
66
+ declare function createLangfuseConfig(config: LangfusePresetConfig): AutotelConfig;
67
+ //#endregion
68
+ export { LangfusePresetConfig, LangfuseRegion, createLangfuseConfig };
@@ -0,0 +1,68 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/langfuse.d.ts
3
+ /** Langfuse Cloud regions and their base URLs. */
4
+ declare const REGION_BASE_URLS: {
5
+ readonly eu: "https://cloud.langfuse.com";
6
+ readonly us: "https://us.cloud.langfuse.com";
7
+ };
8
+ type LangfuseRegion = keyof typeof REGION_BASE_URLS;
9
+ /**
10
+ * Configuration options for the Langfuse preset
11
+ */
12
+ interface LangfusePresetConfig {
13
+ /**
14
+ * Langfuse public key, `pk-lf-...` (required).
15
+ * Found under Settings → API Keys.
16
+ */
17
+ publicKey: string;
18
+ /**
19
+ * Langfuse secret key, `sk-lf-...` (required).
20
+ * Found under Settings → API Keys.
21
+ */
22
+ secretKey: string;
23
+ /**
24
+ * Service name (required).
25
+ * Appears as service.name on every span.
26
+ */
27
+ service: string;
28
+ /**
29
+ * Langfuse Cloud region the project lives in.
30
+ *
31
+ * @default 'eu'
32
+ */
33
+ region?: LangfuseRegion;
34
+ /**
35
+ * Deployment environment (e.g., 'production', 'staging', 'development').
36
+ *
37
+ * @default process.env.NODE_ENV || 'development'
38
+ */
39
+ environment?: string;
40
+ /**
41
+ * Service version for deployment tracking.
42
+ *
43
+ * @default process.env.VERSION || auto-detected from package.json
44
+ */
45
+ version?: string;
46
+ /**
47
+ * Base URL of a self-hosted Langfuse instance, without the OTLP path.
48
+ * Takes precedence over `region`.
49
+ *
50
+ * @default the base URL for the selected region
51
+ */
52
+ baseUrl?: string;
53
+ }
54
+ /**
55
+ * Create an autotel configuration for Langfuse.
56
+ *
57
+ * This preset handles:
58
+ * - OTLP/HTTP protocol — Langfuse does not support gRPC
59
+ * - The regional (or self-hosted) OTLP receiver URL
60
+ * - Basic auth over the public/secret key pair
61
+ * - Opting into v4 ingestion, which keeps traces queryable promptly
62
+ *
63
+ * @param config - Langfuse-specific configuration options
64
+ * @returns AutotelConfig ready to pass to init()
65
+ */
66
+ declare function createLangfuseConfig(config: LangfusePresetConfig): AutotelConfig;
67
+ //#endregion
68
+ export { LangfusePresetConfig, LangfuseRegion, createLangfuseConfig };
@@ -0,0 +1,42 @@
1
+ //#region src/langfuse.ts
2
+ /** Langfuse Cloud regions and their base URLs. */
3
+ const REGION_BASE_URLS = {
4
+ eu: "https://cloud.langfuse.com",
5
+ us: "https://us.cloud.langfuse.com"
6
+ };
7
+ /** OTLP receiver path, appended to whichever base URL is in play. */
8
+ const OTEL_PATH = "/api/public/otel";
9
+ /**
10
+ * Create an autotel configuration for Langfuse.
11
+ *
12
+ * This preset handles:
13
+ * - OTLP/HTTP protocol — Langfuse does not support gRPC
14
+ * - The regional (or self-hosted) OTLP receiver URL
15
+ * - Basic auth over the public/secret key pair
16
+ * - Opting into v4 ingestion, which keeps traces queryable promptly
17
+ *
18
+ * @param config - Langfuse-specific configuration options
19
+ * @returns AutotelConfig ready to pass to init()
20
+ */
21
+ function createLangfuseConfig(config) {
22
+ const { publicKey, secretKey, service, region = "eu", environment, version, baseUrl } = config;
23
+ if (!publicKey) throw new Error("Langfuse public key is required. Find it under Settings → API Keys.");
24
+ if (!secretKey) throw new Error("Langfuse secret key is required. Find it under Settings → API Keys.");
25
+ const regionBaseUrl = REGION_BASE_URLS[region];
26
+ if (!regionBaseUrl) throw new Error(`Unknown Langfuse region "${region}". Supported regions: ${Object.keys(REGION_BASE_URLS).join(", ")}.`);
27
+ const root = (baseUrl ?? regionBaseUrl).replace(/\/+$/, "");
28
+ const credentials = Buffer.from(`${publicKey}:${secretKey}`).toString("base64");
29
+ return {
30
+ service,
31
+ environment,
32
+ version,
33
+ protocol: "http",
34
+ endpoint: `${root}${OTEL_PATH}`,
35
+ headers: {
36
+ Authorization: `Basic ${credentials}`,
37
+ "x-langfuse-ingestion-version": "4"
38
+ }
39
+ };
40
+ }
41
+ //#endregion
42
+ export { createLangfuseConfig };
@@ -0,0 +1,43 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/logfire.ts
3
+ /**
4
+ * Region ingest endpoints.
5
+ *
6
+ * Verified against the live API: the shared `logfire-api.pydantic.dev` host
7
+ * returns 401 for ingest. Logfire's own SDK resolves the region host from the
8
+ * token client-side rather than relying on server-side routing, so the region
9
+ * has to be named — which is why it is required below rather than defaulted.
10
+ * Guessing it wrong produces a bare 401 that names neither cause.
11
+ */
12
+ const REGION_ENDPOINTS = {
13
+ us: "https://logfire-us.pydantic.dev",
14
+ eu: "https://logfire-eu.pydantic.dev"
15
+ };
16
+ /**
17
+ * Create an autotel configuration for Pydantic Logfire.
18
+ *
19
+ * This preset handles:
20
+ * - OTLP/HTTP **protobuf** — Logfire accepts neither gRPC nor a JSON body, and
21
+ * an SDK defaulting to either fails silently
22
+ * - The regional ingest endpoint
23
+ * - The bare-token `Authorization` header Logfire's ingest expects
24
+ *
25
+ * @param config - Logfire-specific configuration options
26
+ * @returns AutotelConfig ready to pass to init()
27
+ */
28
+ function createLogfireConfig(config) {
29
+ const { writeToken, service, region, environment, version } = config;
30
+ if (!writeToken) throw new Error("Logfire write token is required. Create one under Project Settings → Write Tokens.");
31
+ const regionEndpoint = REGION_ENDPOINTS[region];
32
+ if (!regionEndpoint) throw new Error(`Unknown Logfire region "${region}". Supported regions: ${Object.keys(REGION_ENDPOINTS).join(", ")}.`);
33
+ return {
34
+ service,
35
+ environment,
36
+ version,
37
+ protocol: "http/protobuf",
38
+ endpoint: config.endpoint ?? regionEndpoint,
39
+ headers: { Authorization: writeToken }
40
+ };
41
+ }
42
+ //#endregion
43
+ exports.createLogfireConfig = createLogfireConfig;
@@ -0,0 +1,76 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/logfire.d.ts
3
+ /**
4
+ * Region ingest endpoints.
5
+ *
6
+ * Verified against the live API: the shared `logfire-api.pydantic.dev` host
7
+ * returns 401 for ingest. Logfire's own SDK resolves the region host from the
8
+ * token client-side rather than relying on server-side routing, so the region
9
+ * has to be named — which is why it is required below rather than defaulted.
10
+ * Guessing it wrong produces a bare 401 that names neither cause.
11
+ */
12
+ declare const REGION_ENDPOINTS: {
13
+ readonly us: "https://logfire-us.pydantic.dev";
14
+ readonly eu: "https://logfire-eu.pydantic.dev";
15
+ };
16
+ type LogfireRegion = keyof typeof REGION_ENDPOINTS;
17
+ /**
18
+ * Configuration options for the Logfire preset
19
+ */
20
+ interface LogfirePresetConfig {
21
+ /**
22
+ * Logfire **write** token (required).
23
+ *
24
+ * Create one under Project Settings → Write Tokens. Note this is a different
25
+ * credential from the read-scope token the query API needs — a write token is
26
+ * rejected for reads, and vice versa.
27
+ */
28
+ writeToken: string;
29
+ /**
30
+ * Service name (required).
31
+ * Appears as service.name on every span.
32
+ */
33
+ service: string;
34
+ /**
35
+ * Data region the project lives in (required).
36
+ *
37
+ * Both ingest and the query API are region-specific, and a mismatch returns
38
+ * a bare 401, so this is explicit rather than guessed. Ignored when
39
+ * `endpoint` is set for a self-hosted instance.
40
+ */
41
+ region: LogfireRegion;
42
+ /**
43
+ * Deployment environment (e.g., 'production', 'staging', 'development').
44
+ *
45
+ * @default process.env.NODE_ENV || 'development'
46
+ */
47
+ environment?: string;
48
+ /**
49
+ * Service version for deployment tracking.
50
+ *
51
+ * @default process.env.VERSION || auto-detected from package.json
52
+ */
53
+ version?: string;
54
+ /**
55
+ * Full OTLP endpoint override, for self-hosted Logfire.
56
+ * Takes precedence over `region`.
57
+ *
58
+ * @default the named region's endpoint
59
+ */
60
+ endpoint?: string;
61
+ }
62
+ /**
63
+ * Create an autotel configuration for Pydantic Logfire.
64
+ *
65
+ * This preset handles:
66
+ * - OTLP/HTTP **protobuf** — Logfire accepts neither gRPC nor a JSON body, and
67
+ * an SDK defaulting to either fails silently
68
+ * - The regional ingest endpoint
69
+ * - The bare-token `Authorization` header Logfire's ingest expects
70
+ *
71
+ * @param config - Logfire-specific configuration options
72
+ * @returns AutotelConfig ready to pass to init()
73
+ */
74
+ declare function createLogfireConfig(config: LogfirePresetConfig): AutotelConfig;
75
+ //#endregion
76
+ export { LogfirePresetConfig, LogfireRegion, createLogfireConfig };
@@ -0,0 +1,76 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/logfire.d.ts
3
+ /**
4
+ * Region ingest endpoints.
5
+ *
6
+ * Verified against the live API: the shared `logfire-api.pydantic.dev` host
7
+ * returns 401 for ingest. Logfire's own SDK resolves the region host from the
8
+ * token client-side rather than relying on server-side routing, so the region
9
+ * has to be named — which is why it is required below rather than defaulted.
10
+ * Guessing it wrong produces a bare 401 that names neither cause.
11
+ */
12
+ declare const REGION_ENDPOINTS: {
13
+ readonly us: "https://logfire-us.pydantic.dev";
14
+ readonly eu: "https://logfire-eu.pydantic.dev";
15
+ };
16
+ type LogfireRegion = keyof typeof REGION_ENDPOINTS;
17
+ /**
18
+ * Configuration options for the Logfire preset
19
+ */
20
+ interface LogfirePresetConfig {
21
+ /**
22
+ * Logfire **write** token (required).
23
+ *
24
+ * Create one under Project Settings → Write Tokens. Note this is a different
25
+ * credential from the read-scope token the query API needs — a write token is
26
+ * rejected for reads, and vice versa.
27
+ */
28
+ writeToken: string;
29
+ /**
30
+ * Service name (required).
31
+ * Appears as service.name on every span.
32
+ */
33
+ service: string;
34
+ /**
35
+ * Data region the project lives in (required).
36
+ *
37
+ * Both ingest and the query API are region-specific, and a mismatch returns
38
+ * a bare 401, so this is explicit rather than guessed. Ignored when
39
+ * `endpoint` is set for a self-hosted instance.
40
+ */
41
+ region: LogfireRegion;
42
+ /**
43
+ * Deployment environment (e.g., 'production', 'staging', 'development').
44
+ *
45
+ * @default process.env.NODE_ENV || 'development'
46
+ */
47
+ environment?: string;
48
+ /**
49
+ * Service version for deployment tracking.
50
+ *
51
+ * @default process.env.VERSION || auto-detected from package.json
52
+ */
53
+ version?: string;
54
+ /**
55
+ * Full OTLP endpoint override, for self-hosted Logfire.
56
+ * Takes precedence over `region`.
57
+ *
58
+ * @default the named region's endpoint
59
+ */
60
+ endpoint?: string;
61
+ }
62
+ /**
63
+ * Create an autotel configuration for Pydantic Logfire.
64
+ *
65
+ * This preset handles:
66
+ * - OTLP/HTTP **protobuf** — Logfire accepts neither gRPC nor a JSON body, and
67
+ * an SDK defaulting to either fails silently
68
+ * - The regional ingest endpoint
69
+ * - The bare-token `Authorization` header Logfire's ingest expects
70
+ *
71
+ * @param config - Logfire-specific configuration options
72
+ * @returns AutotelConfig ready to pass to init()
73
+ */
74
+ declare function createLogfireConfig(config: LogfirePresetConfig): AutotelConfig;
75
+ //#endregion
76
+ export { LogfirePresetConfig, LogfireRegion, createLogfireConfig };
@@ -0,0 +1,42 @@
1
+ //#region src/logfire.ts
2
+ /**
3
+ * Region ingest endpoints.
4
+ *
5
+ * Verified against the live API: the shared `logfire-api.pydantic.dev` host
6
+ * returns 401 for ingest. Logfire's own SDK resolves the region host from the
7
+ * token client-side rather than relying on server-side routing, so the region
8
+ * has to be named — which is why it is required below rather than defaulted.
9
+ * Guessing it wrong produces a bare 401 that names neither cause.
10
+ */
11
+ const REGION_ENDPOINTS = {
12
+ us: "https://logfire-us.pydantic.dev",
13
+ eu: "https://logfire-eu.pydantic.dev"
14
+ };
15
+ /**
16
+ * Create an autotel configuration for Pydantic Logfire.
17
+ *
18
+ * This preset handles:
19
+ * - OTLP/HTTP **protobuf** — Logfire accepts neither gRPC nor a JSON body, and
20
+ * an SDK defaulting to either fails silently
21
+ * - The regional ingest endpoint
22
+ * - The bare-token `Authorization` header Logfire's ingest expects
23
+ *
24
+ * @param config - Logfire-specific configuration options
25
+ * @returns AutotelConfig ready to pass to init()
26
+ */
27
+ function createLogfireConfig(config) {
28
+ const { writeToken, service, region, environment, version } = config;
29
+ if (!writeToken) throw new Error("Logfire write token is required. Create one under Project Settings → Write Tokens.");
30
+ const regionEndpoint = REGION_ENDPOINTS[region];
31
+ if (!regionEndpoint) throw new Error(`Unknown Logfire region "${region}". Supported regions: ${Object.keys(REGION_ENDPOINTS).join(", ")}.`);
32
+ return {
33
+ service,
34
+ environment,
35
+ version,
36
+ protocol: "http/protobuf",
37
+ endpoint: config.endpoint ?? regionEndpoint,
38
+ headers: { Authorization: writeToken }
39
+ };
40
+ }
41
+ //#endregion
42
+ export { createLogfireConfig };
@@ -0,0 +1,42 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/posthog.ts
3
+ /** PostHog Cloud regions and their ingest hosts. */
4
+ const REGION_HOSTS = {
5
+ us: "https://us.i.posthog.com",
6
+ eu: "https://eu.i.posthog.com"
7
+ };
8
+ /**
9
+ * PostHog serves OTLP under `/i`, not at the host root. autotel appends
10
+ * `/v1/<signal>`, so stopping the endpoint at `/i` yields `/i/v1/traces`,
11
+ * `/i/v1/logs` and `/i/v1/metrics` — the three documented paths.
12
+ */
13
+ const OTLP_PATH_PREFIX = "/i";
14
+ /**
15
+ * Create an autotel configuration for PostHog.
16
+ *
17
+ * This preset handles:
18
+ * - OTLP/HTTP **protobuf** — PostHog's own docs steer away from the JSON
19
+ * exporter, and a JSON body is dropped rather than rejected
20
+ * - The `/i` path prefix its OTLP receiver lives under
21
+ * - Bearer auth with the project token
22
+ *
23
+ * @param config - PostHog-specific configuration options
24
+ * @returns AutotelConfig ready to pass to init()
25
+ */
26
+ function createPostHogConfig(config) {
27
+ const { projectToken, service, region = "us", environment, version } = config;
28
+ if (!projectToken) throw new Error("PostHog project token is required. Find it under Project Settings.");
29
+ const regionHost = REGION_HOSTS[region];
30
+ if (!regionHost) throw new Error(`Unknown PostHog region "${region}". Supported regions: ${Object.keys(REGION_HOSTS).join(", ")}.`);
31
+ const root = (config.host ?? regionHost).replace(/\/+$/, "");
32
+ return {
33
+ service,
34
+ environment,
35
+ version,
36
+ protocol: "http/protobuf",
37
+ endpoint: root.endsWith(OTLP_PATH_PREFIX) ? root : `${root}${OTLP_PATH_PREFIX}`,
38
+ headers: { Authorization: `Bearer ${projectToken}` }
39
+ };
40
+ }
41
+ //#endregion
42
+ exports.createPostHogConfig = createPostHogConfig;
@@ -0,0 +1,63 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/posthog.d.ts
3
+ /** PostHog Cloud regions and their ingest hosts. */
4
+ declare const REGION_HOSTS: {
5
+ readonly us: "https://us.i.posthog.com";
6
+ readonly eu: "https://eu.i.posthog.com";
7
+ };
8
+ type PostHogRegion = keyof typeof REGION_HOSTS;
9
+ /**
10
+ * Configuration options for the PostHog preset
11
+ */
12
+ interface PostHogPresetConfig {
13
+ /**
14
+ * PostHog project API key, `phc_...` (required).
15
+ * Found under Project Settings.
16
+ */
17
+ projectToken: string;
18
+ /**
19
+ * Service name (required).
20
+ * Appears as service.name on every span.
21
+ */
22
+ service: string;
23
+ /**
24
+ * PostHog Cloud region.
25
+ *
26
+ * @default 'us'
27
+ */
28
+ region?: PostHogRegion;
29
+ /**
30
+ * Deployment environment (e.g., 'production', 'staging', 'development').
31
+ *
32
+ * @default process.env.NODE_ENV || 'development'
33
+ */
34
+ environment?: string;
35
+ /**
36
+ * Service version for deployment tracking.
37
+ *
38
+ * @default process.env.VERSION || auto-detected from package.json
39
+ */
40
+ version?: string;
41
+ /**
42
+ * Host of a self-hosted PostHog instance, without the OTLP path.
43
+ * Takes precedence over `region`.
44
+ *
45
+ * @default the host for the selected region
46
+ */
47
+ host?: string;
48
+ }
49
+ /**
50
+ * Create an autotel configuration for PostHog.
51
+ *
52
+ * This preset handles:
53
+ * - OTLP/HTTP **protobuf** — PostHog's own docs steer away from the JSON
54
+ * exporter, and a JSON body is dropped rather than rejected
55
+ * - The `/i` path prefix its OTLP receiver lives under
56
+ * - Bearer auth with the project token
57
+ *
58
+ * @param config - PostHog-specific configuration options
59
+ * @returns AutotelConfig ready to pass to init()
60
+ */
61
+ declare function createPostHogConfig(config: PostHogPresetConfig): AutotelConfig;
62
+ //#endregion
63
+ export { PostHogPresetConfig, PostHogRegion, createPostHogConfig };
@@ -0,0 +1,63 @@
1
+ import { AutotelConfig } from "autotel";
2
+ //#region src/posthog.d.ts
3
+ /** PostHog Cloud regions and their ingest hosts. */
4
+ declare const REGION_HOSTS: {
5
+ readonly us: "https://us.i.posthog.com";
6
+ readonly eu: "https://eu.i.posthog.com";
7
+ };
8
+ type PostHogRegion = keyof typeof REGION_HOSTS;
9
+ /**
10
+ * Configuration options for the PostHog preset
11
+ */
12
+ interface PostHogPresetConfig {
13
+ /**
14
+ * PostHog project API key, `phc_...` (required).
15
+ * Found under Project Settings.
16
+ */
17
+ projectToken: string;
18
+ /**
19
+ * Service name (required).
20
+ * Appears as service.name on every span.
21
+ */
22
+ service: string;
23
+ /**
24
+ * PostHog Cloud region.
25
+ *
26
+ * @default 'us'
27
+ */
28
+ region?: PostHogRegion;
29
+ /**
30
+ * Deployment environment (e.g., 'production', 'staging', 'development').
31
+ *
32
+ * @default process.env.NODE_ENV || 'development'
33
+ */
34
+ environment?: string;
35
+ /**
36
+ * Service version for deployment tracking.
37
+ *
38
+ * @default process.env.VERSION || auto-detected from package.json
39
+ */
40
+ version?: string;
41
+ /**
42
+ * Host of a self-hosted PostHog instance, without the OTLP path.
43
+ * Takes precedence over `region`.
44
+ *
45
+ * @default the host for the selected region
46
+ */
47
+ host?: string;
48
+ }
49
+ /**
50
+ * Create an autotel configuration for PostHog.
51
+ *
52
+ * This preset handles:
53
+ * - OTLP/HTTP **protobuf** — PostHog's own docs steer away from the JSON
54
+ * exporter, and a JSON body is dropped rather than rejected
55
+ * - The `/i` path prefix its OTLP receiver lives under
56
+ * - Bearer auth with the project token
57
+ *
58
+ * @param config - PostHog-specific configuration options
59
+ * @returns AutotelConfig ready to pass to init()
60
+ */
61
+ declare function createPostHogConfig(config: PostHogPresetConfig): AutotelConfig;
62
+ //#endregion
63
+ export { PostHogPresetConfig, PostHogRegion, createPostHogConfig };
@@ -0,0 +1,41 @@
1
+ //#region src/posthog.ts
2
+ /** PostHog Cloud regions and their ingest hosts. */
3
+ const REGION_HOSTS = {
4
+ us: "https://us.i.posthog.com",
5
+ eu: "https://eu.i.posthog.com"
6
+ };
7
+ /**
8
+ * PostHog serves OTLP under `/i`, not at the host root. autotel appends
9
+ * `/v1/<signal>`, so stopping the endpoint at `/i` yields `/i/v1/traces`,
10
+ * `/i/v1/logs` and `/i/v1/metrics` — the three documented paths.
11
+ */
12
+ const OTLP_PATH_PREFIX = "/i";
13
+ /**
14
+ * Create an autotel configuration for PostHog.
15
+ *
16
+ * This preset handles:
17
+ * - OTLP/HTTP **protobuf** — PostHog's own docs steer away from the JSON
18
+ * exporter, and a JSON body is dropped rather than rejected
19
+ * - The `/i` path prefix its OTLP receiver lives under
20
+ * - Bearer auth with the project token
21
+ *
22
+ * @param config - PostHog-specific configuration options
23
+ * @returns AutotelConfig ready to pass to init()
24
+ */
25
+ function createPostHogConfig(config) {
26
+ const { projectToken, service, region = "us", environment, version } = config;
27
+ if (!projectToken) throw new Error("PostHog project token is required. Find it under Project Settings.");
28
+ const regionHost = REGION_HOSTS[region];
29
+ if (!regionHost) throw new Error(`Unknown PostHog region "${region}". Supported regions: ${Object.keys(REGION_HOSTS).join(", ")}.`);
30
+ const root = (config.host ?? regionHost).replace(/\/+$/, "");
31
+ return {
32
+ service,
33
+ environment,
34
+ version,
35
+ protocol: "http/protobuf",
36
+ endpoint: root.endsWith(OTLP_PATH_PREFIX) ? root : `${root}${OTLP_PATH_PREFIX}`,
37
+ headers: { Authorization: `Bearer ${projectToken}` }
38
+ };
39
+ }
40
+ //#endregion
41
+ export { createPostHogConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-backends",
3
- "version": "2.12.43",
3
+ "version": "2.13.0",
4
4
  "description": "Vendor backend configurations for Autotel (Honeycomb, Datadog, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,6 +31,21 @@
31
31
  "types": "./dist/grafana.d.ts",
32
32
  "import": "./dist/grafana.js",
33
33
  "require": "./dist/grafana.cjs"
34
+ },
35
+ "./logfire": {
36
+ "types": "./dist/logfire.d.ts",
37
+ "import": "./dist/logfire.js",
38
+ "require": "./dist/logfire.cjs"
39
+ },
40
+ "./langfuse": {
41
+ "types": "./dist/langfuse.d.ts",
42
+ "import": "./dist/langfuse.js",
43
+ "require": "./dist/langfuse.cjs"
44
+ },
45
+ "./posthog": {
46
+ "types": "./dist/posthog.d.ts",
47
+ "import": "./dist/posthog.js",
48
+ "require": "./dist/posthog.cjs"
34
49
  }
35
50
  },
36
51
  "files": [
@@ -55,15 +70,15 @@
55
70
  "author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
56
71
  "license": "Apache-2.0",
57
72
  "dependencies": {
58
- "@opentelemetry/exporter-logs-otlp-http": ">=0.220.0",
59
- "@opentelemetry/sdk-logs": ">=0.220.0",
60
- "autotel": "6.1.0"
73
+ "@opentelemetry/exporter-logs-otlp-http": ">=0.221.0",
74
+ "@opentelemetry/sdk-logs": ">=0.221.0",
75
+ "autotel": "6.2.0"
61
76
  },
62
77
  "peerDependencies": {
63
- "@opentelemetry/exporter-metrics-otlp-http": ">=0.220.0",
64
- "@opentelemetry/exporter-trace-otlp-http": ">=0.220.0",
65
- "@opentelemetry/sdk-metrics": ">=2.9.0",
66
- "google-auth-library": ">=10.9.0"
78
+ "@opentelemetry/exporter-metrics-otlp-http": ">=0.221.0",
79
+ "@opentelemetry/exporter-trace-otlp-http": ">=0.221.0",
80
+ "@opentelemetry/sdk-metrics": ">=2.10.0",
81
+ "google-auth-library": ">=10.9.1"
67
82
  },
68
83
  "peerDependenciesMeta": {
69
84
  "@opentelemetry/exporter-metrics-otlp-http": {
@@ -80,12 +95,12 @@
80
95
  }
81
96
  },
82
97
  "devDependencies": {
83
- "@types/node": "^26.1.1",
98
+ "@types/node": "^26.1.2",
84
99
  "@typescript-eslint/eslint-plugin": "^8.65.0",
85
100
  "@typescript-eslint/parser": "^8.65.0",
86
101
  "eslint-config-prettier": "^10.1.8",
87
102
  "eslint-plugin-unicorn": "^64.0.0",
88
- "tsdown": "^0.22.12",
103
+ "tsdown": "^0.22.14",
89
104
  "typescript": "^6.0.3",
90
105
  "vitest": "^4.1.10"
91
106
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"datadog.cjs","names":[],"sources":["../src/datadog.ts"],"sourcesContent":["/**\n * Datadog preset for autotel\n *\n * Provides a simplified configuration helper for Datadog integration\n * with best practices built-in.\n *\n * @example Direct cloud ingestion (serverless, edge)\n * ```typescript\n * import { init } from 'autotel';\n * import { createDatadogConfig } from 'autotel-backends/datadog';\n *\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-lambda',\n * enableLogs: true,\n * }));\n * ```\n *\n * @example Local Datadog Agent (long-running services, Kubernetes)\n * ```typescript\n * import { init } from 'autotel';\n * import { createDatadogConfig } from 'autotel-backends/datadog';\n *\n * init(createDatadogConfig({\n * service: 'my-api',\n * useAgent: true, // No API key needed - Agent handles it\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\nimport type { LogRecordProcessor } from '@opentelemetry/sdk-logs';\n\n// `__filename` exists under CJS (including esbuild's CJS output wrapper) but\n// not pure ESM. `typeof` is safe against an undeclared identifier and lets\n// the conditional pick the working URL in either format.\ndeclare const __filename: string | undefined;\n\n/**\n * Datadog site regions\n */\nexport type DatadogSite =\n | 'datadoghq.com' // US1 (default)\n | 'datadoghq.eu' // EU\n | 'us3.datadoghq.com' // US3\n | 'us5.datadoghq.com' // US5\n | 'ap1.datadoghq.com' // AP1\n | 'ddog-gov.com'; // US1-FED\n\n/**\n * Configuration options for Datadog preset\n */\nexport interface DatadogPresetConfig {\n /**\n * Datadog API key (required for direct cloud ingestion).\n * Not needed if using local Datadog Agent (useAgent: true).\n *\n * Get your API key from:\n * https://app.datadoghq.com/organization-settings/api-keys\n */\n apiKey?: string;\n\n /**\n * Datadog site/region.\n * Determines which Datadog intake endpoint to use.\n *\n * @default 'datadoghq.com' (US1)\n */\n site?: DatadogSite;\n\n /**\n * Service name (required).\n * Appears in Datadog APM, Service Catalog, and all telemetry.\n */\n service: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging', 'development').\n * Used for environment filtering in Datadog.\n *\n * @default process.env.DD_ENV || process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n * Enables Deployment Tracking in Datadog APM.\n *\n * @default process.env.DD_VERSION || auto-detected from package.json\n */\n version?: string;\n\n /**\n * Enable log export to Datadog via OTLP.\n *\n * When enabled, this:\n * 1. Sets up OTel Logs SDK with OTLP exporter (for direct OTel logs API usage)\n * 2. Auto-configures OTEL_EXPORTER_OTLP_LOGS_* env vars for pino-opentelemetry-transport\n *\n * For Pino users: Just add pino-opentelemetry-transport to your logger config:\n * ```typescript\n * const logger = pino({\n * transport: {\n * targets: [\n * { target: 'pino-pretty' },\n * { target: 'pino-opentelemetry-transport' }, // Auto-configured!\n * ],\n * },\n * });\n * ```\n *\n * @default false\n */\n enableLogs?: boolean;\n\n /**\n * Use local Datadog Agent instead of direct cloud ingestion.\n *\n * Benefits:\n * - Lower egress costs (Agent aggregates locally)\n * - Advanced features: trace-log correlation, multi-line logs, data scrubbing\n * - 500+ integrations for enrichment\n * - Infrastructure metrics collection\n *\n * Requires: Datadog Agent 7.35+ with OTLP enabled\n *\n * @default false\n */\n useAgent?: boolean;\n\n /**\n * Datadog Agent hostname (when useAgent: true).\n *\n * @default 'localhost'\n */\n agentHost?: string;\n\n /**\n * Datadog Agent OTLP port (when useAgent: true).\n *\n * @default 4318 (OTLP HTTP)\n */\n agentPort?: number;\n\n /**\n * Custom log record processors (advanced).\n * Overrides the default log processor if enableLogs is true.\n */\n logRecordProcessors?: LogRecordProcessor[];\n}\n\n/**\n * Create an autotel configuration optimized for Datadog.\n *\n * This preset handles:\n * - Proper OTLP endpoint configuration (Agent vs direct ingestion)\n * - Direct: https://otlp.{site} → SDK appends /v1/traces, /v1/metrics, /v1/logs\n * - Agent: http://localhost:4318 (default)\n * - Datadog API key authentication headers (direct ingestion only)\n * - Unified service tagging (service, env, version)\n * - Resource attribute best practices\n * - Optional log export configuration\n *\n * @param config - Datadog-specific configuration options\n * @returns AutotelConfig ready to pass to init()\n *\n * @example Simple cloud ingestion\n * ```typescript\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With logs and custom environment\n * ```typescript\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-app',\n * environment: 'production',\n * version: '2.1.0',\n * enableLogs: true,\n * }));\n * ```\n *\n * @example Using local Datadog Agent\n * ```typescript\n * init(createDatadogConfig({\n * service: 'my-api',\n * useAgent: true,\n * agentHost: 'datadog-agent.default.svc.cluster.local', // Kubernetes\n * }));\n * ```\n */\nexport function createDatadogConfig(\n config: DatadogPresetConfig,\n): AutotelConfig {\n const {\n apiKey,\n site = 'datadoghq.com',\n service,\n environment,\n version,\n enableLogs = false,\n useAgent = false,\n agentHost = 'localhost',\n agentPort = 4318,\n logRecordProcessors,\n } = config;\n\n // Validation: API key required for direct ingestion\n if (!useAgent && !apiKey) {\n throw new Error(\n 'Datadog API key is required for direct cloud ingestion. ' +\n 'Either provide apiKey or set useAgent: true to use local Datadog Agent.',\n );\n }\n\n const baseConfig: AutotelConfig = {\n service,\n environment,\n version,\n };\n\n // Local Datadog Agent configuration\n if (useAgent) {\n const agentEndpoint = `http://${agentHost}:${agentPort}`;\n\n // Auto-configure env vars for pino-opentelemetry-transport in agent mode\n if (enableLogs) {\n const logsEndpoint = `http://${agentHost}:${agentPort}/v1/logs`;\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;\n }\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'http/protobuf';\n }\n\n // No API key header needed for agent mode - Agent handles authentication\n\n const resourceAttrs = [\n `service.name=${service}`,\n environment ? `deployment.environment=${environment}` : null,\n version ? `service.version=${version}` : null,\n ]\n .filter(Boolean)\n .join(',');\n\n if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {\n process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;\n }\n }\n\n return {\n ...baseConfig,\n endpoint: agentEndpoint,\n // No API key or headers needed - Agent handles authentication\n };\n }\n\n // Direct cloud ingestion configuration\n // Datadog OTLP endpoint: base URL without path (SDK appends /v1/traces, /v1/metrics, /v1/logs)\n const otlpEndpoint = `https://otlp.${site}`;\n const authHeaders = `dd-api-key=${apiKey}`;\n\n const cloudConfig: AutotelConfig = {\n ...baseConfig,\n endpoint: otlpEndpoint,\n headers: authHeaders,\n };\n\n // Add log export if enabled\n if (enableLogs) {\n // Auto-configure env vars for pino-opentelemetry-transport and other OTel log transports\n // These are read by pino-opentelemetry-transport, otlp-logger, and similar libraries\n const logsEndpoint = useAgent\n ? `http://${agentHost}:${agentPort}/v1/logs`\n : `https://otlp.${site}/v1/logs`;\n\n // Only set if not already configured (allow user override)\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;\n }\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'http/protobuf';\n }\n\n // Only set API key header for direct cloud ingestion (not agent mode)\n if (!useAgent && apiKey && !process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS = `dd-api-key=${apiKey}`;\n }\n\n // Set resource attributes for service identification\n const resourceAttrs = [\n `service.name=${service}`,\n environment ? `deployment.environment=${environment}` : null,\n version ? `service.version=${version}` : null,\n ]\n .filter(Boolean)\n .join(',');\n\n if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {\n process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;\n }\n\n if (logRecordProcessors) {\n // Use custom processors if provided\n cloudConfig.logRecordProcessors = logRecordProcessors;\n } else {\n // Create default OTLP log exporter\n try {\n const pkgRequire = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n );\n const { BatchLogRecordProcessor } = pkgRequire(\n '@opentelemetry/sdk-logs',\n );\n const { OTLPLogExporter } = pkgRequire(\n '@opentelemetry/exporter-logs-otlp-http',\n );\n\n cloudConfig.logRecordProcessors = [\n new BatchLogRecordProcessor({\n exporter: new OTLPLogExporter({\n url: `${otlpEndpoint}/v1/logs`,\n headers: {\n 'dd-api-key': apiKey,\n },\n }),\n }),\n ];\n } catch {\n throw new Error(\n 'Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. ' +\n 'Install them or set enableLogs: false.',\n );\n }\n }\n }\n\n return cloudConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmMA,SAAgB,oBACd,QACe;CACf,MAAM,EACJ,QACA,OAAO,iBACP,SACA,aACA,SACA,aAAa,OACb,WAAW,OACX,YAAY,aACZ,YAAY,MACZ,wBACE;CAGJ,IAAI,CAAC,YAAY,CAAC,QAChB,MAAM,IAAI,MACR,iIAEF;CAGF,MAAM,aAA4B;EAChC;EACA;EACA;CACF;CAGA,IAAI,UAAU;EACZ,MAAM,gBAAgB,UAAU,UAAU,GAAG;EAG7C,IAAI,YAAY;GACd,MAAM,eAAe,UAAU,UAAU,GAAG,UAAU;GAEtD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;GAGjD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;GAKjD,MAAM,gBAAgB;IACpB,gBAAgB;IAChB,cAAc,0BAA0B,gBAAgB;IACxD,UAAU,mBAAmB,YAAY;GAC3C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;GAEX,IAAI,CAAC,QAAQ,IAAI,0BACf,QAAQ,IAAI,2BAA2B;EAE3C;EAEA,OAAO;GACL,GAAG;GACH,UAAU;EAEZ;CACF;CAIA,MAAM,eAAe,gBAAgB;CACrC,MAAM,cAAc,cAAc;CAElC,MAAM,cAA6B;EACjC,GAAG;EACH,UAAU;EACV,SAAS;CACX;CAGA,IAAI,YAAY;EAGd,MAAM,eAAe,WACjB,UAAU,UAAU,GAAG,UAAU,YACjC,gBAAgB,KAAK;EAGzB,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;EAGjD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;EAIjD,IAAI,CAAC,YAAY,UAAU,CAAC,QAAQ,IAAI,iCACtC,QAAQ,IAAI,kCAAkC,cAAc;EAI9D,MAAM,gBAAgB;GACpB,gBAAgB;GAChB,cAAc,0BAA0B,gBAAgB;GACxD,UAAU,mBAAmB,YAAY;EAC3C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;EAEX,IAAI,CAAC,QAAQ,IAAI,0BACf,QAAQ,IAAI,2BAA2B;EAGzC,IAAI,qBAEF,YAAY,sBAAsB;OAGlC,IAAI;GACF,MAAM,cAAA,GAAA,YAAA,cAAA,CACJ,OAAO,eAAe,WAAW,aAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,IACnC;GACA,MAAM,EAAE,4BAA4B,WAClC,yBACF;GACA,MAAM,EAAE,oBAAoB,WAC1B,wCACF;GAEA,YAAY,sBAAsB,CAChC,IAAI,wBAAwB,EAC1B,UAAU,IAAI,gBAAgB;IAC5B,KAAK,GAAG,aAAa;IACrB,SAAS,EACP,cAAc,OAChB;GACF,CAAC,EACH,CAAC,CACH;EACF,QAAQ;GACN,MAAM,IAAI,MACR,gIAEF;EACF;CAEJ;CAEA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"datadog.d.cts","names":[],"sources":["../src/datadog.ts"],"mappings":";;;;;;KA0CY;;;;UAWK;;;;;;;;EAQf;;;;;;;EAQA,OAAO;;;;;EAMP;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;;EAuBA;;;;;;;;;;;;;;EAeA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CR,oBACd,QAAQ,sBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"datadog.d.ts","names":[],"sources":["../src/datadog.ts"],"mappings":";;;;;;KA0CY;;;;UAWK;;;;;;;;EAQf;;;;;;;EAQA,OAAO;;;;;EAMP;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;;;;;;;;;;;;;;;EAuBA;;;;;;;;;;;;;;EAeA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CR,oBACd,QAAQ,sBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"datadog.js","names":[],"sources":["../src/datadog.ts"],"sourcesContent":["/**\n * Datadog preset for autotel\n *\n * Provides a simplified configuration helper for Datadog integration\n * with best practices built-in.\n *\n * @example Direct cloud ingestion (serverless, edge)\n * ```typescript\n * import { init } from 'autotel';\n * import { createDatadogConfig } from 'autotel-backends/datadog';\n *\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-lambda',\n * enableLogs: true,\n * }));\n * ```\n *\n * @example Local Datadog Agent (long-running services, Kubernetes)\n * ```typescript\n * import { init } from 'autotel';\n * import { createDatadogConfig } from 'autotel-backends/datadog';\n *\n * init(createDatadogConfig({\n * service: 'my-api',\n * useAgent: true, // No API key needed - Agent handles it\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\nimport type { LogRecordProcessor } from '@opentelemetry/sdk-logs';\n\n// `__filename` exists under CJS (including esbuild's CJS output wrapper) but\n// not pure ESM. `typeof` is safe against an undeclared identifier and lets\n// the conditional pick the working URL in either format.\ndeclare const __filename: string | undefined;\n\n/**\n * Datadog site regions\n */\nexport type DatadogSite =\n | 'datadoghq.com' // US1 (default)\n | 'datadoghq.eu' // EU\n | 'us3.datadoghq.com' // US3\n | 'us5.datadoghq.com' // US5\n | 'ap1.datadoghq.com' // AP1\n | 'ddog-gov.com'; // US1-FED\n\n/**\n * Configuration options for Datadog preset\n */\nexport interface DatadogPresetConfig {\n /**\n * Datadog API key (required for direct cloud ingestion).\n * Not needed if using local Datadog Agent (useAgent: true).\n *\n * Get your API key from:\n * https://app.datadoghq.com/organization-settings/api-keys\n */\n apiKey?: string;\n\n /**\n * Datadog site/region.\n * Determines which Datadog intake endpoint to use.\n *\n * @default 'datadoghq.com' (US1)\n */\n site?: DatadogSite;\n\n /**\n * Service name (required).\n * Appears in Datadog APM, Service Catalog, and all telemetry.\n */\n service: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging', 'development').\n * Used for environment filtering in Datadog.\n *\n * @default process.env.DD_ENV || process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n * Enables Deployment Tracking in Datadog APM.\n *\n * @default process.env.DD_VERSION || auto-detected from package.json\n */\n version?: string;\n\n /**\n * Enable log export to Datadog via OTLP.\n *\n * When enabled, this:\n * 1. Sets up OTel Logs SDK with OTLP exporter (for direct OTel logs API usage)\n * 2. Auto-configures OTEL_EXPORTER_OTLP_LOGS_* env vars for pino-opentelemetry-transport\n *\n * For Pino users: Just add pino-opentelemetry-transport to your logger config:\n * ```typescript\n * const logger = pino({\n * transport: {\n * targets: [\n * { target: 'pino-pretty' },\n * { target: 'pino-opentelemetry-transport' }, // Auto-configured!\n * ],\n * },\n * });\n * ```\n *\n * @default false\n */\n enableLogs?: boolean;\n\n /**\n * Use local Datadog Agent instead of direct cloud ingestion.\n *\n * Benefits:\n * - Lower egress costs (Agent aggregates locally)\n * - Advanced features: trace-log correlation, multi-line logs, data scrubbing\n * - 500+ integrations for enrichment\n * - Infrastructure metrics collection\n *\n * Requires: Datadog Agent 7.35+ with OTLP enabled\n *\n * @default false\n */\n useAgent?: boolean;\n\n /**\n * Datadog Agent hostname (when useAgent: true).\n *\n * @default 'localhost'\n */\n agentHost?: string;\n\n /**\n * Datadog Agent OTLP port (when useAgent: true).\n *\n * @default 4318 (OTLP HTTP)\n */\n agentPort?: number;\n\n /**\n * Custom log record processors (advanced).\n * Overrides the default log processor if enableLogs is true.\n */\n logRecordProcessors?: LogRecordProcessor[];\n}\n\n/**\n * Create an autotel configuration optimized for Datadog.\n *\n * This preset handles:\n * - Proper OTLP endpoint configuration (Agent vs direct ingestion)\n * - Direct: https://otlp.{site} → SDK appends /v1/traces, /v1/metrics, /v1/logs\n * - Agent: http://localhost:4318 (default)\n * - Datadog API key authentication headers (direct ingestion only)\n * - Unified service tagging (service, env, version)\n * - Resource attribute best practices\n * - Optional log export configuration\n *\n * @param config - Datadog-specific configuration options\n * @returns AutotelConfig ready to pass to init()\n *\n * @example Simple cloud ingestion\n * ```typescript\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With logs and custom environment\n * ```typescript\n * init(createDatadogConfig({\n * apiKey: process.env.DATADOG_API_KEY!,\n * service: 'my-app',\n * environment: 'production',\n * version: '2.1.0',\n * enableLogs: true,\n * }));\n * ```\n *\n * @example Using local Datadog Agent\n * ```typescript\n * init(createDatadogConfig({\n * service: 'my-api',\n * useAgent: true,\n * agentHost: 'datadog-agent.default.svc.cluster.local', // Kubernetes\n * }));\n * ```\n */\nexport function createDatadogConfig(\n config: DatadogPresetConfig,\n): AutotelConfig {\n const {\n apiKey,\n site = 'datadoghq.com',\n service,\n environment,\n version,\n enableLogs = false,\n useAgent = false,\n agentHost = 'localhost',\n agentPort = 4318,\n logRecordProcessors,\n } = config;\n\n // Validation: API key required for direct ingestion\n if (!useAgent && !apiKey) {\n throw new Error(\n 'Datadog API key is required for direct cloud ingestion. ' +\n 'Either provide apiKey or set useAgent: true to use local Datadog Agent.',\n );\n }\n\n const baseConfig: AutotelConfig = {\n service,\n environment,\n version,\n };\n\n // Local Datadog Agent configuration\n if (useAgent) {\n const agentEndpoint = `http://${agentHost}:${agentPort}`;\n\n // Auto-configure env vars for pino-opentelemetry-transport in agent mode\n if (enableLogs) {\n const logsEndpoint = `http://${agentHost}:${agentPort}/v1/logs`;\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;\n }\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'http/protobuf';\n }\n\n // No API key header needed for agent mode - Agent handles authentication\n\n const resourceAttrs = [\n `service.name=${service}`,\n environment ? `deployment.environment=${environment}` : null,\n version ? `service.version=${version}` : null,\n ]\n .filter(Boolean)\n .join(',');\n\n if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {\n process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;\n }\n }\n\n return {\n ...baseConfig,\n endpoint: agentEndpoint,\n // No API key or headers needed - Agent handles authentication\n };\n }\n\n // Direct cloud ingestion configuration\n // Datadog OTLP endpoint: base URL without path (SDK appends /v1/traces, /v1/metrics, /v1/logs)\n const otlpEndpoint = `https://otlp.${site}`;\n const authHeaders = `dd-api-key=${apiKey}`;\n\n const cloudConfig: AutotelConfig = {\n ...baseConfig,\n endpoint: otlpEndpoint,\n headers: authHeaders,\n };\n\n // Add log export if enabled\n if (enableLogs) {\n // Auto-configure env vars for pino-opentelemetry-transport and other OTel log transports\n // These are read by pino-opentelemetry-transport, otlp-logger, and similar libraries\n const logsEndpoint = useAgent\n ? `http://${agentHost}:${agentPort}/v1/logs`\n : `https://otlp.${site}/v1/logs`;\n\n // Only set if not already configured (allow user override)\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;\n }\n\n if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = 'http/protobuf';\n }\n\n // Only set API key header for direct cloud ingestion (not agent mode)\n if (!useAgent && apiKey && !process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS) {\n process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS = `dd-api-key=${apiKey}`;\n }\n\n // Set resource attributes for service identification\n const resourceAttrs = [\n `service.name=${service}`,\n environment ? `deployment.environment=${environment}` : null,\n version ? `service.version=${version}` : null,\n ]\n .filter(Boolean)\n .join(',');\n\n if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {\n process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;\n }\n\n if (logRecordProcessors) {\n // Use custom processors if provided\n cloudConfig.logRecordProcessors = logRecordProcessors;\n } else {\n // Create default OTLP log exporter\n try {\n const pkgRequire = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n );\n const { BatchLogRecordProcessor } = pkgRequire(\n '@opentelemetry/sdk-logs',\n );\n const { OTLPLogExporter } = pkgRequire(\n '@opentelemetry/exporter-logs-otlp-http',\n );\n\n cloudConfig.logRecordProcessors = [\n new BatchLogRecordProcessor({\n exporter: new OTLPLogExporter({\n url: `${otlpEndpoint}/v1/logs`,\n headers: {\n 'dd-api-key': apiKey,\n },\n }),\n }),\n ];\n } catch {\n throw new Error(\n 'Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. ' +\n 'Install them or set enableLogs: false.',\n );\n }\n }\n }\n\n return cloudConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmMA,SAAgB,oBACd,QACe;CACf,MAAM,EACJ,QACA,OAAO,iBACP,SACA,aACA,SACA,aAAa,OACb,WAAW,OACX,YAAY,aACZ,YAAY,MACZ,wBACE;CAGJ,IAAI,CAAC,YAAY,CAAC,QAChB,MAAM,IAAI,MACR,iIAEF;CAGF,MAAM,aAA4B;EAChC;EACA;EACA;CACF;CAGA,IAAI,UAAU;EACZ,MAAM,gBAAgB,UAAU,UAAU,GAAG;EAG7C,IAAI,YAAY;GACd,MAAM,eAAe,UAAU,UAAU,GAAG,UAAU;GAEtD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;GAGjD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;GAKjD,MAAM,gBAAgB;IACpB,gBAAgB;IAChB,cAAc,0BAA0B,gBAAgB;IACxD,UAAU,mBAAmB,YAAY;GAC3C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;GAEX,IAAI,CAAC,QAAQ,IAAI,0BACf,QAAQ,IAAI,2BAA2B;EAE3C;EAEA,OAAO;GACL,GAAG;GACH,UAAU;EAEZ;CACF;CAIA,MAAM,eAAe,gBAAgB;CACrC,MAAM,cAAc,cAAc;CAElC,MAAM,cAA6B;EACjC,GAAG;EACH,UAAU;EACV,SAAS;CACX;CAGA,IAAI,YAAY;EAGd,MAAM,eAAe,WACjB,UAAU,UAAU,GAAG,UAAU,YACjC,gBAAgB,KAAK;EAGzB,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;EAGjD,IAAI,CAAC,QAAQ,IAAI,kCACf,QAAQ,IAAI,mCAAmC;EAIjD,IAAI,CAAC,YAAY,UAAU,CAAC,QAAQ,IAAI,iCACtC,QAAQ,IAAI,kCAAkC,cAAc;EAI9D,MAAM,gBAAgB;GACpB,gBAAgB;GAChB,cAAc,0BAA0B,gBAAgB;GACxD,UAAU,mBAAmB,YAAY;EAC3C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;EAEX,IAAI,CAAC,QAAQ,IAAI,0BACf,QAAQ,IAAI,2BAA2B;EAGzC,IAAI,qBAEF,YAAY,sBAAsB;OAGlC,IAAI;GACF,MAAM,aAAa,cACjB,OAAO,eAAe,WAAW,aAAa,OAAO,KAAK,GAC5D;GACA,MAAM,EAAE,4BAA4B,WAClC,yBACF;GACA,MAAM,EAAE,oBAAoB,WAC1B,wCACF;GAEA,YAAY,sBAAsB,CAChC,IAAI,wBAAwB,EAC1B,UAAU,IAAI,gBAAgB;IAC5B,KAAK,GAAG,aAAa;IACrB,SAAS,EACP,cAAc,OAChB;GACF,CAAC,EACH,CAAC,CACH;EACF,QAAQ;GACN,MAAM,IAAI,MACR,gIAEF;EACF;CAEJ;CAEA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-cloud.cjs","names":[],"sources":["../src/google-cloud.ts"],"sourcesContent":["/**\n * Google Cloud preset for autotel\n *\n * Sends traces (and optionally metrics) to Google Cloud Observability via the\n * Telemetry (OTLP) API. Uses Application Default Credentials (ADC) for auth.\n *\n * @example Direct export to GCP (with google-auth-library)\n * ```typescript\n * import { init } from 'autotel';\n * import { createGoogleCloudConfig } from 'autotel-backends/google-cloud';\n *\n * init(createGoogleCloudConfig({\n * projectId: process.env.GOOGLE_CLOUD_PROJECT!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example Via OpenTelemetry Collector (no auth in app)\n * ```typescript\n * init(createGoogleCloudConfig({\n * projectId: process.env.GOOGLE_CLOUD_PROJECT!,\n * service: 'my-app',\n * useCollector: true,\n * collectorEndpoint: 'http://localhost:4318',\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\n\n/** Minimal SpanExporter-compatible interface (avoids @opentelemetry/sdk-trace-base peer at build time). */\ninterface SpanExporterLike {\n export(\n spans: unknown[],\n resultCallback: (result: { code: number; error?: Error }) => void,\n ): void | Promise<void>;\n forceFlush?(): Promise<void>;\n shutdown?(): Promise<void>;\n}\n\n/** Default Telemetry API base URL (OTLP). */\nconst DEFAULT_ENDPOINT = 'https://telemetry.googleapis.com';\n\n/**\n * Configuration options for Google Cloud preset\n */\nexport interface GoogleCloudPresetConfig {\n /**\n * Google Cloud project ID (required for direct export).\n * Used for quota and resource attribution. Set GOOGLE_CLOUD_PROJECT or\n * GOOGLE_APPLICATION_CREDENTIALS for ADC.\n *\n * @default process.env.GOOGLE_CLOUD_PROJECT\n */\n projectId: string;\n\n /**\n * Service name (required).\n * Appears as service.name in Cloud Trace and Monitoring.\n */\n service: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging').\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.GCP_VERSION || process.env.VERSION\n */\n version?: string;\n\n /**\n * Use an OpenTelemetry Collector instead of exporting directly to GCP.\n * When true, the app sends OTLP to collectorEndpoint; the Collector\n * handles authentication to the Telemetry API. No google-auth-library needed.\n *\n * @default false\n */\n useCollector?: boolean;\n\n /**\n * Collector OTLP endpoint (when useCollector is true).\n *\n * @default 'http://localhost:4318'\n */\n collectorEndpoint?: string;\n\n /**\n * Telemetry API base URL (when useCollector is false).\n * Only override for testing or special endpoints.\n *\n * @default 'https://telemetry.googleapis.com'\n */\n endpoint?: string;\n}\n\n/**\n * Create an autotel configuration for Google Cloud Observability (Telemetry API).\n *\n * - With useCollector: false (default), exports directly to the Telemetry API\n * using Application Default Credentials. Requires optional peer dependency\n * google-auth-library for auth. Install: pnpm add google-auth-library\n *\n * - With useCollector: true, sends OTLP to a local Collector; the Collector\n * forwards to GCP with ADC. No google-auth-library needed in the app.\n *\n * @param config - Google Cloud preset options\n * @returns AutotelConfig ready to pass to init()\n */\nexport function createGoogleCloudConfig(\n config: GoogleCloudPresetConfig,\n): AutotelConfig {\n const {\n projectId,\n service,\n environment,\n version,\n useCollector = false,\n collectorEndpoint = 'http://localhost:4318',\n endpoint = DEFAULT_ENDPOINT,\n } = config;\n\n if (!projectId) {\n throw new Error(\n 'Google Cloud projectId is required. Set it or use process.env.GOOGLE_CLOUD_PROJECT.',\n );\n }\n\n const baseConfig: AutotelConfig = {\n service,\n environment,\n version,\n };\n\n if (useCollector) {\n return {\n ...baseConfig,\n endpoint: collectorEndpoint,\n // x-goog-user-project for quota when Collector forwards to GCP\n headers: { 'x-goog-user-project': projectId },\n };\n }\n\n // Direct export: need ADC via google-auth-library\n try {\n const userRequire = createRequire(process.cwd() + '/package.json');\n const { GoogleAuth } = userRequire('google-auth-library');\n const { OTLPTraceExporter } = userRequire(\n '@opentelemetry/exporter-trace-otlp-http',\n );\n\n const tracesUrl = `${endpoint}/v1/traces`;\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n });\n\n const gcpTraceExporter = createGcpAuthTraceExporter(\n tracesUrl,\n projectId,\n auth,\n OTLPTraceExporter,\n );\n\n return {\n ...baseConfig,\n // Structurally compatible with SpanExporter from @opentelemetry/sdk-trace-base\n spanExporters: [\n gcpTraceExporter as NonNullable<AutotelConfig['spanExporters']>[number],\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (\n message.includes('google-auth-library') ||\n message.includes('Cannot find module')\n ) {\n throw new Error(\n 'Direct export to Google Cloud requires google-auth-library. ' +\n 'Install it: pnpm add google-auth-library. ' +\n 'Or use useCollector: true and run an OpenTelemetry Collector with GCP auth.',\n { cause: error },\n );\n }\n throw error;\n }\n}\n\n/** Minimal auth client: getClient() returns a client with getAccessToken(). */\ninterface GoogleAuthLike {\n getClient(): Promise<{ getAccessToken(): Promise<{ token: string | null }> }>;\n}\n\ntype OTLPTraceExporterCtor = new (config: {\n url: string;\n headers?: Record<string, string>;\n}) => SpanExporterLike;\n\nfunction createGcpAuthTraceExporter(\n url: string,\n projectId: string,\n auth: GoogleAuthLike,\n OTLPTraceExporterCtor: OTLPTraceExporterCtor,\n): SpanExporterLike {\n return new GcpAuthSpanExporter(url, projectId, auth, OTLPTraceExporterCtor);\n}\n\nclass GcpAuthSpanExporter implements SpanExporterLike {\n constructor(\n private readonly url: string,\n private readonly projectId: string,\n private readonly auth: GoogleAuthLike,\n private readonly OTLPTraceExporterCtor: OTLPTraceExporterCtor,\n ) {}\n\n async export(\n spans: unknown[],\n resultCallback: (result: { code: number; error?: Error }) => void,\n ): Promise<void> {\n try {\n const client = await this.auth.getClient();\n const tokenResponse = await client.getAccessToken();\n const token = tokenResponse.token;\n if (!token) {\n resultCallback({\n code: 1,\n error: new Error('No access token from ADC'),\n });\n return;\n }\n const exporter = new this.OTLPTraceExporterCtor({\n url: this.url,\n headers: {\n Authorization: `Bearer ${token}`,\n 'x-goog-user-project': this.projectId,\n },\n });\n exporter.export(spans, resultCallback);\n } catch (error) {\n resultCallback({\n code: 1,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,mBAAmB;;;;;;;;;;;;;;AAyEzB,SAAgB,wBACd,QACe;CACf,MAAM,EACJ,WACA,SACA,aACA,SACA,eAAe,OACf,oBAAoB,yBACpB,WAAW,qBACT;CAEJ,IAAI,CAAC,WACH,MAAM,IAAI,MACR,qFACF;CAGF,MAAM,aAA4B;EAChC;EACA;EACA;CACF;CAEA,IAAI,cACF,OAAO;EACL,GAAG;EACH,UAAU;EAEV,SAAS,EAAE,uBAAuB,UAAU;CAC9C;CAIF,IAAI;EACF,MAAM,eAAA,GAAA,YAAA,cAAA,CAA4B,QAAQ,IAAI,IAAI,eAAe;EACjE,MAAM,EAAE,eAAe,YAAY,qBAAqB;EACxD,MAAM,EAAE,sBAAsB,YAC5B,yCACF;EAOA,MAAM,mBAAmB,2BACvB,GANmB,SAAS,aAO5B,WACA,IAPe,WAAW,EAC1B,QAAQ,CAAC,gDAAgD,EAC3D,CAKK,GACH,iBACF;EAEA,OAAO;GACL,GAAG;GAEH,eAAe,CACb,gBACF;EACF;CACF,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,IACE,QAAQ,SAAS,qBAAqB,KACtC,QAAQ,SAAS,oBAAoB,GAErC,MAAM,IAAI,MACR,qLAGA,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;AACF;AAYA,SAAS,2BACP,KACA,WACA,MACA,uBACkB;CAClB,OAAO,IAAI,oBAAoB,KAAK,WAAW,MAAM,qBAAqB;AAC5E;AAEA,IAAM,sBAAN,MAAsD;CAEjC;CACA;CACA;CACA;CAJnB,YACE,KACA,WACA,MACA,uBACA;EAJiB,KAAA,MAAA;EACA,KAAA,YAAA;EACA,KAAA,OAAA;EACA,KAAA,wBAAA;CAChB;CAEH,MAAM,OACJ,OACA,gBACe;EACf,IAAI;GAGF,MAAM,SAAQ,OADc,MADP,KAAK,KAAK,UAAU,EAAA,CACN,eAAe,EAAA,CACtB;GAC5B,IAAI,CAAC,OAAO;IACV,eAAe;KACb,MAAM;KACN,uBAAO,IAAI,MAAM,0BAA0B;IAC7C,CAAC;IACD;GACF;GAQA,IAPqB,KAAK,sBAAsB;IAC9C,KAAK,KAAK;IACV,SAAS;KACP,eAAe,UAAU;KACzB,uBAAuB,KAAK;IAC9B;GACF,CACO,CAAC,CAAC,OAAO,OAAO,cAAc;EACvC,SAAS,OAAO;GACd,eAAe;IACb,MAAM;IACN,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GACjE,CAAC;EACH;CACF;CAEA,aAA4B;EAC1B,OAAO,QAAQ,QAAQ;CACzB;CAEA,WAA0B;EACxB,OAAO,QAAQ,QAAQ;CACzB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-cloud.d.cts","names":[],"sources":["../src/google-cloud.ts"],"mappings":";;;;;UA+CiB;;;;;;;;EAQf;;;;;EAMA;;;;;;EAOA;;;;;;EAOA;;;;;;;;EASA;;;;;;EAOA;;;;;;;EAQA;;;;;;;;;;;;;;;iBAgBc,wBACd,QAAQ,0BACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-cloud.d.ts","names":[],"sources":["../src/google-cloud.ts"],"mappings":";;;;;UA+CiB;;;;;;;;EAQf;;;;;EAMA;;;;;;EAOA;;;;;;EAOA;;;;;;;;EASA;;;;;;EAOA;;;;;;;EAQA;;;;;;;;;;;;;;;iBAgBc,wBACd,QAAQ,0BACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-cloud.js","names":[],"sources":["../src/google-cloud.ts"],"sourcesContent":["/**\n * Google Cloud preset for autotel\n *\n * Sends traces (and optionally metrics) to Google Cloud Observability via the\n * Telemetry (OTLP) API. Uses Application Default Credentials (ADC) for auth.\n *\n * @example Direct export to GCP (with google-auth-library)\n * ```typescript\n * import { init } from 'autotel';\n * import { createGoogleCloudConfig } from 'autotel-backends/google-cloud';\n *\n * init(createGoogleCloudConfig({\n * projectId: process.env.GOOGLE_CLOUD_PROJECT!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example Via OpenTelemetry Collector (no auth in app)\n * ```typescript\n * init(createGoogleCloudConfig({\n * projectId: process.env.GOOGLE_CLOUD_PROJECT!,\n * service: 'my-app',\n * useCollector: true,\n * collectorEndpoint: 'http://localhost:4318',\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\n\n/** Minimal SpanExporter-compatible interface (avoids @opentelemetry/sdk-trace-base peer at build time). */\ninterface SpanExporterLike {\n export(\n spans: unknown[],\n resultCallback: (result: { code: number; error?: Error }) => void,\n ): void | Promise<void>;\n forceFlush?(): Promise<void>;\n shutdown?(): Promise<void>;\n}\n\n/** Default Telemetry API base URL (OTLP). */\nconst DEFAULT_ENDPOINT = 'https://telemetry.googleapis.com';\n\n/**\n * Configuration options for Google Cloud preset\n */\nexport interface GoogleCloudPresetConfig {\n /**\n * Google Cloud project ID (required for direct export).\n * Used for quota and resource attribution. Set GOOGLE_CLOUD_PROJECT or\n * GOOGLE_APPLICATION_CREDENTIALS for ADC.\n *\n * @default process.env.GOOGLE_CLOUD_PROJECT\n */\n projectId: string;\n\n /**\n * Service name (required).\n * Appears as service.name in Cloud Trace and Monitoring.\n */\n service: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging').\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.GCP_VERSION || process.env.VERSION\n */\n version?: string;\n\n /**\n * Use an OpenTelemetry Collector instead of exporting directly to GCP.\n * When true, the app sends OTLP to collectorEndpoint; the Collector\n * handles authentication to the Telemetry API. No google-auth-library needed.\n *\n * @default false\n */\n useCollector?: boolean;\n\n /**\n * Collector OTLP endpoint (when useCollector is true).\n *\n * @default 'http://localhost:4318'\n */\n collectorEndpoint?: string;\n\n /**\n * Telemetry API base URL (when useCollector is false).\n * Only override for testing or special endpoints.\n *\n * @default 'https://telemetry.googleapis.com'\n */\n endpoint?: string;\n}\n\n/**\n * Create an autotel configuration for Google Cloud Observability (Telemetry API).\n *\n * - With useCollector: false (default), exports directly to the Telemetry API\n * using Application Default Credentials. Requires optional peer dependency\n * google-auth-library for auth. Install: pnpm add google-auth-library\n *\n * - With useCollector: true, sends OTLP to a local Collector; the Collector\n * forwards to GCP with ADC. No google-auth-library needed in the app.\n *\n * @param config - Google Cloud preset options\n * @returns AutotelConfig ready to pass to init()\n */\nexport function createGoogleCloudConfig(\n config: GoogleCloudPresetConfig,\n): AutotelConfig {\n const {\n projectId,\n service,\n environment,\n version,\n useCollector = false,\n collectorEndpoint = 'http://localhost:4318',\n endpoint = DEFAULT_ENDPOINT,\n } = config;\n\n if (!projectId) {\n throw new Error(\n 'Google Cloud projectId is required. Set it or use process.env.GOOGLE_CLOUD_PROJECT.',\n );\n }\n\n const baseConfig: AutotelConfig = {\n service,\n environment,\n version,\n };\n\n if (useCollector) {\n return {\n ...baseConfig,\n endpoint: collectorEndpoint,\n // x-goog-user-project for quota when Collector forwards to GCP\n headers: { 'x-goog-user-project': projectId },\n };\n }\n\n // Direct export: need ADC via google-auth-library\n try {\n const userRequire = createRequire(process.cwd() + '/package.json');\n const { GoogleAuth } = userRequire('google-auth-library');\n const { OTLPTraceExporter } = userRequire(\n '@opentelemetry/exporter-trace-otlp-http',\n );\n\n const tracesUrl = `${endpoint}/v1/traces`;\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n });\n\n const gcpTraceExporter = createGcpAuthTraceExporter(\n tracesUrl,\n projectId,\n auth,\n OTLPTraceExporter,\n );\n\n return {\n ...baseConfig,\n // Structurally compatible with SpanExporter from @opentelemetry/sdk-trace-base\n spanExporters: [\n gcpTraceExporter as NonNullable<AutotelConfig['spanExporters']>[number],\n ],\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (\n message.includes('google-auth-library') ||\n message.includes('Cannot find module')\n ) {\n throw new Error(\n 'Direct export to Google Cloud requires google-auth-library. ' +\n 'Install it: pnpm add google-auth-library. ' +\n 'Or use useCollector: true and run an OpenTelemetry Collector with GCP auth.',\n { cause: error },\n );\n }\n throw error;\n }\n}\n\n/** Minimal auth client: getClient() returns a client with getAccessToken(). */\ninterface GoogleAuthLike {\n getClient(): Promise<{ getAccessToken(): Promise<{ token: string | null }> }>;\n}\n\ntype OTLPTraceExporterCtor = new (config: {\n url: string;\n headers?: Record<string, string>;\n}) => SpanExporterLike;\n\nfunction createGcpAuthTraceExporter(\n url: string,\n projectId: string,\n auth: GoogleAuthLike,\n OTLPTraceExporterCtor: OTLPTraceExporterCtor,\n): SpanExporterLike {\n return new GcpAuthSpanExporter(url, projectId, auth, OTLPTraceExporterCtor);\n}\n\nclass GcpAuthSpanExporter implements SpanExporterLike {\n constructor(\n private readonly url: string,\n private readonly projectId: string,\n private readonly auth: GoogleAuthLike,\n private readonly OTLPTraceExporterCtor: OTLPTraceExporterCtor,\n ) {}\n\n async export(\n spans: unknown[],\n resultCallback: (result: { code: number; error?: Error }) => void,\n ): Promise<void> {\n try {\n const client = await this.auth.getClient();\n const tokenResponse = await client.getAccessToken();\n const token = tokenResponse.token;\n if (!token) {\n resultCallback({\n code: 1,\n error: new Error('No access token from ADC'),\n });\n return;\n }\n const exporter = new this.OTLPTraceExporterCtor({\n url: this.url,\n headers: {\n Authorization: `Bearer ${token}`,\n 'x-goog-user-project': this.projectId,\n },\n });\n exporter.export(spans, resultCallback);\n } catch (error) {\n resultCallback({\n code: 1,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve();\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,mBAAmB;;;;;;;;;;;;;;AAyEzB,SAAgB,wBACd,QACe;CACf,MAAM,EACJ,WACA,SACA,aACA,SACA,eAAe,OACf,oBAAoB,yBACpB,WAAW,qBACT;CAEJ,IAAI,CAAC,WACH,MAAM,IAAI,MACR,qFACF;CAGF,MAAM,aAA4B;EAChC;EACA;EACA;CACF;CAEA,IAAI,cACF,OAAO;EACL,GAAG;EACH,UAAU;EAEV,SAAS,EAAE,uBAAuB,UAAU;CAC9C;CAIF,IAAI;EACF,MAAM,cAAc,cAAc,QAAQ,IAAI,IAAI,eAAe;EACjE,MAAM,EAAE,eAAe,YAAY,qBAAqB;EACxD,MAAM,EAAE,sBAAsB,YAC5B,yCACF;EAOA,MAAM,mBAAmB,2BACvB,GANmB,SAAS,aAO5B,WACA,IAPe,WAAW,EAC1B,QAAQ,CAAC,gDAAgD,EAC3D,CAKK,GACH,iBACF;EAEA,OAAO;GACL,GAAG;GAEH,eAAe,CACb,gBACF;EACF;CACF,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,IACE,QAAQ,SAAS,qBAAqB,KACtC,QAAQ,SAAS,oBAAoB,GAErC,MAAM,IAAI,MACR,qLAGA,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;AACF;AAYA,SAAS,2BACP,KACA,WACA,MACA,uBACkB;CAClB,OAAO,IAAI,oBAAoB,KAAK,WAAW,MAAM,qBAAqB;AAC5E;AAEA,IAAM,sBAAN,MAAsD;CAEjC;CACA;CACA;CACA;CAJnB,YACE,KACA,WACA,MACA,uBACA;EAJiB,KAAA,MAAA;EACA,KAAA,YAAA;EACA,KAAA,OAAA;EACA,KAAA,wBAAA;CAChB;CAEH,MAAM,OACJ,OACA,gBACe;EACf,IAAI;GAGF,MAAM,SAAQ,OADc,MADP,KAAK,KAAK,UAAU,EAAA,CACN,eAAe,EAAA,CACtB;GAC5B,IAAI,CAAC,OAAO;IACV,eAAe;KACb,MAAM;KACN,uBAAO,IAAI,MAAM,0BAA0B;IAC7C,CAAC;IACD;GACF;GAQA,IAPqB,KAAK,sBAAsB;IAC9C,KAAK,KAAK;IACV,SAAS;KACP,eAAe,UAAU;KACzB,uBAAuB,KAAK;IAC9B;GACF,CACO,CAAC,CAAC,OAAO,OAAO,cAAc;EACvC,SAAS,OAAO;GACd,eAAe;IACb,MAAM;IACN,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GACjE,CAAC;EACH;CACF;CAEA,aAA4B;EAC1B,OAAO,QAAQ,QAAQ;CACzB;CAEA,WAA0B;EACxB,OAAO,QAAQ,QAAQ;CACzB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"grafana.cjs","names":[],"sources":["../src/grafana.ts"],"sourcesContent":["/**\n * Grafana Cloud preset for autotel\n *\n * Provides a simplified configuration helper for sending traces, metrics,\n * and logs to Grafana Cloud via the OTLP gateway.\n *\n * Get your endpoint and headers from:\n * Grafana Cloud Portal → your stack → Connections → OpenTelemetry → Configure\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n * import { createGrafanaConfig } from 'autotel-backends/grafana';\n *\n * init(createGrafanaConfig({\n * endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT!,\n * headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,\n * service: 'my-app',\n * enableLogs: true,\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\nimport type { LogRecordProcessor } from '@opentelemetry/sdk-logs';\n\n// See packages/autotel/src/node-require.ts for why the __filename fallback\n// is necessary alongside import.meta.url.\ndeclare const __filename: string | undefined;\n\n/**\n * Configuration options for Grafana Cloud preset\n */\nexport interface GrafanaPresetConfig {\n /**\n * OTLP gateway endpoint (required).\n * From Grafana Cloud: Stack → Connections → OpenTelemetry → Configure.\n * Example: https://otlp-gateway-prod-gb-south-1.grafana.net/otlp\n */\n endpoint: string;\n\n /**\n * OTLP authentication headers.\n * From the same Configure tile; usually Basic auth.\n * Example: \"Authorization=Basic%20BASE64_INSTANCE_ID_AND_TOKEN\"\n * or object: { Authorization: 'Basic ...' }\n */\n headers?: string | Record<string, string>;\n\n /**\n * Service name (required).\n * Appears in Tempo, Mimir, and Loki as service_name.\n */\n service: string;\n\n /**\n * Deployment environment (e.g. 'production', 'staging').\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.OTEL_SERVICE_VERSION\n */\n version?: string;\n\n /**\n * Enable log export to Grafana Cloud (Loki) via OTLP.\n * When true, configures logRecordProcessors so OTel Logs API records are exported.\n *\n * @default true\n */\n enableLogs?: boolean;\n\n /**\n * Custom log record processors (advanced).\n * Overrides the default OTLP log processor when enableLogs is true.\n */\n logRecordProcessors?: LogRecordProcessor[];\n}\n\nfunction normalizeHeaders(\n headers: string | Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!headers) return undefined;\n if (typeof headers === 'object') return headers;\n const out: Record<string, string> = {};\n for (const pair of headers.split(',')) {\n const [key, ...valueParts] = pair.split('=');\n if (key && valueParts.length > 0) {\n let value = valueParts.join('=').trim();\n value = value.replaceAll('%20', ' ');\n out[key.trim()] = value;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/**\n * Create an autotel configuration for Grafana Cloud OTLP.\n *\n * Sends traces (Tempo), metrics (Mimir), and optionally logs (Loki) to the\n * Grafana Cloud OTLP gateway. Endpoint and headers come from the stack's\n * Connections → OpenTelemetry → Configure tile.\n *\n * @param config - Grafana Cloud configuration options\n * @returns AutotelConfig ready to pass to init()\n */\nexport function createGrafanaConfig(\n config: GrafanaPresetConfig,\n): AutotelConfig {\n const {\n endpoint,\n headers: headersInput,\n service,\n environment,\n version,\n enableLogs = true,\n logRecordProcessors,\n } = config;\n\n if (!endpoint) {\n throw new Error(\n 'Grafana Cloud endpoint is required. Get it from: Grafana Cloud → your stack → Connections → OpenTelemetry → Configure',\n );\n }\n\n const headers = normalizeHeaders(headersInput);\n const base = endpoint.replace(/\\/v1\\/(traces|metrics|logs)$/, '');\n const logsUrl = `${base}${base.endsWith('/') ? '' : '/'}v1/logs`;\n\n const result: AutotelConfig = {\n service,\n environment,\n version,\n endpoint,\n headers,\n metrics: true,\n };\n\n if (enableLogs) {\n if (logRecordProcessors) {\n result.logRecordProcessors = logRecordProcessors;\n } else {\n try {\n const pkgRequire = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n );\n const { BatchLogRecordProcessor } = pkgRequire(\n '@opentelemetry/sdk-logs',\n );\n const { OTLPLogExporter } = pkgRequire(\n '@opentelemetry/exporter-logs-otlp-http',\n );\n result.logRecordProcessors = [\n new BatchLogRecordProcessor({\n exporter: new OTLPLogExporter({\n url: logsUrl,\n headers,\n }),\n }),\n ];\n } catch {\n throw new Error(\n 'Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. ' +\n 'Install them or set enableLogs: false.',\n );\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAS,iBACP,SACoC;CACpC,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,QAAQ,QAAQ,MAAM,GAAG,GAAG;EACrC,MAAM,CAAC,KAAK,GAAG,cAAc,KAAK,MAAM,GAAG;EAC3C,IAAI,OAAO,WAAW,SAAS,GAAG;GAChC,IAAI,QAAQ,WAAW,KAAK,GAAG,CAAC,CAAC,KAAK;GACtC,QAAQ,MAAM,WAAW,OAAO,GAAG;GACnC,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;CACA,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,KAAA;AAC7C;;;;;;;;;;;AAYA,SAAgB,oBACd,QACe;CACf,MAAM,EACJ,UACA,SAAS,cACT,SACA,aACA,SACA,aAAa,MACb,wBACE;CAEJ,IAAI,CAAC,UACH,MAAM,IAAI,MACR,uHACF;CAGF,MAAM,UAAU,iBAAiB,YAAY;CAC7C,MAAM,OAAO,SAAS,QAAQ,gCAAgC,EAAE;CAChE,MAAM,UAAU,GAAG,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,IAAI;CAExD,MAAM,SAAwB;EAC5B;EACA;EACA;EACA;EACA;EACA,SAAS;CACX;CAEA,IAAI,YACF,IAAI,qBACF,OAAO,sBAAsB;MAE7B,IAAI;EACF,MAAM,cAAA,GAAA,YAAA,cAAA,CACJ,OAAO,eAAe,WAAW,aAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,IACnC;EACA,MAAM,EAAE,4BAA4B,WAClC,yBACF;EACA,MAAM,EAAE,oBAAoB,WAC1B,wCACF;EACA,OAAO,sBAAsB,CAC3B,IAAI,wBAAwB,EAC1B,UAAU,IAAI,gBAAgB;GAC5B,KAAK;GACL;EACF,CAAC,EACH,CAAC,CACH;CACF,QAAQ;EACN,MAAM,IAAI,MACR,gIAEF;CACF;CAIJ,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"grafana.d.cts","names":[],"sources":["../src/grafana.ts"],"mappings":";;;;;;UAkCiB;;;;;;EAMf;;;;;;;EAQA,mBAAmB;;;;;EAMnB;;;;;;EAOA;;;;;;EAOA;;;;;;;EAQA;;;;;EAMA,sBAAsB;;;;;;;;;;;;iBA8BR,oBACd,QAAQ,sBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"grafana.d.ts","names":[],"sources":["../src/grafana.ts"],"mappings":";;;;;;UAkCiB;;;;;;EAMf;;;;;;;EAQA,mBAAmB;;;;;EAMnB;;;;;;EAOA;;;;;;EAOA;;;;;;;EAQA;;;;;EAMA,sBAAsB;;;;;;;;;;;;iBA8BR,oBACd,QAAQ,sBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"grafana.js","names":[],"sources":["../src/grafana.ts"],"sourcesContent":["/**\n * Grafana Cloud preset for autotel\n *\n * Provides a simplified configuration helper for sending traces, metrics,\n * and logs to Grafana Cloud via the OTLP gateway.\n *\n * Get your endpoint and headers from:\n * Grafana Cloud Portal → your stack → Connections → OpenTelemetry → Configure\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n * import { createGrafanaConfig } from 'autotel-backends/grafana';\n *\n * init(createGrafanaConfig({\n * endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT!,\n * headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,\n * service: 'my-app',\n * enableLogs: true,\n * }));\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport type { AutotelConfig } from 'autotel';\nimport type { LogRecordProcessor } from '@opentelemetry/sdk-logs';\n\n// See packages/autotel/src/node-require.ts for why the __filename fallback\n// is necessary alongside import.meta.url.\ndeclare const __filename: string | undefined;\n\n/**\n * Configuration options for Grafana Cloud preset\n */\nexport interface GrafanaPresetConfig {\n /**\n * OTLP gateway endpoint (required).\n * From Grafana Cloud: Stack → Connections → OpenTelemetry → Configure.\n * Example: https://otlp-gateway-prod-gb-south-1.grafana.net/otlp\n */\n endpoint: string;\n\n /**\n * OTLP authentication headers.\n * From the same Configure tile; usually Basic auth.\n * Example: \"Authorization=Basic%20BASE64_INSTANCE_ID_AND_TOKEN\"\n * or object: { Authorization: 'Basic ...' }\n */\n headers?: string | Record<string, string>;\n\n /**\n * Service name (required).\n * Appears in Tempo, Mimir, and Loki as service_name.\n */\n service: string;\n\n /**\n * Deployment environment (e.g. 'production', 'staging').\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.OTEL_SERVICE_VERSION\n */\n version?: string;\n\n /**\n * Enable log export to Grafana Cloud (Loki) via OTLP.\n * When true, configures logRecordProcessors so OTel Logs API records are exported.\n *\n * @default true\n */\n enableLogs?: boolean;\n\n /**\n * Custom log record processors (advanced).\n * Overrides the default OTLP log processor when enableLogs is true.\n */\n logRecordProcessors?: LogRecordProcessor[];\n}\n\nfunction normalizeHeaders(\n headers: string | Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!headers) return undefined;\n if (typeof headers === 'object') return headers;\n const out: Record<string, string> = {};\n for (const pair of headers.split(',')) {\n const [key, ...valueParts] = pair.split('=');\n if (key && valueParts.length > 0) {\n let value = valueParts.join('=').trim();\n value = value.replaceAll('%20', ' ');\n out[key.trim()] = value;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/**\n * Create an autotel configuration for Grafana Cloud OTLP.\n *\n * Sends traces (Tempo), metrics (Mimir), and optionally logs (Loki) to the\n * Grafana Cloud OTLP gateway. Endpoint and headers come from the stack's\n * Connections → OpenTelemetry → Configure tile.\n *\n * @param config - Grafana Cloud configuration options\n * @returns AutotelConfig ready to pass to init()\n */\nexport function createGrafanaConfig(\n config: GrafanaPresetConfig,\n): AutotelConfig {\n const {\n endpoint,\n headers: headersInput,\n service,\n environment,\n version,\n enableLogs = true,\n logRecordProcessors,\n } = config;\n\n if (!endpoint) {\n throw new Error(\n 'Grafana Cloud endpoint is required. Get it from: Grafana Cloud → your stack → Connections → OpenTelemetry → Configure',\n );\n }\n\n const headers = normalizeHeaders(headersInput);\n const base = endpoint.replace(/\\/v1\\/(traces|metrics|logs)$/, '');\n const logsUrl = `${base}${base.endsWith('/') ? '' : '/'}v1/logs`;\n\n const result: AutotelConfig = {\n service,\n environment,\n version,\n endpoint,\n headers,\n metrics: true,\n };\n\n if (enableLogs) {\n if (logRecordProcessors) {\n result.logRecordProcessors = logRecordProcessors;\n } else {\n try {\n const pkgRequire = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n );\n const { BatchLogRecordProcessor } = pkgRequire(\n '@opentelemetry/sdk-logs',\n );\n const { OTLPLogExporter } = pkgRequire(\n '@opentelemetry/exporter-logs-otlp-http',\n );\n result.logRecordProcessors = [\n new BatchLogRecordProcessor({\n exporter: new OTLPLogExporter({\n url: logsUrl,\n headers,\n }),\n }),\n ];\n } catch {\n throw new Error(\n 'Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. ' +\n 'Install them or set enableLogs: false.',\n );\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAS,iBACP,SACoC;CACpC,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,MAAM,MAA8B,CAAC;CACrC,KAAK,MAAM,QAAQ,QAAQ,MAAM,GAAG,GAAG;EACrC,MAAM,CAAC,KAAK,GAAG,cAAc,KAAK,MAAM,GAAG;EAC3C,IAAI,OAAO,WAAW,SAAS,GAAG;GAChC,IAAI,QAAQ,WAAW,KAAK,GAAG,CAAC,CAAC,KAAK;GACtC,QAAQ,MAAM,WAAW,OAAO,GAAG;GACnC,IAAI,IAAI,KAAK,KAAK;EACpB;CACF;CACA,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM,KAAA;AAC7C;;;;;;;;;;;AAYA,SAAgB,oBACd,QACe;CACf,MAAM,EACJ,UACA,SAAS,cACT,SACA,aACA,SACA,aAAa,MACb,wBACE;CAEJ,IAAI,CAAC,UACH,MAAM,IAAI,MACR,uHACF;CAGF,MAAM,UAAU,iBAAiB,YAAY;CAC7C,MAAM,OAAO,SAAS,QAAQ,gCAAgC,EAAE;CAChE,MAAM,UAAU,GAAG,OAAO,KAAK,SAAS,GAAG,IAAI,KAAK,IAAI;CAExD,MAAM,SAAwB;EAC5B;EACA;EACA;EACA;EACA;EACA,SAAS;CACX;CAEA,IAAI,YACF,IAAI,qBACF,OAAO,sBAAsB;MAE7B,IAAI;EACF,MAAM,aAAa,cACjB,OAAO,eAAe,WAAW,aAAa,OAAO,KAAK,GAC5D;EACA,MAAM,EAAE,4BAA4B,WAClC,yBACF;EACA,MAAM,EAAE,oBAAoB,WAC1B,wCACF;EACA,OAAO,sBAAsB,CAC3B,IAAI,wBAAwB,EAC1B,UAAU,IAAI,gBAAgB;GAC5B,KAAK;GACL;EACF,CAAC,EACH,CAAC,CACH;CACF,QAAQ;EACN,MAAM,IAAI,MACR,gIAEF;CACF;CAIJ,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"honeycomb.cjs","names":[],"sources":["../src/honeycomb.ts"],"sourcesContent":["/**\n * Honeycomb preset for autotel\n *\n * Provides a simplified configuration helper for Honeycomb integration\n * with best practices built-in.\n *\n * @example Using Honeycomb with API key\n * ```typescript\n * import { init } from 'autotel';\n * import { createHoneycombConfig } from 'autotel-backends/honeycomb';\n *\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With custom dataset\n * ```typescript\n * import { init } from 'autotel';\n * import { createHoneycombConfig } from 'autotel-backends/honeycomb';\n *\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * dataset: 'production',\n * }));\n * ```\n */\n\nimport type { AutotelConfig } from 'autotel';\n\n/**\n * Configuration options for Honeycomb preset\n */\nexport interface HoneycombPresetConfig {\n /**\n * Honeycomb API key (required).\n *\n * Get your API key from:\n * https://ui.honeycomb.io/account\n *\n * For classic environments, use an environment-specific key.\n * For newer environments, use a team-level API key.\n */\n apiKey: string;\n\n /**\n * Service name (required).\n * Appears as service.name in Honeycomb traces and determines dataset routing.\n */\n service: string;\n\n /**\n * Dataset name (optional).\n * For classic Honeycomb accounts that use datasets.\n * Modern environments route based on service.name instead.\n *\n * @default service name\n */\n dataset?: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging', 'development').\n * Used for environment filtering in Honeycomb.\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.VERSION || auto-detected from package.json\n */\n version?: string;\n\n /**\n * Honeycomb API endpoint.\n * Use this to configure for different regions or on-premises installations.\n *\n * @default 'api.honeycomb.io:443'\n */\n endpoint?: string;\n\n /**\n * Sample rate for traces (1 = 100%, 10 = 10%, 100 = 1%).\n * Honeycomb's head-based sampling rate.\n *\n * Note: Autotel uses tail-based sampling by default.\n * This setting applies additional head-based sampling if specified.\n *\n * @default undefined (no head-based sampling, relies on tail sampling)\n */\n sampleRate?: number;\n}\n\n/**\n * Create an autotel configuration optimized for Honeycomb.\n *\n * This preset handles:\n * - gRPC protocol configuration (Honeycomb's preferred protocol)\n * - Proper endpoint and authentication headers\n * - Dataset routing (for classic accounts)\n * - Unified service tagging (service, env, version)\n *\n * Honeycomb uses gRPC by default for better performance and lower overhead.\n * This preset automatically configures the gRPC protocol.\n *\n * @param config - Honeycomb-specific configuration options\n * @returns AutotelConfig ready to pass to init()\n *\n * @example Simple configuration\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With custom dataset and environment\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * dataset: 'production',\n * environment: 'production',\n * version: '2.1.0',\n * }));\n * ```\n *\n * @example With sample rate\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * sampleRate: 10, // Sample 10% of traces (head-based sampling)\n * }));\n * ```\n */\nexport function createHoneycombConfig(\n config: HoneycombPresetConfig,\n): AutotelConfig {\n const {\n apiKey,\n service,\n dataset,\n environment,\n version,\n endpoint = 'api.honeycomb.io:443',\n sampleRate,\n } = config;\n\n // Validation: API key is required\n if (!apiKey) {\n throw new Error(\n 'Honeycomb API key is required. Get your API key from: https://ui.honeycomb.io/account',\n );\n }\n\n // Build headers\n const headers: Record<string, string> = {\n 'x-honeycomb-team': apiKey,\n };\n\n // Add dataset header if specified (for classic Honeycomb accounts)\n if (dataset) {\n headers['x-honeycomb-dataset'] = dataset;\n }\n\n // Add sample rate header if specified\n if (sampleRate !== undefined) {\n headers['x-honeycomb-samplerate'] = String(sampleRate);\n }\n\n return {\n service,\n environment,\n version,\n protocol: 'grpc', // Honeycomb uses gRPC for better performance\n endpoint,\n headers,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,SAAgB,sBACd,QACe;CACf,MAAM,EACJ,QACA,SACA,SACA,aACA,SACA,WAAW,wBACX,eACE;CAGJ,IAAI,CAAC,QACH,MAAM,IAAI,MACR,uFACF;CAIF,MAAM,UAAkC,EACtC,oBAAoB,OACtB;CAGA,IAAI,SACF,QAAQ,yBAAyB;CAInC,IAAI,eAAe,KAAA,GACjB,QAAQ,4BAA4B,OAAO,UAAU;CAGvD,OAAO;EACL;EACA;EACA;EACA,UAAU;EACV;EACA;CACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"honeycomb.d.cts","names":[],"sources":["../src/honeycomb.ts"],"mappings":";;;;;UAmCiB;;;;;;;;;;EAUf;;;;;EAMA;;;;;;;;EASA;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8Cc,sBACd,QAAQ,wBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"honeycomb.d.ts","names":[],"sources":["../src/honeycomb.ts"],"mappings":";;;;;UAmCiB;;;;;;;;;;EAUf;;;;;EAMA;;;;;;;;EASA;;;;;;;EAQA;;;;;;EAOA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8Cc,sBACd,QAAQ,wBACP"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"honeycomb.js","names":[],"sources":["../src/honeycomb.ts"],"sourcesContent":["/**\n * Honeycomb preset for autotel\n *\n * Provides a simplified configuration helper for Honeycomb integration\n * with best practices built-in.\n *\n * @example Using Honeycomb with API key\n * ```typescript\n * import { init } from 'autotel';\n * import { createHoneycombConfig } from 'autotel-backends/honeycomb';\n *\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With custom dataset\n * ```typescript\n * import { init } from 'autotel';\n * import { createHoneycombConfig } from 'autotel-backends/honeycomb';\n *\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * dataset: 'production',\n * }));\n * ```\n */\n\nimport type { AutotelConfig } from 'autotel';\n\n/**\n * Configuration options for Honeycomb preset\n */\nexport interface HoneycombPresetConfig {\n /**\n * Honeycomb API key (required).\n *\n * Get your API key from:\n * https://ui.honeycomb.io/account\n *\n * For classic environments, use an environment-specific key.\n * For newer environments, use a team-level API key.\n */\n apiKey: string;\n\n /**\n * Service name (required).\n * Appears as service.name in Honeycomb traces and determines dataset routing.\n */\n service: string;\n\n /**\n * Dataset name (optional).\n * For classic Honeycomb accounts that use datasets.\n * Modern environments route based on service.name instead.\n *\n * @default service name\n */\n dataset?: string;\n\n /**\n * Deployment environment (e.g., 'production', 'staging', 'development').\n * Used for environment filtering in Honeycomb.\n *\n * @default process.env.NODE_ENV || 'development'\n */\n environment?: string;\n\n /**\n * Service version for deployment tracking.\n *\n * @default process.env.VERSION || auto-detected from package.json\n */\n version?: string;\n\n /**\n * Honeycomb API endpoint.\n * Use this to configure for different regions or on-premises installations.\n *\n * @default 'api.honeycomb.io:443'\n */\n endpoint?: string;\n\n /**\n * Sample rate for traces (1 = 100%, 10 = 10%, 100 = 1%).\n * Honeycomb's head-based sampling rate.\n *\n * Note: Autotel uses tail-based sampling by default.\n * This setting applies additional head-based sampling if specified.\n *\n * @default undefined (no head-based sampling, relies on tail sampling)\n */\n sampleRate?: number;\n}\n\n/**\n * Create an autotel configuration optimized for Honeycomb.\n *\n * This preset handles:\n * - gRPC protocol configuration (Honeycomb's preferred protocol)\n * - Proper endpoint and authentication headers\n * - Dataset routing (for classic accounts)\n * - Unified service tagging (service, env, version)\n *\n * Honeycomb uses gRPC by default for better performance and lower overhead.\n * This preset automatically configures the gRPC protocol.\n *\n * @param config - Honeycomb-specific configuration options\n * @returns AutotelConfig ready to pass to init()\n *\n * @example Simple configuration\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * }));\n * ```\n *\n * @example With custom dataset and environment\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * dataset: 'production',\n * environment: 'production',\n * version: '2.1.0',\n * }));\n * ```\n *\n * @example With sample rate\n * ```typescript\n * init(createHoneycombConfig({\n * apiKey: process.env.HONEYCOMB_API_KEY!,\n * service: 'my-app',\n * sampleRate: 10, // Sample 10% of traces (head-based sampling)\n * }));\n * ```\n */\nexport function createHoneycombConfig(\n config: HoneycombPresetConfig,\n): AutotelConfig {\n const {\n apiKey,\n service,\n dataset,\n environment,\n version,\n endpoint = 'api.honeycomb.io:443',\n sampleRate,\n } = config;\n\n // Validation: API key is required\n if (!apiKey) {\n throw new Error(\n 'Honeycomb API key is required. Get your API key from: https://ui.honeycomb.io/account',\n );\n }\n\n // Build headers\n const headers: Record<string, string> = {\n 'x-honeycomb-team': apiKey,\n };\n\n // Add dataset header if specified (for classic Honeycomb accounts)\n if (dataset) {\n headers['x-honeycomb-dataset'] = dataset;\n }\n\n // Add sample rate header if specified\n if (sampleRate !== undefined) {\n headers['x-honeycomb-samplerate'] = String(sampleRate);\n }\n\n return {\n service,\n environment,\n version,\n protocol: 'grpc', // Honeycomb uses gRPC for better performance\n endpoint,\n headers,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,SAAgB,sBACd,QACe;CACf,MAAM,EACJ,QACA,SACA,SACA,aACA,SACA,WAAW,wBACX,eACE;CAGJ,IAAI,CAAC,QACH,MAAM,IAAI,MACR,uFACF;CAIF,MAAM,UAAkC,EACtC,oBAAoB,OACtB;CAGA,IAAI,SACF,QAAQ,yBAAyB;CAInC,IAAI,eAAe,KAAA,GACjB,QAAQ,4BAA4B,OAAO,UAAU;CAGvD,OAAO;EACL;EACA;EACA;EACA,UAAU;EACV;EACA;CACF;AACF"}