autotel-backends 2.12.28 → 2.12.30
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.
- package/dist/datadog.cjs +134 -112
- package/dist/datadog.cjs.map +1 -1
- package/dist/datadog.d.cts +93 -121
- package/dist/datadog.d.cts.map +1 -0
- package/dist/datadog.d.ts +93 -121
- package/dist/datadog.d.ts.map +1 -0
- package/dist/datadog.js +133 -109
- package/dist/datadog.js.map +1 -1
- package/dist/google-cloud.cjs +114 -112
- package/dist/google-cloud.cjs.map +1 -1
- package/dist/google-cloud.d.cts +51 -77
- package/dist/google-cloud.d.cts.map +1 -0
- package/dist/google-cloud.d.ts +51 -77
- package/dist/google-cloud.d.ts.map +1 -0
- package/dist/google-cloud.js +113 -110
- package/dist/google-cloud.js.map +1 -1
- package/dist/grafana.cjs +75 -75
- package/dist/grafana.cjs.map +1 -1
- package/dist/grafana.d.cts +48 -69
- package/dist/grafana.d.cts.map +1 -0
- package/dist/grafana.d.ts +48 -69
- package/dist/grafana.d.ts.map +1 -0
- package/dist/grafana.js +74 -72
- package/dist/grafana.js.map +1 -1
- package/dist/honeycomb.cjs +60 -37
- package/dist/honeycomb.cjs.map +1 -1
- package/dist/honeycomb.d.cts +58 -86
- package/dist/honeycomb.d.cts.map +1 -0
- package/dist/honeycomb.d.ts +58 -86
- package/dist/honeycomb.d.ts.map +1 -0
- package/dist/honeycomb.js +59 -35
- package/dist/honeycomb.js.map +1 -1
- package/dist/index.cjs +9 -335
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +4 -328
- package/package.json +5 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/grafana.d.ts
CHANGED
|
@@ -1,75 +1,53 @@
|
|
|
1
|
-
import { AutotelConfig } from
|
|
2
|
-
import { LogRecordProcessor } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Grafana Cloud preset for autotel
|
|
6
|
-
*
|
|
7
|
-
* Provides a simplified configuration helper for sending traces, metrics,
|
|
8
|
-
* and logs to Grafana Cloud via the OTLP gateway.
|
|
9
|
-
*
|
|
10
|
-
* Get your endpoint and headers from:
|
|
11
|
-
* Grafana Cloud Portal → your stack → Connections → OpenTelemetry → Configure
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { init } from 'autotel';
|
|
16
|
-
* import { createGrafanaConfig } from 'autotel-backends/grafana';
|
|
17
|
-
*
|
|
18
|
-
* init(createGrafanaConfig({
|
|
19
|
-
* endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT!,
|
|
20
|
-
* headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,
|
|
21
|
-
* service: 'my-app',
|
|
22
|
-
* enableLogs: true,
|
|
23
|
-
* }));
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
1
|
+
import { AutotelConfig } from "autotel";
|
|
2
|
+
import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
|
|
26
3
|
|
|
4
|
+
//#region src/grafana.d.ts
|
|
27
5
|
/**
|
|
28
6
|
* Configuration options for Grafana Cloud preset
|
|
29
7
|
*/
|
|
30
8
|
interface GrafanaPresetConfig {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
9
|
+
/**
|
|
10
|
+
* OTLP gateway endpoint (required).
|
|
11
|
+
* From Grafana Cloud: Stack → Connections → OpenTelemetry → Configure.
|
|
12
|
+
* Example: https://otlp-gateway-prod-gb-south-1.grafana.net/otlp
|
|
13
|
+
*/
|
|
14
|
+
endpoint: string;
|
|
15
|
+
/**
|
|
16
|
+
* OTLP authentication headers.
|
|
17
|
+
* From the same Configure tile; usually Basic auth.
|
|
18
|
+
* Example: "Authorization=Basic%20BASE64_INSTANCE_ID_AND_TOKEN"
|
|
19
|
+
* or object: { Authorization: 'Basic ...' }
|
|
20
|
+
*/
|
|
21
|
+
headers?: string | Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Service name (required).
|
|
24
|
+
* Appears in Tempo, Mimir, and Loki as service_name.
|
|
25
|
+
*/
|
|
26
|
+
service: string;
|
|
27
|
+
/**
|
|
28
|
+
* Deployment environment (e.g. 'production', 'staging').
|
|
29
|
+
*
|
|
30
|
+
* @default process.env.NODE_ENV || 'development'
|
|
31
|
+
*/
|
|
32
|
+
environment?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Service version for deployment tracking.
|
|
35
|
+
*
|
|
36
|
+
* @default process.env.OTEL_SERVICE_VERSION
|
|
37
|
+
*/
|
|
38
|
+
version?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Enable log export to Grafana Cloud (Loki) via OTLP.
|
|
41
|
+
* When true, configures logRecordProcessors so OTel Logs API records are exported.
|
|
42
|
+
*
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
enableLogs?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Custom log record processors (advanced).
|
|
48
|
+
* Overrides the default OTLP log processor when enableLogs is true.
|
|
49
|
+
*/
|
|
50
|
+
logRecordProcessors?: LogRecordProcessor[];
|
|
73
51
|
}
|
|
74
52
|
/**
|
|
75
53
|
* Create an autotel configuration for Grafana Cloud OTLP.
|
|
@@ -82,5 +60,6 @@ interface GrafanaPresetConfig {
|
|
|
82
60
|
* @returns AutotelConfig ready to pass to init()
|
|
83
61
|
*/
|
|
84
62
|
declare function createGrafanaConfig(config: GrafanaPresetConfig): AutotelConfig;
|
|
85
|
-
|
|
86
|
-
export {
|
|
63
|
+
//#endregion
|
|
64
|
+
export { GrafanaPresetConfig, createGrafanaConfig };
|
|
65
|
+
//# sourceMappingURL=grafana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grafana.d.ts","names":[],"sources":["../src/grafana.ts"],"mappings":";;;;;;;UAkCiB,mBAAA;;;;;;EAMf,QAAA;;;;;;;EAQA,OAAA,YAAmB,MAAA;;;;;EAMnB,OAAA;;;;;;EAOA,WAAA;;;;;;EAOA,OAAA;;;;;;;EAQA,UAAA;;;;;EAMA,mBAAA,GAAsB,kBAAkB;AAAA;;;;;;;;;;;iBA8B1B,mBAAA,CACd,MAAA,EAAQ,mBAAA,GACP,aAAa"}
|
package/dist/grafana.js
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
import { createRequire } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region src/grafana.ts
|
|
3
|
+
/**
|
|
4
|
+
* Grafana Cloud preset for autotel
|
|
5
|
+
*
|
|
6
|
+
* Provides a simplified configuration helper for sending traces, metrics,
|
|
7
|
+
* and logs to Grafana Cloud via the OTLP gateway.
|
|
8
|
+
*
|
|
9
|
+
* Get your endpoint and headers from:
|
|
10
|
+
* Grafana Cloud Portal → your stack → Connections → OpenTelemetry → Configure
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { init } from 'autotel';
|
|
15
|
+
* import { createGrafanaConfig } from 'autotel-backends/grafana';
|
|
16
|
+
*
|
|
17
|
+
* init(createGrafanaConfig({
|
|
18
|
+
* endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT!,
|
|
19
|
+
* headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,
|
|
20
|
+
* service: 'my-app',
|
|
21
|
+
* enableLogs: true,
|
|
22
|
+
* }));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
function normalizeHeaders(headers) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
if (!headers) return void 0;
|
|
27
|
+
if (typeof headers === "object") return headers;
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const pair of headers.split(",")) {
|
|
30
|
+
const [key, ...valueParts] = pair.split("=");
|
|
31
|
+
if (key && valueParts.length > 0) {
|
|
32
|
+
let value = valueParts.join("=").trim();
|
|
33
|
+
value = value.replaceAll("%20", " ");
|
|
34
|
+
out[key.trim()] = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
17
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Create an autotel configuration for Grafana Cloud OTLP.
|
|
41
|
+
*
|
|
42
|
+
* Sends traces (Tempo), metrics (Mimir), and optionally logs (Loki) to the
|
|
43
|
+
* Grafana Cloud OTLP gateway. Endpoint and headers come from the stack's
|
|
44
|
+
* Connections → OpenTelemetry → Configure tile.
|
|
45
|
+
*
|
|
46
|
+
* @param config - Grafana Cloud configuration options
|
|
47
|
+
* @returns AutotelConfig ready to pass to init()
|
|
48
|
+
*/
|
|
18
49
|
function createGrafanaConfig(config) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (logRecordProcessors) {
|
|
46
|
-
result.logRecordProcessors = logRecordProcessors;
|
|
47
|
-
} else {
|
|
48
|
-
try {
|
|
49
|
-
const pkgRequire = createRequire(
|
|
50
|
-
typeof __filename === "string" ? __filename : import.meta.url
|
|
51
|
-
);
|
|
52
|
-
const { BatchLogRecordProcessor } = pkgRequire(
|
|
53
|
-
"@opentelemetry/sdk-logs"
|
|
54
|
-
);
|
|
55
|
-
const { OTLPLogExporter } = pkgRequire(
|
|
56
|
-
"@opentelemetry/exporter-logs-otlp-http"
|
|
57
|
-
);
|
|
58
|
-
result.logRecordProcessors = [
|
|
59
|
-
new BatchLogRecordProcessor(
|
|
60
|
-
new OTLPLogExporter({
|
|
61
|
-
url: logsUrl,
|
|
62
|
-
headers
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
];
|
|
66
|
-
} catch {
|
|
67
|
-
throw new Error(
|
|
68
|
-
"Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false."
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
50
|
+
const { endpoint, headers: headersInput, service, environment, version, enableLogs = true, logRecordProcessors } = config;
|
|
51
|
+
if (!endpoint) throw new Error("Grafana Cloud endpoint is required. Get it from: Grafana Cloud → your stack → Connections → OpenTelemetry → Configure");
|
|
52
|
+
const headers = normalizeHeaders(headersInput);
|
|
53
|
+
const base = endpoint.replace(/\/v1\/(traces|metrics|logs)$/, "");
|
|
54
|
+
const logsUrl = `${base}${base.endsWith("/") ? "" : "/"}v1/logs`;
|
|
55
|
+
const result = {
|
|
56
|
+
service,
|
|
57
|
+
environment,
|
|
58
|
+
version,
|
|
59
|
+
endpoint,
|
|
60
|
+
headers,
|
|
61
|
+
metrics: true
|
|
62
|
+
};
|
|
63
|
+
if (enableLogs) if (logRecordProcessors) result.logRecordProcessors = logRecordProcessors;
|
|
64
|
+
else try {
|
|
65
|
+
const pkgRequire = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
66
|
+
const { BatchLogRecordProcessor } = pkgRequire("@opentelemetry/sdk-logs");
|
|
67
|
+
const { OTLPLogExporter } = pkgRequire("@opentelemetry/exporter-logs-otlp-http");
|
|
68
|
+
result.logRecordProcessors = [new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
69
|
+
url: logsUrl,
|
|
70
|
+
headers
|
|
71
|
+
}))];
|
|
72
|
+
} catch {
|
|
73
|
+
throw new Error("Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false.");
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
//#endregion
|
|
76
78
|
export { createGrafanaConfig };
|
|
77
|
-
|
|
79
|
+
|
|
78
80
|
//# sourceMappingURL=grafana.js.map
|
package/dist/grafana.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 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,wBACF,IAAI,gBAAgB;GAClB,KAAK;GACL;EACF,CAAC,CACH,CACF;CACF,QAAQ;EACN,MAAM,IAAI,MACR,gIAEF;CACF;CAIJ,OAAO;AACT"}
|
package/dist/honeycomb.cjs
CHANGED
|
@@ -1,41 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/honeycomb.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create an autotel configuration optimized for Honeycomb.
|
|
5
|
+
*
|
|
6
|
+
* This preset handles:
|
|
7
|
+
* - gRPC protocol configuration (Honeycomb's preferred protocol)
|
|
8
|
+
* - Proper endpoint and authentication headers
|
|
9
|
+
* - Dataset routing (for classic accounts)
|
|
10
|
+
* - Unified service tagging (service, env, version)
|
|
11
|
+
*
|
|
12
|
+
* Honeycomb uses gRPC by default for better performance and lower overhead.
|
|
13
|
+
* This preset automatically configures the gRPC protocol.
|
|
14
|
+
*
|
|
15
|
+
* @param config - Honeycomb-specific configuration options
|
|
16
|
+
* @returns AutotelConfig ready to pass to init()
|
|
17
|
+
*
|
|
18
|
+
* @example Simple configuration
|
|
19
|
+
* ```typescript
|
|
20
|
+
* init(createHoneycombConfig({
|
|
21
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
22
|
+
* service: 'my-app',
|
|
23
|
+
* }));
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With custom dataset and environment
|
|
27
|
+
* ```typescript
|
|
28
|
+
* init(createHoneycombConfig({
|
|
29
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
30
|
+
* service: 'my-app',
|
|
31
|
+
* dataset: 'production',
|
|
32
|
+
* environment: 'production',
|
|
33
|
+
* version: '2.1.0',
|
|
34
|
+
* }));
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example With sample rate
|
|
38
|
+
* ```typescript
|
|
39
|
+
* init(createHoneycombConfig({
|
|
40
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
41
|
+
* service: 'my-app',
|
|
42
|
+
* sampleRate: 10, // Sample 10% of traces (head-based sampling)
|
|
43
|
+
* }));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
4
46
|
function createHoneycombConfig(config) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
const headers = {
|
|
20
|
-
"x-honeycomb-team": apiKey
|
|
21
|
-
};
|
|
22
|
-
if (dataset) {
|
|
23
|
-
headers["x-honeycomb-dataset"] = dataset;
|
|
24
|
-
}
|
|
25
|
-
if (sampleRate !== void 0) {
|
|
26
|
-
headers["x-honeycomb-samplerate"] = String(sampleRate);
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
service,
|
|
30
|
-
environment,
|
|
31
|
-
version,
|
|
32
|
-
protocol: "grpc",
|
|
33
|
-
// Honeycomb uses gRPC for better performance
|
|
34
|
-
endpoint,
|
|
35
|
-
headers
|
|
36
|
-
};
|
|
47
|
+
const { apiKey, service, dataset, environment, version, endpoint = "api.honeycomb.io:443", sampleRate } = config;
|
|
48
|
+
if (!apiKey) throw new Error("Honeycomb API key is required. Get your API key from: https://ui.honeycomb.io/account");
|
|
49
|
+
const headers = { "x-honeycomb-team": apiKey };
|
|
50
|
+
if (dataset) headers["x-honeycomb-dataset"] = dataset;
|
|
51
|
+
if (sampleRate !== void 0) headers["x-honeycomb-samplerate"] = String(sampleRate);
|
|
52
|
+
return {
|
|
53
|
+
service,
|
|
54
|
+
environment,
|
|
55
|
+
version,
|
|
56
|
+
protocol: "grpc",
|
|
57
|
+
endpoint,
|
|
58
|
+
headers
|
|
59
|
+
};
|
|
37
60
|
}
|
|
38
|
-
|
|
61
|
+
//#endregion
|
|
39
62
|
exports.createHoneycombConfig = createHoneycombConfig;
|
|
40
|
-
|
|
63
|
+
|
|
41
64
|
//# sourceMappingURL=honeycomb.cjs.map
|
package/dist/honeycomb.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/dist/honeycomb.d.cts
CHANGED
|
@@ -1,92 +1,63 @@
|
|
|
1
|
-
import { AutotelConfig } from
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Honeycomb preset for autotel
|
|
5
|
-
*
|
|
6
|
-
* Provides a simplified configuration helper for Honeycomb integration
|
|
7
|
-
* with best practices built-in.
|
|
8
|
-
*
|
|
9
|
-
* @example Using Honeycomb with API key
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import { init } from 'autotel';
|
|
12
|
-
* import { createHoneycombConfig } from 'autotel-backends/honeycomb';
|
|
13
|
-
*
|
|
14
|
-
* init(createHoneycombConfig({
|
|
15
|
-
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
16
|
-
* service: 'my-app',
|
|
17
|
-
* }));
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example With custom dataset
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { init } from 'autotel';
|
|
23
|
-
* import { createHoneycombConfig } from 'autotel-backends/honeycomb';
|
|
24
|
-
*
|
|
25
|
-
* init(createHoneycombConfig({
|
|
26
|
-
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
27
|
-
* service: 'my-app',
|
|
28
|
-
* dataset: 'production',
|
|
29
|
-
* }));
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
1
|
+
import { AutotelConfig } from "autotel";
|
|
32
2
|
|
|
3
|
+
//#region src/honeycomb.d.ts
|
|
33
4
|
/**
|
|
34
5
|
* Configuration options for Honeycomb preset
|
|
35
6
|
*/
|
|
36
7
|
interface HoneycombPresetConfig {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Honeycomb API key (required).
|
|
10
|
+
*
|
|
11
|
+
* Get your API key from:
|
|
12
|
+
* https://ui.honeycomb.io/account
|
|
13
|
+
*
|
|
14
|
+
* For classic environments, use an environment-specific key.
|
|
15
|
+
* For newer environments, use a team-level API key.
|
|
16
|
+
*/
|
|
17
|
+
apiKey: string;
|
|
18
|
+
/**
|
|
19
|
+
* Service name (required).
|
|
20
|
+
* Appears as service.name in Honeycomb traces and determines dataset routing.
|
|
21
|
+
*/
|
|
22
|
+
service: string;
|
|
23
|
+
/**
|
|
24
|
+
* Dataset name (optional).
|
|
25
|
+
* For classic Honeycomb accounts that use datasets.
|
|
26
|
+
* Modern environments route based on service.name instead.
|
|
27
|
+
*
|
|
28
|
+
* @default service name
|
|
29
|
+
*/
|
|
30
|
+
dataset?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Deployment environment (e.g., 'production', 'staging', 'development').
|
|
33
|
+
* Used for environment filtering in Honeycomb.
|
|
34
|
+
*
|
|
35
|
+
* @default process.env.NODE_ENV || 'development'
|
|
36
|
+
*/
|
|
37
|
+
environment?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Service version for deployment tracking.
|
|
40
|
+
*
|
|
41
|
+
* @default process.env.VERSION || auto-detected from package.json
|
|
42
|
+
*/
|
|
43
|
+
version?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Honeycomb API endpoint.
|
|
46
|
+
* Use this to configure for different regions or on-premises installations.
|
|
47
|
+
*
|
|
48
|
+
* @default 'api.honeycomb.io:443'
|
|
49
|
+
*/
|
|
50
|
+
endpoint?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Sample rate for traces (1 = 100%, 10 = 10%, 100 = 1%).
|
|
53
|
+
* Honeycomb's head-based sampling rate.
|
|
54
|
+
*
|
|
55
|
+
* Note: Autotel uses tail-based sampling by default.
|
|
56
|
+
* This setting applies additional head-based sampling if specified.
|
|
57
|
+
*
|
|
58
|
+
* @default undefined (no head-based sampling, relies on tail sampling)
|
|
59
|
+
*/
|
|
60
|
+
sampleRate?: number;
|
|
90
61
|
}
|
|
91
62
|
/**
|
|
92
63
|
* Create an autotel configuration optimized for Honeycomb.
|
|
@@ -132,5 +103,6 @@ interface HoneycombPresetConfig {
|
|
|
132
103
|
* ```
|
|
133
104
|
*/
|
|
134
105
|
declare function createHoneycombConfig(config: HoneycombPresetConfig): AutotelConfig;
|
|
135
|
-
|
|
136
|
-
export {
|
|
106
|
+
//#endregion
|
|
107
|
+
export { HoneycombPresetConfig, createHoneycombConfig };
|
|
108
|
+
//# sourceMappingURL=honeycomb.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honeycomb.d.cts","names":[],"sources":["../src/honeycomb.ts"],"mappings":";;;;;;UAmCiB,qBAAA;;;;;;;;;;EAUf,MAAA;;;;;EAMA,OAAA;;;;;;;;EASA,OAAA;;;;;;;EAQA,WAAA;;;;;;EAOA,OAAA;;;;;;;EAQA,QAAA;;;;;;;;;;EAWA,UAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8Cc,qBAAA,CACd,MAAA,EAAQ,qBAAA,GACP,aAAa"}
|