autotel-backends 2.12.40 → 2.12.41
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 +2 -2
- package/dist/datadog.cjs.map +1 -1
- package/dist/datadog.d.cts +0 -1
- package/dist/datadog.d.cts.map +1 -1
- package/dist/datadog.d.ts +0 -1
- package/dist/datadog.d.ts.map +1 -1
- package/dist/datadog.js +2 -2
- package/dist/datadog.js.map +1 -1
- package/dist/google-cloud.d.cts +0 -1
- package/dist/google-cloud.d.cts.map +1 -1
- package/dist/google-cloud.d.ts +0 -1
- package/dist/google-cloud.d.ts.map +1 -1
- package/dist/grafana.cjs +2 -2
- package/dist/grafana.cjs.map +1 -1
- package/dist/grafana.d.cts +0 -1
- package/dist/grafana.d.cts.map +1 -1
- package/dist/grafana.d.ts +0 -1
- package/dist/grafana.d.ts.map +1 -1
- package/dist/grafana.js +2 -2
- package/dist/grafana.js.map +1 -1
- package/dist/honeycomb.d.cts +0 -1
- package/dist/honeycomb.d.cts.map +1 -1
- package/dist/honeycomb.d.ts +0 -1
- package/dist/honeycomb.d.ts.map +1 -1
- package/package.json +11 -12
- package/skills/autotel-backends/SKILL.md +7 -7
package/dist/datadog.cjs
CHANGED
|
@@ -122,10 +122,10 @@ function createDatadogConfig(config) {
|
|
|
122
122
|
const pkgRequire = (0, node_module.createRequire)(typeof __filename === "string" ? __filename : require("url").pathToFileURL(__filename).href);
|
|
123
123
|
const { BatchLogRecordProcessor } = pkgRequire("@opentelemetry/sdk-logs");
|
|
124
124
|
const { OTLPLogExporter } = pkgRequire("@opentelemetry/exporter-logs-otlp-http");
|
|
125
|
-
cloudConfig.logRecordProcessors = [new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
125
|
+
cloudConfig.logRecordProcessors = [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter({
|
|
126
126
|
url: `${otlpEndpoint}/v1/logs`,
|
|
127
127
|
headers: { "dd-api-key": apiKey }
|
|
128
|
-
}))];
|
|
128
|
+
}) })];
|
|
129
129
|
} catch {
|
|
130
130
|
throw new Error("Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false.");
|
|
131
131
|
}
|
package/dist/datadog.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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,wBACF,IAAI,gBAAgB;IAClB,KAAK,GAAG,aAAa;IACrB,SAAS,EACP,cAAc,OAChB;GACF,CAAC,CACH,CACF;EACF,QAAQ;GACN,MAAM,IAAI,MACR,gIAEF;EACF;CAEJ;CAEA,OAAO;AACT"}
|
|
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"}
|
package/dist/datadog.d.cts
CHANGED
package/dist/datadog.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadog.d.cts","names":[],"sources":["../src/datadog.ts"],"mappings":"
|
|
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"}
|
package/dist/datadog.d.ts
CHANGED
package/dist/datadog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadog.d.ts","names":[],"sources":["../src/datadog.ts"],"mappings":"
|
|
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"}
|
package/dist/datadog.js
CHANGED
|
@@ -121,10 +121,10 @@ function createDatadogConfig(config) {
|
|
|
121
121
|
const pkgRequire = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
122
122
|
const { BatchLogRecordProcessor } = pkgRequire("@opentelemetry/sdk-logs");
|
|
123
123
|
const { OTLPLogExporter } = pkgRequire("@opentelemetry/exporter-logs-otlp-http");
|
|
124
|
-
cloudConfig.logRecordProcessors = [new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
124
|
+
cloudConfig.logRecordProcessors = [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter({
|
|
125
125
|
url: `${otlpEndpoint}/v1/logs`,
|
|
126
126
|
headers: { "dd-api-key": apiKey }
|
|
127
|
-
}))];
|
|
127
|
+
}) })];
|
|
128
128
|
} catch {
|
|
129
129
|
throw new Error("Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false.");
|
|
130
130
|
}
|
package/dist/datadog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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,wBACF,IAAI,gBAAgB;IAClB,KAAK,GAAG,aAAa;IACrB,SAAS,EACP,cAAc,OAChB;GACF,CAAC,CACH,CACF;EACF,QAAQ;GACN,MAAM,IAAI,MACR,gIAEF;EACF;CAEJ;CAEA,OAAO;AACT"}
|
|
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"}
|
package/dist/google-cloud.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud.d.cts","names":[],"sources":["../src/google-cloud.ts"],"mappings":"
|
|
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"}
|
package/dist/google-cloud.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud.d.ts","names":[],"sources":["../src/google-cloud.ts"],"mappings":"
|
|
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"}
|
package/dist/grafana.cjs
CHANGED
|
@@ -66,10 +66,10 @@ function createGrafanaConfig(config) {
|
|
|
66
66
|
const pkgRequire = (0, node_module.createRequire)(typeof __filename === "string" ? __filename : require("url").pathToFileURL(__filename).href);
|
|
67
67
|
const { BatchLogRecordProcessor } = pkgRequire("@opentelemetry/sdk-logs");
|
|
68
68
|
const { OTLPLogExporter } = pkgRequire("@opentelemetry/exporter-logs-otlp-http");
|
|
69
|
-
result.logRecordProcessors = [new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
69
|
+
result.logRecordProcessors = [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter({
|
|
70
70
|
url: logsUrl,
|
|
71
71
|
headers
|
|
72
|
-
}))];
|
|
72
|
+
}) })];
|
|
73
73
|
} catch {
|
|
74
74
|
throw new Error("Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false.");
|
|
75
75
|
}
|
package/dist/grafana.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 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,
|
|
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"}
|
package/dist/grafana.d.cts
CHANGED
package/dist/grafana.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grafana.d.cts","names":[],"sources":["../src/grafana.ts"],"mappings":"
|
|
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"}
|
package/dist/grafana.d.ts
CHANGED
package/dist/grafana.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grafana.d.ts","names":[],"sources":["../src/grafana.ts"],"mappings":"
|
|
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"}
|
package/dist/grafana.js
CHANGED
|
@@ -65,10 +65,10 @@ function createGrafanaConfig(config) {
|
|
|
65
65
|
const pkgRequire = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
|
|
66
66
|
const { BatchLogRecordProcessor } = pkgRequire("@opentelemetry/sdk-logs");
|
|
67
67
|
const { OTLPLogExporter } = pkgRequire("@opentelemetry/exporter-logs-otlp-http");
|
|
68
|
-
result.logRecordProcessors = [new BatchLogRecordProcessor(new OTLPLogExporter({
|
|
68
|
+
result.logRecordProcessors = [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter({
|
|
69
69
|
url: logsUrl,
|
|
70
70
|
headers
|
|
71
|
-
}))];
|
|
71
|
+
}) })];
|
|
72
72
|
} catch {
|
|
73
73
|
throw new Error("Log export requires @opentelemetry/sdk-logs and @opentelemetry/exporter-logs-otlp-http. Install them or set enableLogs: false.");
|
|
74
74
|
}
|
package/dist/grafana.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
package/dist/honeycomb.d.cts
CHANGED
package/dist/honeycomb.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeycomb.d.cts","names":[],"sources":["../src/honeycomb.ts"],"mappings":"
|
|
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"}
|
package/dist/honeycomb.d.ts
CHANGED
package/dist/honeycomb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honeycomb.d.ts","names":[],"sources":["../src/honeycomb.ts"],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autotel-backends",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.41",
|
|
4
4
|
"description": "Vendor backend configurations for Autotel (Honeycomb, Datadog, etc.)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"author": "Jag Reehal <jag@jagreehal.com> (https://jagreehal.com)",
|
|
57
57
|
"license": "Apache-2.0",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@opentelemetry/exporter-logs-otlp-http": ">=0.
|
|
60
|
-
"@opentelemetry/sdk-logs": ">=0.
|
|
61
|
-
"autotel": "
|
|
59
|
+
"@opentelemetry/exporter-logs-otlp-http": ">=0.220.0",
|
|
60
|
+
"@opentelemetry/sdk-logs": ">=0.220.0",
|
|
61
|
+
"autotel": "5.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@opentelemetry/exporter-metrics-otlp-http": ">=0.
|
|
65
|
-
"@opentelemetry/exporter-trace-otlp-http": ">=0.
|
|
66
|
-
"@opentelemetry/sdk-metrics": ">=2.
|
|
64
|
+
"@opentelemetry/exporter-metrics-otlp-http": ">=0.220.0",
|
|
65
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.220.0",
|
|
66
|
+
"@opentelemetry/sdk-metrics": ">=2.9.0",
|
|
67
67
|
"google-auth-library": ">=10.9.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@types/node": "^26.1.
|
|
85
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
86
|
-
"@typescript-eslint/parser": "^8.
|
|
84
|
+
"@types/node": "^26.1.1",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
86
|
+
"@typescript-eslint/parser": "^8.65.0",
|
|
87
87
|
"eslint-config-prettier": "^10.1.8",
|
|
88
88
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
89
|
-
"tsdown": "^0.22.
|
|
89
|
+
"tsdown": "^0.22.12",
|
|
90
90
|
"typescript": "^6.0.3",
|
|
91
91
|
"vitest": "^4.1.10"
|
|
92
92
|
},
|
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
"dev": "tsdown --watch",
|
|
106
106
|
"lint": "eslint src/**/*.ts",
|
|
107
107
|
"lint:fix": "eslint src/**/*.ts --fix",
|
|
108
|
-
"format": "prettier --write .",
|
|
109
108
|
"format:check": "prettier --check src/**/*.ts",
|
|
110
109
|
"type-check": "tsc --noEmit",
|
|
111
110
|
"test": "vitest run --config vitest.unit.config.ts",
|
|
@@ -106,7 +106,7 @@ When `enableLogs: true`, the preset auto-sets `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`
|
|
|
106
106
|
|
|
107
107
|
### Google Cloud
|
|
108
108
|
|
|
109
|
-
**Via OpenTelemetry Collector (recommended
|
|
109
|
+
**Via OpenTelemetry Collector (recommended, no auth in app):**
|
|
110
110
|
|
|
111
111
|
```typescript
|
|
112
112
|
import { init } from 'autotel';
|
|
@@ -184,7 +184,7 @@ Grafana preset also enables `metrics: true` by default. Logs go to `/v1/logs` on
|
|
|
184
184
|
|
|
185
185
|
## Common Mistakes
|
|
186
186
|
|
|
187
|
-
### HIGH
|
|
187
|
+
### HIGH: Passing apiKey to Datadog with useAgent: true
|
|
188
188
|
|
|
189
189
|
```typescript
|
|
190
190
|
// WRONG: apiKey is ignored and Agent mode doesn't use it
|
|
@@ -207,7 +207,7 @@ init(
|
|
|
207
207
|
);
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
### HIGH
|
|
210
|
+
### HIGH: Calling init() without apiKey in direct Datadog mode
|
|
211
211
|
|
|
212
212
|
`createDatadogConfig` throws at call-time if `!useAgent && !apiKey`. This is a startup crash, not a runtime one.
|
|
213
213
|
|
|
@@ -217,7 +217,7 @@ init(createDatadogConfig({ service: 'my-app' }));
|
|
|
217
217
|
// throws: "Datadog API key is required..."
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
### HIGH
|
|
220
|
+
### HIGH: Trying Google Cloud direct export without google-auth-library installed
|
|
221
221
|
|
|
222
222
|
```typescript
|
|
223
223
|
// WRONG: throws at runtime if package is absent
|
|
@@ -236,11 +236,11 @@ init(createGoogleCloudConfig({
|
|
|
236
236
|
}));
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
### MEDIUM
|
|
239
|
+
### MEDIUM: Using wrong Honeycomb API key type
|
|
240
240
|
|
|
241
241
|
Modern Honeycomb environments use a team-level API key. Classic environments use dataset-specific keys. If traces are missing, verify key type in Honeycomb's account settings. The `dataset` option is only needed for classic accounts.
|
|
242
242
|
|
|
243
|
-
### MEDIUM
|
|
243
|
+
### MEDIUM: Setting OTEL*EXPORTER_OTLP_LOGS*\* env vars before calling createDatadogConfig with enableLogs
|
|
244
244
|
|
|
245
245
|
The Datadog preset respects existing env vars and skips overwriting them. If you set `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` manually to the wrong value before calling the preset, the preset's correct value is silently skipped.
|
|
246
246
|
|
|
@@ -252,7 +252,7 @@ init(createDatadogConfig({ apiKey: key, service: 'app', enableLogs: true }));
|
|
|
252
252
|
|
|
253
253
|
Clear or unset conflicting env vars before calling the preset, or pass `logRecordProcessors` directly.
|
|
254
254
|
|
|
255
|
-
### MEDIUM
|
|
255
|
+
### MEDIUM: Stripping the /v1/traces suffix from Grafana endpoint
|
|
256
256
|
|
|
257
257
|
```typescript
|
|
258
258
|
// WRONG: Grafana gateway expects the full base URL; the SDK appends /v1/traces
|