autotel-backends 2.12.29 → 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/honeycomb.d.ts
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.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honeycomb.d.ts","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"}
|
package/dist/honeycomb.js
CHANGED
|
@@ -1,39 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/honeycomb.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create an autotel configuration optimized for Honeycomb.
|
|
4
|
+
*
|
|
5
|
+
* This preset handles:
|
|
6
|
+
* - gRPC protocol configuration (Honeycomb's preferred protocol)
|
|
7
|
+
* - Proper endpoint and authentication headers
|
|
8
|
+
* - Dataset routing (for classic accounts)
|
|
9
|
+
* - Unified service tagging (service, env, version)
|
|
10
|
+
*
|
|
11
|
+
* Honeycomb uses gRPC by default for better performance and lower overhead.
|
|
12
|
+
* This preset automatically configures the gRPC protocol.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Honeycomb-specific configuration options
|
|
15
|
+
* @returns AutotelConfig ready to pass to init()
|
|
16
|
+
*
|
|
17
|
+
* @example Simple configuration
|
|
18
|
+
* ```typescript
|
|
19
|
+
* init(createHoneycombConfig({
|
|
20
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
21
|
+
* service: 'my-app',
|
|
22
|
+
* }));
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example With custom dataset and environment
|
|
26
|
+
* ```typescript
|
|
27
|
+
* init(createHoneycombConfig({
|
|
28
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
29
|
+
* service: 'my-app',
|
|
30
|
+
* dataset: 'production',
|
|
31
|
+
* environment: 'production',
|
|
32
|
+
* version: '2.1.0',
|
|
33
|
+
* }));
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example With sample rate
|
|
37
|
+
* ```typescript
|
|
38
|
+
* init(createHoneycombConfig({
|
|
39
|
+
* apiKey: process.env.HONEYCOMB_API_KEY!,
|
|
40
|
+
* service: 'my-app',
|
|
41
|
+
* sampleRate: 10, // Sample 10% of traces (head-based sampling)
|
|
42
|
+
* }));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
2
45
|
function createHoneycombConfig(config) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
const headers = {
|
|
18
|
-
"x-honeycomb-team": apiKey
|
|
19
|
-
};
|
|
20
|
-
if (dataset) {
|
|
21
|
-
headers["x-honeycomb-dataset"] = dataset;
|
|
22
|
-
}
|
|
23
|
-
if (sampleRate !== void 0) {
|
|
24
|
-
headers["x-honeycomb-samplerate"] = String(sampleRate);
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
service,
|
|
28
|
-
environment,
|
|
29
|
-
version,
|
|
30
|
-
protocol: "grpc",
|
|
31
|
-
// Honeycomb uses gRPC for better performance
|
|
32
|
-
endpoint,
|
|
33
|
-
headers
|
|
34
|
-
};
|
|
46
|
+
const { apiKey, service, dataset, environment, version, endpoint = "api.honeycomb.io:443", sampleRate } = config;
|
|
47
|
+
if (!apiKey) throw new Error("Honeycomb API key is required. Get your API key from: https://ui.honeycomb.io/account");
|
|
48
|
+
const headers = { "x-honeycomb-team": apiKey };
|
|
49
|
+
if (dataset) headers["x-honeycomb-dataset"] = dataset;
|
|
50
|
+
if (sampleRate !== void 0) headers["x-honeycomb-samplerate"] = String(sampleRate);
|
|
51
|
+
return {
|
|
52
|
+
service,
|
|
53
|
+
environment,
|
|
54
|
+
version,
|
|
55
|
+
protocol: "grpc",
|
|
56
|
+
endpoint,
|
|
57
|
+
headers
|
|
58
|
+
};
|
|
35
59
|
}
|
|
36
|
-
|
|
60
|
+
//#endregion
|
|
37
61
|
export { createHoneycombConfig };
|
|
38
|
-
|
|
62
|
+
|
|
39
63
|
//# sourceMappingURL=honeycomb.js.map
|
package/dist/honeycomb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,335 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
service,
|
|
11
|
-
dataset,
|
|
12
|
-
environment,
|
|
13
|
-
version,
|
|
14
|
-
endpoint = "api.honeycomb.io:443",
|
|
15
|
-
sampleRate
|
|
16
|
-
} = config;
|
|
17
|
-
if (!apiKey) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
"Honeycomb API key is required. Get your API key from: https://ui.honeycomb.io/account"
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
const headers = {
|
|
23
|
-
"x-honeycomb-team": apiKey
|
|
24
|
-
};
|
|
25
|
-
if (dataset) {
|
|
26
|
-
headers["x-honeycomb-dataset"] = dataset;
|
|
27
|
-
}
|
|
28
|
-
if (sampleRate !== void 0) {
|
|
29
|
-
headers["x-honeycomb-samplerate"] = String(sampleRate);
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
service,
|
|
33
|
-
environment,
|
|
34
|
-
version,
|
|
35
|
-
protocol: "grpc",
|
|
36
|
-
// Honeycomb uses gRPC for better performance
|
|
37
|
-
endpoint,
|
|
38
|
-
headers
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createDatadogConfig(config) {
|
|
42
|
-
const {
|
|
43
|
-
apiKey,
|
|
44
|
-
site = "datadoghq.com",
|
|
45
|
-
service,
|
|
46
|
-
environment,
|
|
47
|
-
version,
|
|
48
|
-
enableLogs = false,
|
|
49
|
-
useAgent = false,
|
|
50
|
-
agentHost = "localhost",
|
|
51
|
-
agentPort = 4318,
|
|
52
|
-
logRecordProcessors
|
|
53
|
-
} = config;
|
|
54
|
-
if (!useAgent && !apiKey) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
"Datadog API key is required for direct cloud ingestion. Either provide apiKey or set useAgent: true to use local Datadog Agent."
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
const baseConfig = {
|
|
60
|
-
service,
|
|
61
|
-
environment,
|
|
62
|
-
version
|
|
63
|
-
};
|
|
64
|
-
if (useAgent) {
|
|
65
|
-
const agentEndpoint = `http://${agentHost}:${agentPort}`;
|
|
66
|
-
if (enableLogs) {
|
|
67
|
-
const logsEndpoint = `http://${agentHost}:${agentPort}/v1/logs`;
|
|
68
|
-
if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {
|
|
69
|
-
process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;
|
|
70
|
-
}
|
|
71
|
-
if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {
|
|
72
|
-
process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = "http/protobuf";
|
|
73
|
-
}
|
|
74
|
-
const resourceAttrs = [
|
|
75
|
-
`service.name=${service}`,
|
|
76
|
-
environment ? `deployment.environment=${environment}` : null,
|
|
77
|
-
version ? `service.version=${version}` : null
|
|
78
|
-
].filter(Boolean).join(",");
|
|
79
|
-
if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {
|
|
80
|
-
process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
...baseConfig,
|
|
85
|
-
endpoint: agentEndpoint
|
|
86
|
-
// No API key or headers needed - Agent handles authentication
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const otlpEndpoint = `https://otlp.${site}`;
|
|
90
|
-
const authHeaders = `dd-api-key=${apiKey}`;
|
|
91
|
-
const cloudConfig = {
|
|
92
|
-
...baseConfig,
|
|
93
|
-
endpoint: otlpEndpoint,
|
|
94
|
-
headers: authHeaders
|
|
95
|
-
};
|
|
96
|
-
if (enableLogs) {
|
|
97
|
-
const logsEndpoint = useAgent ? `http://${agentHost}:${agentPort}/v1/logs` : `https://otlp.${site}/v1/logs`;
|
|
98
|
-
if (!process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT) {
|
|
99
|
-
process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = logsEndpoint;
|
|
100
|
-
}
|
|
101
|
-
if (!process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) {
|
|
102
|
-
process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = "http/protobuf";
|
|
103
|
-
}
|
|
104
|
-
if (!useAgent && apiKey && !process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS) {
|
|
105
|
-
process.env.OTEL_EXPORTER_OTLP_LOGS_HEADERS = `dd-api-key=${apiKey}`;
|
|
106
|
-
}
|
|
107
|
-
const resourceAttrs = [
|
|
108
|
-
`service.name=${service}`,
|
|
109
|
-
environment ? `deployment.environment=${environment}` : null,
|
|
110
|
-
version ? `service.version=${version}` : null
|
|
111
|
-
].filter(Boolean).join(",");
|
|
112
|
-
if (!process.env.OTEL_RESOURCE_ATTRIBUTES) {
|
|
113
|
-
process.env.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs;
|
|
114
|
-
}
|
|
115
|
-
if (logRecordProcessors) {
|
|
116
|
-
cloudConfig.logRecordProcessors = logRecordProcessors;
|
|
117
|
-
} else {
|
|
118
|
-
try {
|
|
119
|
-
const pkgRequire = module$1.createRequire(
|
|
120
|
-
typeof __filename === "string" ? __filename : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))
|
|
121
|
-
);
|
|
122
|
-
const { BatchLogRecordProcessor } = pkgRequire(
|
|
123
|
-
"@opentelemetry/sdk-logs"
|
|
124
|
-
);
|
|
125
|
-
const { OTLPLogExporter } = pkgRequire(
|
|
126
|
-
"@opentelemetry/exporter-logs-otlp-http"
|
|
127
|
-
);
|
|
128
|
-
cloudConfig.logRecordProcessors = [
|
|
129
|
-
new BatchLogRecordProcessor(
|
|
130
|
-
new OTLPLogExporter({
|
|
131
|
-
url: `${otlpEndpoint}/v1/logs`,
|
|
132
|
-
headers: {
|
|
133
|
-
"dd-api-key": apiKey
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
)
|
|
137
|
-
];
|
|
138
|
-
} catch {
|
|
139
|
-
throw new Error(
|
|
140
|
-
"Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false."
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return cloudConfig;
|
|
146
|
-
}
|
|
147
|
-
var DEFAULT_ENDPOINT = "https://telemetry.googleapis.com";
|
|
148
|
-
function createGoogleCloudConfig(config) {
|
|
149
|
-
const {
|
|
150
|
-
projectId,
|
|
151
|
-
service,
|
|
152
|
-
environment,
|
|
153
|
-
version,
|
|
154
|
-
useCollector = false,
|
|
155
|
-
collectorEndpoint = "http://localhost:4318",
|
|
156
|
-
endpoint = DEFAULT_ENDPOINT
|
|
157
|
-
} = config;
|
|
158
|
-
if (!projectId) {
|
|
159
|
-
throw new Error(
|
|
160
|
-
"Google Cloud projectId is required. Set it or use process.env.GOOGLE_CLOUD_PROJECT."
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
const baseConfig = {
|
|
164
|
-
service,
|
|
165
|
-
environment,
|
|
166
|
-
version
|
|
167
|
-
};
|
|
168
|
-
if (useCollector) {
|
|
169
|
-
return {
|
|
170
|
-
...baseConfig,
|
|
171
|
-
endpoint: collectorEndpoint,
|
|
172
|
-
// x-goog-user-project for quota when Collector forwards to GCP
|
|
173
|
-
headers: { "x-goog-user-project": projectId }
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
const userRequire = module$1.createRequire(process.cwd() + "/package.json");
|
|
178
|
-
const { GoogleAuth } = userRequire("google-auth-library");
|
|
179
|
-
const { OTLPTraceExporter } = userRequire(
|
|
180
|
-
"@opentelemetry/exporter-trace-otlp-http"
|
|
181
|
-
);
|
|
182
|
-
const tracesUrl = `${endpoint}/v1/traces`;
|
|
183
|
-
const auth = new GoogleAuth({
|
|
184
|
-
scopes: ["https://www.googleapis.com/auth/cloud-platform"]
|
|
185
|
-
});
|
|
186
|
-
const gcpTraceExporter = createGcpAuthTraceExporter(
|
|
187
|
-
tracesUrl,
|
|
188
|
-
projectId,
|
|
189
|
-
auth,
|
|
190
|
-
OTLPTraceExporter
|
|
191
|
-
);
|
|
192
|
-
return {
|
|
193
|
-
...baseConfig,
|
|
194
|
-
// Structurally compatible with SpanExporter from @opentelemetry/sdk-trace-base
|
|
195
|
-
spanExporters: [
|
|
196
|
-
gcpTraceExporter
|
|
197
|
-
]
|
|
198
|
-
};
|
|
199
|
-
} catch (error) {
|
|
200
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
201
|
-
if (message.includes("google-auth-library") || message.includes("Cannot find module")) {
|
|
202
|
-
throw new Error(
|
|
203
|
-
"Direct export to Google Cloud requires google-auth-library. Install it: pnpm add google-auth-library. Or use useCollector: true and run an OpenTelemetry Collector with GCP auth.",
|
|
204
|
-
{ cause: error }
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function createGcpAuthTraceExporter(url, projectId, auth, OTLPTraceExporterCtor) {
|
|
211
|
-
return new GcpAuthSpanExporter(url, projectId, auth, OTLPTraceExporterCtor);
|
|
212
|
-
}
|
|
213
|
-
var GcpAuthSpanExporter = class {
|
|
214
|
-
constructor(url, projectId, auth, OTLPTraceExporterCtor) {
|
|
215
|
-
this.url = url;
|
|
216
|
-
this.projectId = projectId;
|
|
217
|
-
this.auth = auth;
|
|
218
|
-
this.OTLPTraceExporterCtor = OTLPTraceExporterCtor;
|
|
219
|
-
}
|
|
220
|
-
url;
|
|
221
|
-
projectId;
|
|
222
|
-
auth;
|
|
223
|
-
OTLPTraceExporterCtor;
|
|
224
|
-
async export(spans, resultCallback) {
|
|
225
|
-
try {
|
|
226
|
-
const client = await this.auth.getClient();
|
|
227
|
-
const tokenResponse = await client.getAccessToken();
|
|
228
|
-
const token = tokenResponse.token;
|
|
229
|
-
if (!token) {
|
|
230
|
-
resultCallback({
|
|
231
|
-
code: 1,
|
|
232
|
-
error: new Error("No access token from ADC")
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
const exporter = new this.OTLPTraceExporterCtor({
|
|
237
|
-
url: this.url,
|
|
238
|
-
headers: {
|
|
239
|
-
Authorization: `Bearer ${token}`,
|
|
240
|
-
"x-goog-user-project": this.projectId
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
exporter.export(spans, resultCallback);
|
|
244
|
-
} catch (error) {
|
|
245
|
-
resultCallback({
|
|
246
|
-
code: 1,
|
|
247
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
forceFlush() {
|
|
252
|
-
return Promise.resolve();
|
|
253
|
-
}
|
|
254
|
-
shutdown() {
|
|
255
|
-
return Promise.resolve();
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
function normalizeHeaders(headers) {
|
|
259
|
-
if (!headers) return void 0;
|
|
260
|
-
if (typeof headers === "object") return headers;
|
|
261
|
-
const out = {};
|
|
262
|
-
for (const pair of headers.split(",")) {
|
|
263
|
-
const [key, ...valueParts] = pair.split("=");
|
|
264
|
-
if (key && valueParts.length > 0) {
|
|
265
|
-
let value = valueParts.join("=").trim();
|
|
266
|
-
value = value.replaceAll("%20", " ");
|
|
267
|
-
out[key.trim()] = value;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return Object.keys(out).length > 0 ? out : void 0;
|
|
271
|
-
}
|
|
272
|
-
function createGrafanaConfig(config) {
|
|
273
|
-
const {
|
|
274
|
-
endpoint,
|
|
275
|
-
headers: headersInput,
|
|
276
|
-
service,
|
|
277
|
-
environment,
|
|
278
|
-
version,
|
|
279
|
-
enableLogs = true,
|
|
280
|
-
logRecordProcessors
|
|
281
|
-
} = config;
|
|
282
|
-
if (!endpoint) {
|
|
283
|
-
throw new Error(
|
|
284
|
-
"Grafana Cloud endpoint is required. Get it from: Grafana Cloud \u2192 your stack \u2192 Connections \u2192 OpenTelemetry \u2192 Configure"
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
const headers = normalizeHeaders(headersInput);
|
|
288
|
-
const base = endpoint.replace(/\/v1\/(traces|metrics|logs)$/, "");
|
|
289
|
-
const logsUrl = `${base}${base.endsWith("/") ? "" : "/"}v1/logs`;
|
|
290
|
-
const result = {
|
|
291
|
-
service,
|
|
292
|
-
environment,
|
|
293
|
-
version,
|
|
294
|
-
endpoint,
|
|
295
|
-
headers,
|
|
296
|
-
metrics: true
|
|
297
|
-
};
|
|
298
|
-
if (enableLogs) {
|
|
299
|
-
if (logRecordProcessors) {
|
|
300
|
-
result.logRecordProcessors = logRecordProcessors;
|
|
301
|
-
} else {
|
|
302
|
-
try {
|
|
303
|
-
const pkgRequire = module$1.createRequire(
|
|
304
|
-
typeof __filename === "string" ? __filename : (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))
|
|
305
|
-
);
|
|
306
|
-
const { BatchLogRecordProcessor } = pkgRequire(
|
|
307
|
-
"@opentelemetry/sdk-logs"
|
|
308
|
-
);
|
|
309
|
-
const { OTLPLogExporter } = pkgRequire(
|
|
310
|
-
"@opentelemetry/exporter-logs-otlp-http"
|
|
311
|
-
);
|
|
312
|
-
result.logRecordProcessors = [
|
|
313
|
-
new BatchLogRecordProcessor(
|
|
314
|
-
new OTLPLogExporter({
|
|
315
|
-
url: logsUrl,
|
|
316
|
-
headers
|
|
317
|
-
})
|
|
318
|
-
)
|
|
319
|
-
];
|
|
320
|
-
} catch {
|
|
321
|
-
throw new Error(
|
|
322
|
-
"Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false."
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return result;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
exports.createDatadogConfig = createDatadogConfig;
|
|
331
|
-
exports.createGoogleCloudConfig = createGoogleCloudConfig;
|
|
332
|
-
exports.createGrafanaConfig = createGrafanaConfig;
|
|
333
|
-
exports.createHoneycombConfig = createHoneycombConfig;
|
|
334
|
-
//# sourceMappingURL=index.cjs.map
|
|
335
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_honeycomb = require("./honeycomb.cjs");
|
|
3
|
+
const require_datadog = require("./datadog.cjs");
|
|
4
|
+
const require_google_cloud = require("./google-cloud.cjs");
|
|
5
|
+
const require_grafana = require("./grafana.cjs");
|
|
6
|
+
exports.createDatadogConfig = require_datadog.createDatadogConfig;
|
|
7
|
+
exports.createGoogleCloudConfig = require_google_cloud.createGoogleCloudConfig;
|
|
8
|
+
exports.createGrafanaConfig = require_grafana.createGrafanaConfig;
|
|
9
|
+
exports.createHoneycombConfig = require_honeycomb.createHoneycombConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import '@opentelemetry/sdk-logs';
|
|
1
|
+
import { DatadogPresetConfig, DatadogSite, createDatadogConfig } from "./datadog.cjs";
|
|
2
|
+
import { GoogleCloudPresetConfig, createGoogleCloudConfig } from "./google-cloud.cjs";
|
|
3
|
+
import { GrafanaPresetConfig, createGrafanaConfig } from "./grafana.cjs";
|
|
4
|
+
import { HoneycombPresetConfig, createHoneycombConfig } from "./honeycomb.cjs";
|
|
5
|
+
export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import '@opentelemetry/sdk-logs';
|
|
1
|
+
import { DatadogPresetConfig, DatadogSite, createDatadogConfig } from "./datadog.js";
|
|
2
|
+
import { GoogleCloudPresetConfig, createGoogleCloudConfig } from "./google-cloud.js";
|
|
3
|
+
import { GrafanaPresetConfig, createGrafanaConfig } from "./grafana.js";
|
|
4
|
+
import { HoneycombPresetConfig, createHoneycombConfig } from "./honeycomb.js";
|
|
5
|
+
export { type DatadogPresetConfig, type DatadogSite, type GoogleCloudPresetConfig, type GrafanaPresetConfig, type HoneycombPresetConfig, createDatadogConfig, createGoogleCloudConfig, createGrafanaConfig, createHoneycombConfig };
|