@geekmidas/telescope 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/{hono-Bw-ey6CT.mjs → hono-Bz9PQQzj.mjs} +2 -2
  3. package/dist/{hono-Bw-ey6CT.mjs.map → hono-Bz9PQQzj.mjs.map} +1 -1
  4. package/dist/{hono-CPHX7FAm.cjs → hono-Z_JIICmt.cjs} +2 -2
  5. package/dist/{hono-CPHX7FAm.cjs.map → hono-Z_JIICmt.cjs.map} +1 -1
  6. package/dist/{http-BIvr0YdI.mjs → http-Crsriv32.mjs} +1 -1
  7. package/dist/{http-BIvr0YdI.mjs.map → http-Crsriv32.mjs.map} +1 -1
  8. package/dist/{http-BiNtg85L.d.mts → http-D5kn3_Mt.d.mts} +3 -3
  9. package/dist/{http-BiNtg85L.d.mts.map → http-D5kn3_Mt.d.mts.map} +1 -1
  10. package/dist/{http-BsqmhurZ.cjs → http-JycFRfSe.cjs} +1 -1
  11. package/dist/{http-BsqmhurZ.cjs.map → http-JycFRfSe.cjs.map} +1 -1
  12. package/dist/instrumentation/hono.cjs +2 -2
  13. package/dist/instrumentation/hono.mjs +2 -2
  14. package/dist/instrumentation/http.cjs +1 -1
  15. package/dist/instrumentation/http.d.mts +1 -1
  16. package/dist/instrumentation/http.mjs +1 -1
  17. package/dist/instrumentation/index.cjs +5 -5
  18. package/dist/instrumentation/index.d.mts +1 -1
  19. package/dist/instrumentation/index.mjs +5 -5
  20. package/dist/instrumentation/middleware.cjs +2 -2
  21. package/dist/instrumentation/middleware.mjs +2 -2
  22. package/dist/instrumentation/otel.cjs +2 -2
  23. package/dist/instrumentation/otel.mjs +2 -2
  24. package/dist/instrumentation/setup.cjs +1 -1
  25. package/dist/instrumentation/setup.mjs +1 -1
  26. package/dist/logger/console.d.mts.map +1 -1
  27. package/dist/logger/pino.d.mts +2 -2
  28. package/dist/{middleware-DqPQpcup.cjs → middleware-D3v5SnSs.cjs} +2 -2
  29. package/dist/{middleware-DqPQpcup.cjs.map → middleware-D3v5SnSs.cjs.map} +1 -1
  30. package/dist/{middleware-4-GrQlOT.mjs → middleware-Dy1ctr2N.mjs} +2 -2
  31. package/dist/{middleware-4-GrQlOT.mjs.map → middleware-Dy1ctr2N.mjs.map} +1 -1
  32. package/dist/{otel-40udNP5g.mjs → otel-DPKNyJ0t.mjs} +2 -2
  33. package/dist/{otel-40udNP5g.mjs.map → otel-DPKNyJ0t.mjs.map} +1 -1
  34. package/dist/{otel-COrpz_GZ.cjs → otel-DuiBeBPU.cjs} +2 -2
  35. package/dist/{otel-COrpz_GZ.cjs.map → otel-DuiBeBPU.cjs.map} +1 -1
  36. package/dist/otel-SBVoVEHr.d.cts.map +1 -1
  37. package/dist/otlp/hono.cjs +3 -3
  38. package/dist/otlp/hono.mjs +3 -3
  39. package/dist/otlp/index.cjs +3 -3
  40. package/dist/otlp/index.mjs +3 -3
  41. package/dist/otlp/receiver.cjs +3 -3
  42. package/dist/otlp/receiver.mjs +3 -3
  43. package/dist/otlp/transformer.cjs +2 -2
  44. package/dist/otlp/transformer.mjs +2 -2
  45. package/dist/otlp/types.cjs +1 -1
  46. package/dist/otlp/types.mjs +1 -1
  47. package/dist/{receiver-slCoAFat.cjs → receiver-BW_4go_X.cjs} +2 -2
  48. package/dist/{receiver-slCoAFat.cjs.map → receiver-BW_4go_X.cjs.map} +1 -1
  49. package/dist/{receiver-D46dfkYI.mjs → receiver-q4f7eirs.mjs} +2 -2
  50. package/dist/{receiver-D46dfkYI.mjs.map → receiver-q4f7eirs.mjs.map} +1 -1
  51. package/dist/{setup-DC9JMEYZ.mjs → setup-BhCp2LUp.mjs} +1 -1
  52. package/dist/{setup-DC9JMEYZ.mjs.map → setup-BhCp2LUp.mjs.map} +1 -1
  53. package/dist/{setup-DufxQpi9.cjs → setup-_uT4L_x5.cjs} +1 -1
  54. package/dist/{setup-DufxQpi9.cjs.map → setup-_uT4L_x5.cjs.map} +1 -1
  55. package/dist/storage/kysely.d.mts.map +1 -1
  56. package/dist/tracing-BX8uY2nR.d.cts.map +1 -1
  57. package/dist/tracing-PnECEbEu.d.mts.map +1 -1
  58. package/dist/{transformer-CFQ4WFk6.mjs → transformer-CFrJQkUg.mjs} +2 -2
  59. package/dist/{transformer-CFQ4WFk6.mjs.map → transformer-CFrJQkUg.mjs.map} +1 -1
  60. package/dist/{transformer-Csl6fbgv.cjs → transformer-DvDYyFRQ.cjs} +2 -2
  61. package/dist/{transformer-Csl6fbgv.cjs.map → transformer-DvDYyFRQ.cjs.map} +1 -1
  62. package/dist/types-B1EIa_cQ.d.mts.map +1 -1
  63. package/dist/{types-BMiHgsi4.cjs → types-BBeTDpHr.cjs} +1 -1
  64. package/dist/{types-BMiHgsi4.cjs.map → types-BBeTDpHr.cjs.map} +1 -1
  65. package/dist/{types-Cj59nqy7.mjs → types-CXYLhG_G.mjs} +1 -1
  66. package/dist/{types-Cj59nqy7.mjs.map → types-CXYLhG_G.mjs.map} +1 -1
  67. package/package.json +117 -47
  68. package/ui/node_modules/.bin/vite +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-4-GrQlOT.mjs","names":["event: any","options: TelemetryMiddlewareOptions","lambdaContext: LambdaContext","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>","fn: () => Promise<T>"],"sources":["../src/instrumentation/middleware.ts"],"sourcesContent":["/**\n * OpenTelemetry instrumentation middleware for @geekmidas/constructs\n *\n * This middleware automatically creates spans for HTTP requests,\n * extracts trace context from incoming headers, and records\n * request/response metadata as span attributes.\n */\nimport type { MiddlewareObj } from '@middy/core';\nimport { context, type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for the telemetry middleware\n */\nexport interface TelemetryMiddlewareOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Whether to skip tracing for this request\n\t */\n\tshouldSkip?: (event: any) => boolean;\n}\n\n// Symbol for storing span on event\nconst SPAN_SYMBOL = Symbol('telemetry.span');\nconst CONTEXT_SYMBOL = Symbol('telemetry.context');\n\n/**\n * Get the current span from the Lambda event\n */\nexport function getSpanFromEvent(event: any): Span | undefined {\n\treturn event?.[SPAN_SYMBOL];\n}\n\n/**\n * Get the current trace context from the Lambda event\n */\nexport function getContextFromEvent(event: any): any {\n\treturn event?.[CONTEXT_SYMBOL];\n}\n\n/**\n * Create a telemetry middleware for Lambda handlers\n *\n * @example\n * ```typescript\n * import { telemetryMiddleware } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: { middleware: telemetryMiddleware() },\n * });\n * ```\n */\nexport function telemetryMiddleware(\n\toptions: TelemetryMiddlewareOptions = {},\n): MiddlewareObj<any, any, Error, LambdaContext> {\n\treturn {\n\t\tbefore: async (request) => {\n\t\t\t// Skip if custom skip function returns true\n\t\t\tif (options.shouldSkip?.(request.event)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst event = request.event;\n\t\t\tconst lambdaContext = request.context;\n\n\t\t\t// Extract trace context from headers\n\t\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t\t// Build span attributes from event\n\t\t\tconst attrs = buildSpanAttributes(event, lambdaContext, options);\n\n\t\t\t// Create the span\n\t\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\n\t\t\t// Store span and context on event for access in handler\n\t\t\tevent[SPAN_SYMBOL] = span;\n\t\t\tevent[CONTEXT_SYMBOL] = trace.setSpan(parentContext, span);\n\n\t\t\t// Add Lambda-specific attributes\n\t\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t\tif (options.recordBody && event.body) {\n\t\t\t\tconst bodyStr =\n\t\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t\t? event.body\n\t\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\t\t// Truncate large bodies\n\t\t\t\tspan.setAttribute(\n\t\t\t\t\t'http.request.body',\n\t\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tafter: async (request) => {\n\t\t\tconst span = getSpanFromEvent(request.event);\n\t\t\tif (!span) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst response = request.response;\n\t\t\tconst statusCode =\n\t\t\t\ttypeof response?.statusCode === 'number' ? response.statusCode : 200;\n\n\t\t\tif (options.recordResponseBody && response?.body) {\n\t\t\t\tconst bodyStr =\n\t\t\t\t\ttypeof response.body === 'string'\n\t\t\t\t\t\t? response.body\n\t\t\t\t\t\t: JSON.stringify(response.body);\n\t\t\t\tspan.setAttribute(\n\t\t\t\t\t'http.response.body',\n\t\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tendHttpSpan(span, { statusCode });\n\t\t},\n\n\t\tonError: async (request) => {\n\t\t\tconst span = getSpanFromEvent(request.event);\n\t\t\tif (!span) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst error = request.error;\n\t\t\tconst response = request.response;\n\n\t\t\t// Determine status code from response or error\n\t\t\tlet statusCode = 500;\n\t\t\tif (response?.statusCode) {\n\t\t\t\tstatusCode = response.statusCode;\n\t\t\t} else if (error && 'statusCode' in error) {\n\t\t\t\tstatusCode = (error as any).statusCode;\n\t\t\t}\n\n\t\t\tendHttpSpan(\n\t\t\t\tspan,\n\t\t\t\t{ statusCode },\n\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t);\n\t\t},\n\t};\n}\n\n/**\n * Build span attributes from Lambda event\n */\nfunction buildSpanAttributes(\n\tevent: any,\n\tlambdaContext: LambdaContext,\n\toptions: TelemetryMiddlewareOptions,\n): HttpSpanAttributes {\n\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\tconst isV2 =\n\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\tconst isV1 =\n\t\t'requestContext' in event &&\n\t\t'httpMethod' in event &&\n\t\t!('http' in (event.requestContext || {}));\n\n\tlet method = 'INVOKE';\n\tlet path = '/';\n\tlet route: string | undefined;\n\tlet host: string | undefined;\n\tlet scheme: 'http' | 'https' | undefined;\n\tlet userAgent: string | undefined;\n\tlet clientIp: string | undefined;\n\tlet requestId: string | undefined;\n\n\tif (isV2) {\n\t\t// API Gateway v2 (HTTP API)\n\t\tconst http = event.requestContext.http;\n\t\tmethod = http.method;\n\t\tpath = event.rawPath || http.path;\n\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\thost = event.headers?.host;\n\t\tscheme = 'https';\n\t\tuserAgent = http.userAgent;\n\t\tclientIp = http.sourceIp;\n\t\trequestId = event.requestContext.requestId;\n\t} else if (isV1) {\n\t\t// API Gateway v1 (REST API)\n\t\tmethod = event.httpMethod;\n\t\tpath = event.path;\n\t\troute = event.resource;\n\t\thost = event.headers?.Host || event.headers?.host;\n\t\tscheme = 'https';\n\t\tuserAgent = event.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\trequestId = event.requestContext?.requestId;\n\t} else if ('httpMethod' in event) {\n\t\t// ALB event\n\t\tmethod = event.httpMethod;\n\t\tpath = event.path;\n\t\thost = event.headers?.host;\n\t\tuserAgent = event.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t}\n\n\tconst attrs: HttpSpanAttributes = {\n\t\tmethod,\n\t\tpath,\n\t\troute,\n\t\thost,\n\t\tscheme,\n\t\tuserAgent,\n\t\tclientIp,\n\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t};\n\n\t// Add endpoint metadata if extractors provided\n\tif (options.getEndpointName || options.getOperationId) {\n\t\tattrs.endpoint = {\n\t\t\tname: options.getEndpointName?.(event),\n\t\t\toperationId: options.getOperationId?.(event),\n\t\t};\n\t}\n\n\t// Add user metadata if extractor provided\n\tif (options.getUserId) {\n\t\tconst userId = options.getUserId(event);\n\t\tif (userId) {\n\t\t\tattrs.user = { userId };\n\t\t}\n\t}\n\n\treturn attrs;\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n\n/**\n * Run a function within the span context from a Lambda event\n *\n * @example\n * ```typescript\n * await withEventContext(event, async () => {\n * // Any spans created here will be children of the request span\n * await doSomething();\n * });\n * ```\n */\nexport async function withEventContext<T>(\n\tevent: any,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst ctx = getContextFromEvent(event);\n\tif (!ctx) {\n\t\treturn fn();\n\t}\n\treturn context.with(ctx, fn);\n}\n"],"mappings":";;;;AAuDA,MAAM,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;AACtB,cAAY,MAAM,UAAU,iBAAiB,MAAM,UAAU;AAC7D,aAAW,MAAM,UAAU,oBAAoB,MAAM,IAAI,CAAC,IAAI,MAAM;CACpE;CAED,MAAMC,QAA4B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,aAAa,cAAc;CACtC;AAGD,KAAI,QAAQ,mBAAmB,QAAQ,eACtC,OAAM,WAAW;EAChB,MAAM,QAAQ,kBAAkB,MAAM;EACtC,aAAa,QAAQ,iBAAiB,MAAM;CAC5C;AAIF,KAAI,QAAQ,WAAW;EACtB,MAAM,SAAS,QAAQ,UAAU,MAAM;AACvC,MAAI,OACH,OAAM,OAAO,EAAE,OAAQ;CAExB;AAED,QAAO;AACP;;;;AAKD,SAAS,iBACRC,SACgD;CAChD,MAAMC,aAA4D,CAAE;AACpE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,CACjD,YAAW,IAAI,aAAa,IAAI;AAEjC,QAAO;AACP;;;;;;;;;;;;AAaD,eAAsB,iBACrBX,OACAY,IACa;CACb,MAAM,MAAM,oBAAoB,MAAM;AACtC,MAAK,IACJ,QAAO,IAAI;AAEZ,QAAO,QAAQ,KAAK,KAAK,GAAG;AAC5B"}
1
+ {"version":3,"file":"middleware-Dy1ctr2N.mjs","names":["event: any","options: TelemetryMiddlewareOptions","lambdaContext: LambdaContext","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>","fn: () => Promise<T>"],"sources":["../src/instrumentation/middleware.ts"],"sourcesContent":["/**\n * OpenTelemetry instrumentation middleware for @geekmidas/constructs\n *\n * This middleware automatically creates spans for HTTP requests,\n * extracts trace context from incoming headers, and records\n * request/response metadata as span attributes.\n */\nimport type { MiddlewareObj } from '@middy/core';\nimport { context, type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for the telemetry middleware\n */\nexport interface TelemetryMiddlewareOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Whether to skip tracing for this request\n\t */\n\tshouldSkip?: (event: any) => boolean;\n}\n\n// Symbol for storing span on event\nconst SPAN_SYMBOL = Symbol('telemetry.span');\nconst CONTEXT_SYMBOL = Symbol('telemetry.context');\n\n/**\n * Get the current span from the Lambda event\n */\nexport function getSpanFromEvent(event: any): Span | undefined {\n\treturn event?.[SPAN_SYMBOL];\n}\n\n/**\n * Get the current trace context from the Lambda event\n */\nexport function getContextFromEvent(event: any): any {\n\treturn event?.[CONTEXT_SYMBOL];\n}\n\n/**\n * Create a telemetry middleware for Lambda handlers\n *\n * @example\n * ```typescript\n * import { telemetryMiddleware } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: { middleware: telemetryMiddleware() },\n * });\n * ```\n */\nexport function telemetryMiddleware(\n\toptions: TelemetryMiddlewareOptions = {},\n): MiddlewareObj<any, any, Error, LambdaContext> {\n\treturn {\n\t\tbefore: async (request) => {\n\t\t\t// Skip if custom skip function returns true\n\t\t\tif (options.shouldSkip?.(request.event)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst event = request.event;\n\t\t\tconst lambdaContext = request.context;\n\n\t\t\t// Extract trace context from headers\n\t\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t\t// Build span attributes from event\n\t\t\tconst attrs = buildSpanAttributes(event, lambdaContext, options);\n\n\t\t\t// Create the span\n\t\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\n\t\t\t// Store span and context on event for access in handler\n\t\t\tevent[SPAN_SYMBOL] = span;\n\t\t\tevent[CONTEXT_SYMBOL] = trace.setSpan(parentContext, span);\n\n\t\t\t// Add Lambda-specific attributes\n\t\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t\tif (options.recordBody && event.body) {\n\t\t\t\tconst bodyStr =\n\t\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t\t? event.body\n\t\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\t\t// Truncate large bodies\n\t\t\t\tspan.setAttribute(\n\t\t\t\t\t'http.request.body',\n\t\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tafter: async (request) => {\n\t\t\tconst span = getSpanFromEvent(request.event);\n\t\t\tif (!span) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst response = request.response;\n\t\t\tconst statusCode =\n\t\t\t\ttypeof response?.statusCode === 'number' ? response.statusCode : 200;\n\n\t\t\tif (options.recordResponseBody && response?.body) {\n\t\t\t\tconst bodyStr =\n\t\t\t\t\ttypeof response.body === 'string'\n\t\t\t\t\t\t? response.body\n\t\t\t\t\t\t: JSON.stringify(response.body);\n\t\t\t\tspan.setAttribute(\n\t\t\t\t\t'http.response.body',\n\t\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tendHttpSpan(span, { statusCode });\n\t\t},\n\n\t\tonError: async (request) => {\n\t\t\tconst span = getSpanFromEvent(request.event);\n\t\t\tif (!span) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst error = request.error;\n\t\t\tconst response = request.response;\n\n\t\t\t// Determine status code from response or error\n\t\t\tlet statusCode = 500;\n\t\t\tif (response?.statusCode) {\n\t\t\t\tstatusCode = response.statusCode;\n\t\t\t} else if (error && 'statusCode' in error) {\n\t\t\t\tstatusCode = (error as any).statusCode;\n\t\t\t}\n\n\t\t\tendHttpSpan(\n\t\t\t\tspan,\n\t\t\t\t{ statusCode },\n\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t);\n\t\t},\n\t};\n}\n\n/**\n * Build span attributes from Lambda event\n */\nfunction buildSpanAttributes(\n\tevent: any,\n\tlambdaContext: LambdaContext,\n\toptions: TelemetryMiddlewareOptions,\n): HttpSpanAttributes {\n\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\tconst isV2 =\n\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\tconst isV1 =\n\t\t'requestContext' in event &&\n\t\t'httpMethod' in event &&\n\t\t!('http' in (event.requestContext || {}));\n\n\tlet method = 'INVOKE';\n\tlet path = '/';\n\tlet route: string | undefined;\n\tlet host: string | undefined;\n\tlet scheme: 'http' | 'https' | undefined;\n\tlet userAgent: string | undefined;\n\tlet clientIp: string | undefined;\n\tlet requestId: string | undefined;\n\n\tif (isV2) {\n\t\t// API Gateway v2 (HTTP API)\n\t\tconst http = event.requestContext.http;\n\t\tmethod = http.method;\n\t\tpath = event.rawPath || http.path;\n\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\thost = event.headers?.host;\n\t\tscheme = 'https';\n\t\tuserAgent = http.userAgent;\n\t\tclientIp = http.sourceIp;\n\t\trequestId = event.requestContext.requestId;\n\t} else if (isV1) {\n\t\t// API Gateway v1 (REST API)\n\t\tmethod = event.httpMethod;\n\t\tpath = event.path;\n\t\troute = event.resource;\n\t\thost = event.headers?.Host || event.headers?.host;\n\t\tscheme = 'https';\n\t\tuserAgent = event.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\trequestId = event.requestContext?.requestId;\n\t} else if ('httpMethod' in event) {\n\t\t// ALB event\n\t\tmethod = event.httpMethod;\n\t\tpath = event.path;\n\t\thost = event.headers?.host;\n\t\tuserAgent = event.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t}\n\n\tconst attrs: HttpSpanAttributes = {\n\t\tmethod,\n\t\tpath,\n\t\troute,\n\t\thost,\n\t\tscheme,\n\t\tuserAgent,\n\t\tclientIp,\n\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t};\n\n\t// Add endpoint metadata if extractors provided\n\tif (options.getEndpointName || options.getOperationId) {\n\t\tattrs.endpoint = {\n\t\t\tname: options.getEndpointName?.(event),\n\t\t\toperationId: options.getOperationId?.(event),\n\t\t};\n\t}\n\n\t// Add user metadata if extractor provided\n\tif (options.getUserId) {\n\t\tconst userId = options.getUserId(event);\n\t\tif (userId) {\n\t\t\tattrs.user = { userId };\n\t\t}\n\t}\n\n\treturn attrs;\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n\n/**\n * Run a function within the span context from a Lambda event\n *\n * @example\n * ```typescript\n * await withEventContext(event, async () => {\n * // Any spans created here will be children of the request span\n * await doSomething();\n * });\n * ```\n */\nexport async function withEventContext<T>(\n\tevent: any,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tconst ctx = getContextFromEvent(event);\n\tif (!ctx) {\n\t\treturn fn();\n\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EjC,WAAS,MAAM;AACf,SAAO,MAAM;AACb,SAAO,MAAM,SAAS;AACtB,cAAY,MAAM,UAAU,iBAAiB,MAAM,UAAU;AAC7D,aAAW,MAAM,UAAU,oBAAoB,MAAM,IAAI,CAAC,IAAI,MAAM;CACpE;CAED,MAAMC,QAA4B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,aAAa,cAAc;CACtC;AAGD,KAAI,QAAQ,mBAAmB,QAAQ,eACtC,OAAM,WAAW;EAChB,MAAM,QAAQ,kBAAkB,MAAM;EACtC,aAAa,QAAQ,iBAAiB,MAAM;CAC5C;AAIF,KAAI,QAAQ,WAAW;EACtB,MAAM,SAAS,QAAQ,UAAU,MAAM;AACvC,MAAI,OACH,OAAM,OAAO,EAAE,OAAQ;CAExB;AAED,QAAO;AACP;;;;AAKD,SAAS,iBACRC,SACgD;CAChD,MAAMC,aAA4D,CAAE;AACpE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,CACjD,YAAW,IAAI,aAAa,IAAI;AAEjC,QAAO;AACP;;;;;;;;;;;;AAaD,eAAsB,iBACrBX,OACAY,IACa;CACb,MAAM,MAAM,oBAAoB,MAAM;AACtC,MAAK,IACJ,QAAO,IAAI;AAEZ,QAAO,QAAQ,KAAK,KAAK,GAAG;AAC5B"}
@@ -1,4 +1,4 @@
1
- import { createHttpServerSpan, endHttpSpan, extractTraceContext } from "./http-BIvr0YdI.mjs";
1
+ import { createHttpServerSpan, endHttpSpan, extractTraceContext } from "./http-Crsriv32.mjs";
2
2
  import { trace } from "@opentelemetry/api";
3
3
 
4
4
  //#region src/instrumentation/otel.ts
@@ -127,4 +127,4 @@ function normalizeHeaders(headers) {
127
127
 
128
128
  //#endregion
129
129
  export { OTelTelemetry };
130
- //# sourceMappingURL=otel-40udNP5g.mjs.map
130
+ //# sourceMappingURL=otel-DPKNyJ0t.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"otel-40udNP5g.mjs","names":["options: OTelTelemetryOptions","request: TelemetryRequest","ctx: TelemetryContext","response: TelemetryResponse","error: Error","event: any","lambdaContext: any","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>"],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":["/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * This provides automatic span creation for Lambda handlers using\n * OpenTelemetry. Works with any OTel-compatible backend (Jaeger, Zipkin,\n * Datadog, Honeycomb, etc.)\n */\nimport { type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\n\n/**\n * Context object returned by onRequestStart, passed to subsequent hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryContext {\n\t[key: string]: unknown;\n}\n\n/**\n * Request information passed to telemetry hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryRequest {\n\tevent: any;\n\tcontext: LambdaContext;\n}\n\n/**\n * Response information passed to onRequestEnd.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryResponse {\n\tstatusCode: number;\n\tbody?: string;\n\theaders?: Record<string, string>;\n}\n\n/**\n * Telemetry interface for instrumenting endpoint requests.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface Telemetry {\n\tonRequestStart(request: TelemetryRequest): TelemetryContext;\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void;\n\tonRequestError(ctx: TelemetryContext, error: Error): void;\n}\n\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for OTelTelemetry\n */\nexport interface OTelTelemetryOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n}\n\n/**\n * Telemetry context with span reference\n */\ninterface OTelContext extends TelemetryContext {\n\tspan: Span;\n\totelContext: any;\n}\n\n/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * @example\n * ```typescript\n * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry(),\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry({\n * recordBody: true,\n * getUserId: (event) => event.requestContext?.authorizer?.userId,\n * }),\n * });\n * ```\n */\nexport class OTelTelemetry implements Telemetry {\n\tconstructor(private options: OTelTelemetryOptions = {}) {}\n\n\tonRequestStart(request: TelemetryRequest): TelemetryContext {\n\t\tconst { event, context: lambdaContext } = request;\n\n\t\t// Extract trace context from headers\n\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from event\n\t\tconst attrs = this.buildSpanAttributes(event, lambdaContext);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst otelContext = trace.setSpan(parentContext, span);\n\n\t\t// Add Lambda-specific attributes\n\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t// Record body if requested\n\t\tif (this.options.recordBody && event.body) {\n\t\t\tconst bodyStr =\n\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t? event.body\n\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.request.body',\n\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t);\n\t\t}\n\n\t\treturn { span, otelContext } as OTelContext;\n\t}\n\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void {\n\t\tconst { span } = ctx as OTelContext;\n\n\t\tif (this.options.recordResponseBody && response.body) {\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.response.body',\n\t\t\t\tresponse.body.length > 4096\n\t\t\t\t\t? `${response.body.slice(0, 4096)}...`\n\t\t\t\t\t: response.body,\n\t\t\t);\n\t\t}\n\n\t\tendHttpSpan(span, { statusCode: response.statusCode });\n\t}\n\n\tonRequestError(ctx: TelemetryContext, error: Error): void {\n\t\tconst { span } = ctx as OTelContext;\n\t\tendHttpSpan(span, { statusCode: 500 }, error);\n\t}\n\n\t/**\n\t * Build span attributes from Lambda event\n\t */\n\tprivate buildSpanAttributes(\n\t\tevent: any,\n\t\tlambdaContext: any,\n\t): HttpSpanAttributes {\n\t\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\t\tconst isV2 =\n\t\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\t\tconst isV1 =\n\t\t\t'requestContext' in event &&\n\t\t\t'httpMethod' in event &&\n\t\t\t!('http' in (event.requestContext || {}));\n\n\t\tlet method = 'INVOKE';\n\t\tlet path = '/';\n\t\tlet route: string | undefined;\n\t\tlet host: string | undefined;\n\t\tlet scheme: 'http' | 'https' | undefined;\n\t\tlet userAgent: string | undefined;\n\t\tlet clientIp: string | undefined;\n\t\tlet requestId: string | undefined;\n\n\t\tif (isV2) {\n\t\t\t// API Gateway v2 (HTTP API)\n\t\t\tconst http = event.requestContext.http;\n\t\t\tmethod = http.method;\n\t\t\tpath = event.rawPath || http.path;\n\t\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\t\thost = event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent = http.userAgent;\n\t\t\tclientIp = http.sourceIp;\n\t\t\trequestId = event.requestContext.requestId;\n\t\t} else if (isV1) {\n\t\t\t// API Gateway v1 (REST API)\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\troute = event.resource;\n\t\t\thost = event.headers?.Host || event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\t\trequestId = event.requestContext?.requestId;\n\t\t} else if ('httpMethod' in event) {\n\t\t\t// ALB event\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\thost = event.headers?.host;\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t\t}\n\n\t\tconst attrs: HttpSpanAttributes = {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\troute,\n\t\t\thost,\n\t\t\tscheme,\n\t\t\tuserAgent,\n\t\t\tclientIp,\n\t\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t\t};\n\n\t\t// Add endpoint metadata if extractors provided\n\t\tif (this.options.getEndpointName || this.options.getOperationId) {\n\t\t\tattrs.endpoint = {\n\t\t\t\tname: this.options.getEndpointName?.(event),\n\t\t\t\toperationId: this.options.getOperationId?.(event),\n\t\t\t};\n\t\t}\n\n\t\t// Add user metadata if extractor provided\n\t\tif (this.options.getUserId) {\n\t\t\tconst userId = this.options.getUserId(event);\n\t\t\tif (userId) {\n\t\t\t\tattrs.user = { userId };\n\t\t\t}\n\t\t}\n\n\t\treturn attrs;\n\t}\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,gBAAb,MAAgD;CAC/C,YAAoBA,UAAgC,CAAE,GAAE;EAApC;CAAsC;CAE1D,eAAeC,SAA6C;EAC3D,MAAM,EAAE,OAAO,SAAS,eAAe,GAAG;EAG1C,MAAM,UAAU,iBAAiB,MAAM,WAAW,CAAE,EAAC;EACrD,MAAM,gBAAgB,oBAAoB,QAAQ;EAGlD,MAAM,QAAQ,KAAK,oBAAoB,OAAO,cAAc;EAG5D,MAAM,OAAO,qBAAqB,OAAO,cAAc;EACvD,MAAM,cAAc,MAAM,QAAQ,eAAe,KAAK;AAGtD,OAAK,aAAa,sBAAsB,cAAc,aAAa;AACnE,OAAK,aAAa,aAAa,cAAc,aAAa;AAG1D,MAAI,KAAK,QAAQ,cAAc,MAAM,MAAM;GAC1C,MAAM,iBACE,MAAM,SAAS,WACnB,MAAM,OACN,KAAK,UAAU,MAAM,KAAK;AAC9B,QAAK,aACJ,qBACA,QAAQ,SAAS,QAAQ,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC,OAAO,QACzD;EACD;AAED,SAAO;GAAE;GAAM;EAAa;CAC5B;CAED,aAAaC,KAAuBC,UAAmC;EACtE,MAAM,EAAE,MAAM,GAAG;AAEjB,MAAI,KAAK,QAAQ,sBAAsB,SAAS,KAC/C,MAAK,aACJ,sBACA,SAAS,KAAK,SAAS,QACnB,EAAE,SAAS,KAAK,MAAM,GAAG,KAAK,CAAC,OAChC,SAAS,KACZ;AAGF,cAAY,MAAM,EAAE,YAAY,SAAS,WAAY,EAAC;CACtD;CAED,eAAeD,KAAuBE,OAAoB;EACzD,MAAM,EAAE,MAAM,GAAG;AACjB,cAAY,MAAM,EAAE,YAAY,IAAK,GAAE,MAAM;CAC7C;;;;CAKD,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AU,MAAM;AAC5C,OAAI,OACH,OAAM,OAAO,EAAE,OAAQ;EAExB;AAED,SAAO;CACP;AACD;;;;AAKD,SAAS,iBACRC,SACgD;CAChD,MAAMC,aAA4D,CAAE;AACpE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,CACjD,YAAW,IAAI,aAAa,IAAI;AAEjC,QAAO;AACP"}
1
+ {"version":3,"file":"otel-DPKNyJ0t.mjs","names":["options: OTelTelemetryOptions","request: TelemetryRequest","ctx: TelemetryContext","response: TelemetryResponse","error: Error","event: any","lambdaContext: any","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>"],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":["/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * This provides automatic span creation for Lambda handlers using\n * OpenTelemetry. Works with any OTel-compatible backend (Jaeger, Zipkin,\n * Datadog, Honeycomb, etc.)\n */\nimport { type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\n\n/**\n * Context object returned by onRequestStart, passed to subsequent hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryContext {\n\t[key: string]: unknown;\n}\n\n/**\n * Request information passed to telemetry hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryRequest {\n\tevent: any;\n\tcontext: LambdaContext;\n}\n\n/**\n * Response information passed to onRequestEnd.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryResponse {\n\tstatusCode: number;\n\tbody?: string;\n\theaders?: Record<string, string>;\n}\n\n/**\n * Telemetry interface for instrumenting endpoint requests.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface Telemetry {\n\tonRequestStart(request: TelemetryRequest): TelemetryContext;\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void;\n\tonRequestError(ctx: TelemetryContext, error: Error): void;\n}\n\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for OTelTelemetry\n */\nexport interface OTelTelemetryOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n}\n\n/**\n * Telemetry context with span reference\n */\ninterface OTelContext extends TelemetryContext {\n\tspan: Span;\n\totelContext: any;\n}\n\n/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * @example\n * ```typescript\n * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry(),\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry({\n * recordBody: true,\n * getUserId: (event) => event.requestContext?.authorizer?.userId,\n * }),\n * });\n * ```\n */\nexport class OTelTelemetry implements Telemetry {\n\tconstructor(private options: OTelTelemetryOptions = {}) {}\n\n\tonRequestStart(request: TelemetryRequest): TelemetryContext {\n\t\tconst { event, context: lambdaContext } = request;\n\n\t\t// Extract trace context from headers\n\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from event\n\t\tconst attrs = this.buildSpanAttributes(event, lambdaContext);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst otelContext = trace.setSpan(parentContext, span);\n\n\t\t// Add Lambda-specific attributes\n\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t// Record body if requested\n\t\tif (this.options.recordBody && event.body) {\n\t\t\tconst bodyStr =\n\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t? event.body\n\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.request.body',\n\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t);\n\t\t}\n\n\t\treturn { span, otelContext } as OTelContext;\n\t}\n\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void {\n\t\tconst { span } = ctx as OTelContext;\n\n\t\tif (this.options.recordResponseBody && response.body) {\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.response.body',\n\t\t\t\tresponse.body.length > 4096\n\t\t\t\t\t? `${response.body.slice(0, 4096)}...`\n\t\t\t\t\t: response.body,\n\t\t\t);\n\t\t}\n\n\t\tendHttpSpan(span, { statusCode: response.statusCode });\n\t}\n\n\tonRequestError(ctx: TelemetryContext, error: Error): void {\n\t\tconst { span } = ctx as OTelContext;\n\t\tendHttpSpan(span, { statusCode: 500 }, error);\n\t}\n\n\t/**\n\t * Build span attributes from Lambda event\n\t */\n\tprivate buildSpanAttributes(\n\t\tevent: any,\n\t\tlambdaContext: any,\n\t): HttpSpanAttributes {\n\t\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\t\tconst isV2 =\n\t\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\t\tconst isV1 =\n\t\t\t'requestContext' in event &&\n\t\t\t'httpMethod' in event &&\n\t\t\t!('http' in (event.requestContext || {}));\n\n\t\tlet method = 'INVOKE';\n\t\tlet path = '/';\n\t\tlet route: string | undefined;\n\t\tlet host: string | undefined;\n\t\tlet scheme: 'http' | 'https' | undefined;\n\t\tlet userAgent: string | undefined;\n\t\tlet clientIp: string | undefined;\n\t\tlet requestId: string | undefined;\n\n\t\tif (isV2) {\n\t\t\t// API Gateway v2 (HTTP API)\n\t\t\tconst http = event.requestContext.http;\n\t\t\tmethod = http.method;\n\t\t\tpath = event.rawPath || http.path;\n\t\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\t\thost = event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent = http.userAgent;\n\t\t\tclientIp = http.sourceIp;\n\t\t\trequestId = event.requestContext.requestId;\n\t\t} else if (isV1) {\n\t\t\t// API Gateway v1 (REST API)\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\troute = event.resource;\n\t\t\thost = event.headers?.Host || event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\t\trequestId = event.requestContext?.requestId;\n\t\t} else if ('httpMethod' in event) {\n\t\t\t// ALB event\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\thost = event.headers?.host;\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t\t}\n\n\t\tconst attrs: HttpSpanAttributes = {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\troute,\n\t\t\thost,\n\t\t\tscheme,\n\t\t\tuserAgent,\n\t\t\tclientIp,\n\t\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t\t};\n\n\t\t// Add endpoint metadata if extractors provided\n\t\tif (this.options.getEndpointName || this.options.getOperationId) {\n\t\t\tattrs.endpoint = {\n\t\t\t\tname: this.options.getEndpointName?.(event),\n\t\t\t\toperationId: this.options.getOperationId?.(event),\n\t\t\t};\n\t\t}\n\n\t\t// Add user metadata if extractor provided\n\t\tif (this.options.getUserId) {\n\t\t\tconst userId = this.options.getUserId(event);\n\t\t\tif (userId) {\n\t\t\t\tattrs.user = { userId };\n\t\t\t}\n\t\t}\n\n\t\treturn attrs;\n\t}\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,gBAAb,MAAgD;CAC/C,YAAoBA,UAAgC,CAAE,GAAE;EAApC;CAAsC;CAE1D,eAAeC,SAA6C;EAC3D,MAAM,EAAE,OAAO,SAAS,eAAe,GAAG;EAG1C,MAAM,UAAU,iBAAiB,MAAM,WAAW,CAAE,EAAC;EACrD,MAAM,gBAAgB,oBAAoB,QAAQ;EAGlD,MAAM,QAAQ,KAAK,oBAAoB,OAAO,cAAc;EAG5D,MAAM,OAAO,qBAAqB,OAAO,cAAc;EACvD,MAAM,cAAc,MAAM,QAAQ,eAAe,KAAK;AAGtD,OAAK,aAAa,sBAAsB,cAAc,aAAa;AACnE,OAAK,aAAa,aAAa,cAAc,aAAa;AAG1D,MAAI,KAAK,QAAQ,cAAc,MAAM,MAAM;GAC1C,MAAM,iBACE,MAAM,SAAS,WACnB,MAAM,OACN,KAAK,UAAU,MAAM,KAAK;AAC9B,QAAK,aACJ,qBACA,QAAQ,SAAS,QAAQ,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC,OAAO,QACzD;EACD;AAED,SAAO;GAAE;GAAM;EAAa;CAC5B;CAED,aAAaC,KAAuBC,UAAmC;EACtE,MAAM,EAAE,MAAM,GAAG;AAEjB,MAAI,KAAK,QAAQ,sBAAsB,SAAS,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A4B;GACjC;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,aAAa,cAAc;EACtC;AAGD,MAAI,KAAK,QAAQ,mBAAmB,KAAK,QAAQ,eAChD,OAAM,WAAW;GAChB,MAAM,KAAK,QAAQ,kBAAkB,MAAM;GAC3C,aAAa,KAAK,QAAQ,iBAAiB,MAAM;EACjD;AAIF,MAAI,KAAK,QAAQ,WAAW;GAC3B,MAAM,SAAS,KAAK,QAAQ,UAAU,MAAM;AAC5C,OAAI,OACH,OAAM,OAAO,EAAE,OAAQ;EAExB;AAED,SAAO;CACP;AACD;;;;AAKD,SAAS,iBACRC,SACgD;CAChD,MAAMC,aAA4D,CAAE;AACpE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,CACjD,YAAW,IAAI,aAAa,IAAI;AAEjC,QAAO;AACP"}
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_http = require('./http-BsqmhurZ.cjs');
2
+ const require_http = require('./http-JycFRfSe.cjs');
3
3
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
4
4
 
5
5
  //#region src/instrumentation/otel.ts
@@ -133,4 +133,4 @@ Object.defineProperty(exports, 'OTelTelemetry', {
133
133
  return OTelTelemetry;
134
134
  }
135
135
  });
136
- //# sourceMappingURL=otel-COrpz_GZ.cjs.map
136
+ //# sourceMappingURL=otel-DuiBeBPU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"otel-COrpz_GZ.cjs","names":["options: OTelTelemetryOptions","request: TelemetryRequest","ctx: TelemetryContext","response: TelemetryResponse","error: Error","event: any","lambdaContext: any","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>"],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":["/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * This provides automatic span creation for Lambda handlers using\n * OpenTelemetry. Works with any OTel-compatible backend (Jaeger, Zipkin,\n * Datadog, Honeycomb, etc.)\n */\nimport { type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\n\n/**\n * Context object returned by onRequestStart, passed to subsequent hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryContext {\n\t[key: string]: unknown;\n}\n\n/**\n * Request information passed to telemetry hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryRequest {\n\tevent: any;\n\tcontext: LambdaContext;\n}\n\n/**\n * Response information passed to onRequestEnd.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryResponse {\n\tstatusCode: number;\n\tbody?: string;\n\theaders?: Record<string, string>;\n}\n\n/**\n * Telemetry interface for instrumenting endpoint requests.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface Telemetry {\n\tonRequestStart(request: TelemetryRequest): TelemetryContext;\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void;\n\tonRequestError(ctx: TelemetryContext, error: Error): void;\n}\n\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for OTelTelemetry\n */\nexport interface OTelTelemetryOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n}\n\n/**\n * Telemetry context with span reference\n */\ninterface OTelContext extends TelemetryContext {\n\tspan: Span;\n\totelContext: any;\n}\n\n/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * @example\n * ```typescript\n * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry(),\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry({\n * recordBody: true,\n * getUserId: (event) => event.requestContext?.authorizer?.userId,\n * }),\n * });\n * ```\n */\nexport class OTelTelemetry implements Telemetry {\n\tconstructor(private options: OTelTelemetryOptions = {}) {}\n\n\tonRequestStart(request: TelemetryRequest): TelemetryContext {\n\t\tconst { event, context: lambdaContext } = request;\n\n\t\t// Extract trace context from headers\n\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from event\n\t\tconst attrs = this.buildSpanAttributes(event, lambdaContext);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst otelContext = trace.setSpan(parentContext, span);\n\n\t\t// Add Lambda-specific attributes\n\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t// Record body if requested\n\t\tif (this.options.recordBody && event.body) {\n\t\t\tconst bodyStr =\n\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t? event.body\n\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.request.body',\n\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t);\n\t\t}\n\n\t\treturn { span, otelContext } as OTelContext;\n\t}\n\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void {\n\t\tconst { span } = ctx as OTelContext;\n\n\t\tif (this.options.recordResponseBody && response.body) {\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.response.body',\n\t\t\t\tresponse.body.length > 4096\n\t\t\t\t\t? `${response.body.slice(0, 4096)}...`\n\t\t\t\t\t: response.body,\n\t\t\t);\n\t\t}\n\n\t\tendHttpSpan(span, { statusCode: response.statusCode });\n\t}\n\n\tonRequestError(ctx: TelemetryContext, error: Error): void {\n\t\tconst { span } = ctx as OTelContext;\n\t\tendHttpSpan(span, { statusCode: 500 }, error);\n\t}\n\n\t/**\n\t * Build span attributes from Lambda event\n\t */\n\tprivate buildSpanAttributes(\n\t\tevent: any,\n\t\tlambdaContext: any,\n\t): HttpSpanAttributes {\n\t\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\t\tconst isV2 =\n\t\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\t\tconst isV1 =\n\t\t\t'requestContext' in event &&\n\t\t\t'httpMethod' in event &&\n\t\t\t!('http' in (event.requestContext || {}));\n\n\t\tlet method = 'INVOKE';\n\t\tlet path = '/';\n\t\tlet route: string | undefined;\n\t\tlet host: string | undefined;\n\t\tlet scheme: 'http' | 'https' | undefined;\n\t\tlet userAgent: string | undefined;\n\t\tlet clientIp: string | undefined;\n\t\tlet requestId: string | undefined;\n\n\t\tif (isV2) {\n\t\t\t// API Gateway v2 (HTTP API)\n\t\t\tconst http = event.requestContext.http;\n\t\t\tmethod = http.method;\n\t\t\tpath = event.rawPath || http.path;\n\t\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\t\thost = event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent = http.userAgent;\n\t\t\tclientIp = http.sourceIp;\n\t\t\trequestId = event.requestContext.requestId;\n\t\t} else if (isV1) {\n\t\t\t// API Gateway v1 (REST API)\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\troute = event.resource;\n\t\t\thost = event.headers?.Host || event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\t\trequestId = event.requestContext?.requestId;\n\t\t} else if ('httpMethod' in event) {\n\t\t\t// ALB event\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\thost = event.headers?.host;\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t\t}\n\n\t\tconst attrs: HttpSpanAttributes = {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\troute,\n\t\t\thost,\n\t\t\tscheme,\n\t\t\tuserAgent,\n\t\t\tclientIp,\n\t\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t\t};\n\n\t\t// Add endpoint metadata if extractors provided\n\t\tif (this.options.getEndpointName || this.options.getOperationId) {\n\t\t\tattrs.endpoint = {\n\t\t\t\tname: this.options.getEndpointName?.(event),\n\t\t\t\toperationId: this.options.getOperationId?.(event),\n\t\t\t};\n\t\t}\n\n\t\t// Add user metadata if extractor provided\n\t\tif (this.options.getUserId) {\n\t\t\tconst userId = this.options.getUserId(event);\n\t\t\tif (userId) {\n\t\t\t\tattrs.user = { userId };\n\t\t\t}\n\t\t}\n\n\t\treturn attrs;\n\t}\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,gBAAb,MAAgD;CAC/C,YAAoBA,UAAgC,CAAE,GAAE;EAApC;CAAsC;CAE1D,eAAeC,SAA6C;EAC3D,MAAM,EAAE,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eBPU.cjs","names":["options: OTelTelemetryOptions","request: TelemetryRequest","ctx: TelemetryContext","response: TelemetryResponse","error: Error","event: any","lambdaContext: any","route: string | undefined","host: string | undefined","scheme: 'http' | 'https' | undefined","userAgent: string | undefined","clientIp: string | undefined","requestId: string | undefined","attrs: HttpSpanAttributes","headers: Record<string, string | string[] | undefined>","normalized: Record<string, string | string[] | undefined>"],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":["/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * This provides automatic span creation for Lambda handlers using\n * OpenTelemetry. Works with any OTel-compatible backend (Jaeger, Zipkin,\n * Datadog, Honeycomb, etc.)\n */\nimport { type Span, trace } from '@opentelemetry/api';\nimport type { Context as LambdaContext } from 'aws-lambda';\n\n/**\n * Context object returned by onRequestStart, passed to subsequent hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryContext {\n\t[key: string]: unknown;\n}\n\n/**\n * Request information passed to telemetry hooks.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryRequest {\n\tevent: any;\n\tcontext: LambdaContext;\n}\n\n/**\n * Response information passed to onRequestEnd.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface TelemetryResponse {\n\tstatusCode: number;\n\tbody?: string;\n\theaders?: Record<string, string>;\n}\n\n/**\n * Telemetry interface for instrumenting endpoint requests.\n * This matches the Telemetry interface from @geekmidas/constructs.\n */\nexport interface Telemetry {\n\tonRequestStart(request: TelemetryRequest): TelemetryContext;\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void;\n\tonRequestError(ctx: TelemetryContext, error: Error): void;\n}\n\nimport {\n\tcreateHttpServerSpan,\n\tendHttpSpan,\n\textractTraceContext,\n\ttype HttpSpanAttributes,\n} from './http';\n\n/**\n * Options for OTelTelemetry\n */\nexport interface OTelTelemetryOptions {\n\t/**\n\t * Whether to record request body as span attribute\n\t * @default false\n\t */\n\trecordBody?: boolean;\n\n\t/**\n\t * Whether to record response body as span attribute\n\t * @default false\n\t */\n\trecordResponseBody?: boolean;\n\n\t/**\n\t * Custom function to extract user ID from event\n\t */\n\tgetUserId?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract endpoint name from event\n\t */\n\tgetEndpointName?: (event: any) => string | undefined;\n\n\t/**\n\t * Custom function to extract operation ID from event\n\t */\n\tgetOperationId?: (event: any) => string | undefined;\n}\n\n/**\n * Telemetry context with span reference\n */\ninterface OTelContext extends TelemetryContext {\n\tspan: Span;\n\totelContext: any;\n}\n\n/**\n * OpenTelemetry implementation of the Telemetry interface\n *\n * @example\n * ```typescript\n * import { OTelTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry(),\n * });\n * ```\n *\n * @example With options\n * ```typescript\n * const adaptor = new AmazonApiGatewayV2Endpoint(envParser, endpoint, {\n * telemetry: new OTelTelemetry({\n * recordBody: true,\n * getUserId: (event) => event.requestContext?.authorizer?.userId,\n * }),\n * });\n * ```\n */\nexport class OTelTelemetry implements Telemetry {\n\tconstructor(private options: OTelTelemetryOptions = {}) {}\n\n\tonRequestStart(request: TelemetryRequest): TelemetryContext {\n\t\tconst { event, context: lambdaContext } = request;\n\n\t\t// Extract trace context from headers\n\t\tconst headers = normalizeHeaders(event.headers || {});\n\t\tconst parentContext = extractTraceContext(headers);\n\n\t\t// Build span attributes from event\n\t\tconst attrs = this.buildSpanAttributes(event, lambdaContext);\n\n\t\t// Create the span\n\t\tconst span = createHttpServerSpan(attrs, parentContext);\n\t\tconst otelContext = trace.setSpan(parentContext, span);\n\n\t\t// Add Lambda-specific attributes\n\t\tspan.setAttribute('faas.invocation_id', lambdaContext.awsRequestId);\n\t\tspan.setAttribute('faas.name', lambdaContext.functionName);\n\n\t\t// Record body if requested\n\t\tif (this.options.recordBody && event.body) {\n\t\t\tconst bodyStr =\n\t\t\t\ttypeof event.body === 'string'\n\t\t\t\t\t? event.body\n\t\t\t\t\t: JSON.stringify(event.body);\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.request.body',\n\t\t\t\tbodyStr.length > 4096 ? `${bodyStr.slice(0, 4096)}...` : bodyStr,\n\t\t\t);\n\t\t}\n\n\t\treturn { span, otelContext } as OTelContext;\n\t}\n\n\tonRequestEnd(ctx: TelemetryContext, response: TelemetryResponse): void {\n\t\tconst { span } = ctx as OTelContext;\n\n\t\tif (this.options.recordResponseBody && response.body) {\n\t\t\tspan.setAttribute(\n\t\t\t\t'http.response.body',\n\t\t\t\tresponse.body.length > 4096\n\t\t\t\t\t? `${response.body.slice(0, 4096)}...`\n\t\t\t\t\t: response.body,\n\t\t\t);\n\t\t}\n\n\t\tendHttpSpan(span, { statusCode: response.statusCode });\n\t}\n\n\tonRequestError(ctx: TelemetryContext, error: Error): void {\n\t\tconst { span } = ctx as OTelContext;\n\t\tendHttpSpan(span, { statusCode: 500 }, error);\n\t}\n\n\t/**\n\t * Build span attributes from Lambda event\n\t */\n\tprivate buildSpanAttributes(\n\t\tevent: any,\n\t\tlambdaContext: any,\n\t): HttpSpanAttributes {\n\t\t// Detect event type (API Gateway v1, v2, ALB, or direct invoke)\n\t\tconst isV2 =\n\t\t\t'requestContext' in event && 'http' in (event.requestContext || {});\n\t\tconst isV1 =\n\t\t\t'requestContext' in event &&\n\t\t\t'httpMethod' in event &&\n\t\t\t!('http' in (event.requestContext || {}));\n\n\t\tlet method = 'INVOKE';\n\t\tlet path = '/';\n\t\tlet route: string | undefined;\n\t\tlet host: string | undefined;\n\t\tlet scheme: 'http' | 'https' | undefined;\n\t\tlet userAgent: string | undefined;\n\t\tlet clientIp: string | undefined;\n\t\tlet requestId: string | undefined;\n\n\t\tif (isV2) {\n\t\t\t// API Gateway v2 (HTTP API)\n\t\t\tconst http = event.requestContext.http;\n\t\t\tmethod = http.method;\n\t\t\tpath = event.rawPath || http.path;\n\t\t\troute = event.routeKey?.replace(/^[A-Z]+\\s+/, ''); // Remove HTTP method prefix\n\t\t\thost = event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent = http.userAgent;\n\t\t\tclientIp = http.sourceIp;\n\t\t\trequestId = event.requestContext.requestId;\n\t\t} else if (isV1) {\n\t\t\t// API Gateway v1 (REST API)\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\troute = event.resource;\n\t\t\thost = event.headers?.Host || event.headers?.host;\n\t\t\tscheme = 'https';\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['User-Agent'] || event.headers?.['user-agent'];\n\t\t\tclientIp = event.requestContext?.identity?.sourceIp;\n\t\t\trequestId = event.requestContext?.requestId;\n\t\t} else if ('httpMethod' in event) {\n\t\t\t// ALB event\n\t\t\tmethod = event.httpMethod;\n\t\t\tpath = event.path;\n\t\t\thost = event.headers?.host;\n\t\t\tuserAgent =\n\t\t\t\tevent.headers?.['user-agent'] || event.headers?.['User-Agent'];\n\t\t\tclientIp = event.headers?.['x-forwarded-for']?.split(',')[0]?.trim();\n\t\t}\n\n\t\tconst attrs: HttpSpanAttributes = {\n\t\t\tmethod,\n\t\t\tpath,\n\t\t\troute,\n\t\t\thost,\n\t\t\tscheme,\n\t\t\tuserAgent,\n\t\t\tclientIp,\n\t\t\trequestId: requestId || lambdaContext.awsRequestId,\n\t\t};\n\n\t\t// Add endpoint metadata if extractors provided\n\t\tif (this.options.getEndpointName || this.options.getOperationId) {\n\t\t\tattrs.endpoint = {\n\t\t\t\tname: this.options.getEndpointName?.(event),\n\t\t\t\toperationId: this.options.getOperationId?.(event),\n\t\t\t};\n\t\t}\n\n\t\t// Add user metadata if extractor provided\n\t\tif (this.options.getUserId) {\n\t\t\tconst userId = this.options.getUserId(event);\n\t\t\tif (userId) {\n\t\t\t\tattrs.user = { userId };\n\t\t\t}\n\t\t}\n\n\t\treturn attrs;\n\t}\n}\n\n/**\n * Normalize headers to lowercase keys\n */\nfunction normalizeHeaders(\n\theaders: Record<string, string | string[] | undefined>,\n): Record<string, string | string[] | undefined> {\n\tconst normalized: Record<string, string | string[] | undefined> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tnormalized[key.toLowerCase()] = value;\n\t}\n\treturn normalized;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,gBAAb,MAAgD;CAC/C,YAAoBA,UAAgC,CAAE,GAAE;EAApC;CAAsC;CAE1D,eAAeC,SAA6C;EAC3D,MAAM,EAAE,OAAO,SAAS,eAAe,GAAG;EAG1C,MAAM,UAAU,iBAAiB,MAAM,WAAW,CAAE,EAAC;EACrD,MAAM,gBAAgB,iCAAoB,QAAQ;EAGlD,MAAM,QAAQ,KAAK,oBAAoB,OAAO,cAAc;EAG5D,MAAM,OAAO,kCAAqB,OAAO,cAAc;EACvD,MAAM,cAAc,0BAAM,QAAQ,eAAe,KAAK;AAGtD,OAAK,aAAa,sBAAsB,cAAc,aAAa;AACnE,OAAK,aAAa,aAAa,cAAc,aAAa;AAG1D,MAAI,KAAK,QAAQ,cAAc,MAAM,MAAM;GAC1C,MAAM,iBACE,MAAM,SAAS,WACnB,MAAM,OACN,KAAK,UAAU,MAAM,KAAK;AAC9B,QAAK,aACJ,qBACA,QAAQ,SAAS,QAAQ,EAAE,QAAQ,MAAM,GAAG,KAAK,CAAC,OAAO,QACzD;EACD;AAED,SAAO;GAAE;GAAM;EAAa;CAC5B;CAED,aAAaC,KAAuBC,UAAmC;EACtE,MAAM,EAAE,MAAM,GAAG;AAEjB,MAAI,KAAK,QAAQ,sBAAsB,SAAS,KAC/C,MAAK,aACJ,sBACA,SAAS,KAAK,SAAS,QACnB,EAAE,SAAS,KAAK,MAAM,GAAG,KAAK,CAAC,OAChC,SAAS,KACZ;AAGF,2BAAY,MAAM,EAAE,YAAY,SAAS,WAAY,EAAC;CACtD;CAED,eAAeD,KAAuBE,OAAoB;EACzD,MAAM,EAAE,MAAM,GAAG;AACjB,2BAAY,MAAM,EAAE,YAAY,IAAK,GAAE,MAAM;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,KAAK,QAAQ,UAAU,MAAM;AAC5C,OAAI,OACH,OAAM,OAAO,EAAE,OAAQ;EAExB;AAED,SAAO;CACP;AACD;;;;AAKD,SAAS,iBACRC,SACgD;CAChD,MAAMC,aAA4D,CAAE;AACpE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,CACjD,YAAW,IAAI,aAAa,IAAI;AAEjC,QAAO;AACP"}
@@ -1 +1 @@
1
- {"version":3,"file":"otel-SBVoVEHr.d.cts","names":[],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":[],"mappings":";;;;;;AAcA;AAQA;AASiB,UAjBA,gBAAA,CAoBN;EAOM,CAAA,GAAA,EAAA,MAAS,CAAA,EAAA,OAAA;;;;;;AAGL,UAtBJ,gBAAA,CAsBI;EAAgB,KAAS,EAAA,GAAA;EAAK,OAAA,EApBzC,OAoByC;AAanD;AA2DA;;;;AAG4C,UAxF3B,iBAAA,CAwF2B;EAAgB,UAiCzC,EAAA,MAAA;EAAgB,IAAY,CAAA,EAAA,MAAA;EAAiB,OAe3C,CAAA,EArIV,MAqIU,CAAA,MAAA,EAAA,MAAA,CAAA;;;AAnD0B;;;UA3E9B,SAAA;0BACQ,mBAAmB;oBACzB,4BAA4B;sBAC1B,yBAAyB;;;;;UAa7B,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2DJ,aAAA,YAAyB;;wBACR;0BAEL,mBAAmB;oBAiCzB,4BAA4B;sBAe1B,yBAAyB"}
1
+ {"version":3,"file":"otel-SBVoVEHr.d.cts","names":[],"sources":["../src/instrumentation/otel.ts"],"sourcesContent":[],"mappings":";;;;;;AAcA;AAQA;AASiB,UAjBA,gBAAA,CAiBiB;EAUjB,CAAA,GAAA,EAAA,MAAS,CAAA,EAAA,OAAA;;;;;;AAGL,UAtBJ,gBAAA,CAsBI;EAAgB,KAAS,EAAA,GAAA;EAAK,OAAA,EApBzC,OAoByC;AAanD;AA2DA;;;;AAG4C,UAxF3B,iBAAA,CAwF2B;EAAgB,UAiCzC,EAAA,MAAA;EAAgB,IAAY,CAAA,EAAA,MAAA;EAAiB,OAe3C,CAAA,EArIV,MAqIU,CAAA,MAAA,EAAA,MAAA,CAAA;;;AAnD0B;;;UA3E9B,SAAA;0BACQ,mBAAmB;oBACzB,4BAA4B;sBAC1B,yBAAyB;;;;;UAa7B,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2DJ,aAAA,YAAyB;;wBACR;0BAEL,mBAAmB;oBAiCzB,4BAA4B;sBAe1B,yBAAyB"}
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require('../chunk-CUT6urMc.cjs');
2
- require('../types-BMiHgsi4.cjs');
3
- require('../transformer-Csl6fbgv.cjs');
4
- const require_receiver = require('../receiver-slCoAFat.cjs');
2
+ require('../types-BBeTDpHr.cjs');
3
+ require('../transformer-DvDYyFRQ.cjs');
4
+ const require_receiver = require('../receiver-BW_4go_X.cjs');
5
5
  const hono = require_chunk.__toESM(require("hono"));
6
6
 
7
7
  //#region src/otlp/hono.ts
@@ -1,6 +1,6 @@
1
- import "../types-Cj59nqy7.mjs";
2
- import "../transformer-CFQ4WFk6.mjs";
3
- import { OTLPReceiver } from "../receiver-D46dfkYI.mjs";
1
+ import "../types-CXYLhG_G.mjs";
2
+ import "../transformer-CFrJQkUg.mjs";
3
+ import { OTLPReceiver } from "../receiver-q4f7eirs.mjs";
4
4
  import { Hono } from "hono";
5
5
 
6
6
  //#region src/otlp/hono.ts
@@ -1,6 +1,6 @@
1
- const require_types = require('../types-BMiHgsi4.cjs');
2
- const require_transformer = require('../transformer-Csl6fbgv.cjs');
3
- const require_receiver = require('../receiver-slCoAFat.cjs');
1
+ const require_types = require('../types-BBeTDpHr.cjs');
2
+ const require_transformer = require('../transformer-DvDYyFRQ.cjs');
3
+ const require_receiver = require('../receiver-BW_4go_X.cjs');
4
4
 
5
5
  exports.OTLPReceiver = require_receiver.OTLPReceiver;
6
6
  exports.SeverityNumber = require_types.SeverityNumber;
@@ -1,5 +1,5 @@
1
- import { SeverityNumber, SpanKind, SpanStatusCode } from "../types-Cj59nqy7.mjs";
2
- import { transformLogs, transformMetrics, transformTraces } from "../transformer-CFQ4WFk6.mjs";
3
- import { OTLPReceiver } from "../receiver-D46dfkYI.mjs";
1
+ import { SeverityNumber, SpanKind, SpanStatusCode } from "../types-CXYLhG_G.mjs";
2
+ import { transformLogs, transformMetrics, transformTraces } from "../transformer-CFrJQkUg.mjs";
3
+ import { OTLPReceiver } from "../receiver-q4f7eirs.mjs";
4
4
 
5
5
  export { OTLPReceiver, SeverityNumber, SpanKind, SpanStatusCode, transformLogs, transformMetrics, transformTraces };
@@ -1,5 +1,5 @@
1
- require('../types-BMiHgsi4.cjs');
2
- require('../transformer-Csl6fbgv.cjs');
3
- const require_receiver = require('../receiver-slCoAFat.cjs');
1
+ require('../types-BBeTDpHr.cjs');
2
+ require('../transformer-DvDYyFRQ.cjs');
3
+ const require_receiver = require('../receiver-BW_4go_X.cjs');
4
4
 
5
5
  exports.OTLPReceiver = require_receiver.OTLPReceiver;
@@ -1,5 +1,5 @@
1
- import "../types-Cj59nqy7.mjs";
2
- import "../transformer-CFQ4WFk6.mjs";
3
- import { OTLPReceiver } from "../receiver-D46dfkYI.mjs";
1
+ import "../types-CXYLhG_G.mjs";
2
+ import "../transformer-CFrJQkUg.mjs";
3
+ import { OTLPReceiver } from "../receiver-q4f7eirs.mjs";
4
4
 
5
5
  export { OTLPReceiver };
@@ -1,5 +1,5 @@
1
- require('../types-BMiHgsi4.cjs');
2
- const require_transformer = require('../transformer-Csl6fbgv.cjs');
1
+ require('../types-BBeTDpHr.cjs');
2
+ const require_transformer = require('../transformer-DvDYyFRQ.cjs');
3
3
 
4
4
  exports.transformLogs = require_transformer.transformLogs;
5
5
  exports.transformMetrics = require_transformer.transformMetrics;
@@ -1,4 +1,4 @@
1
- import "../types-Cj59nqy7.mjs";
2
- import { transformLogs, transformMetrics, transformTraces } from "../transformer-CFQ4WFk6.mjs";
1
+ import "../types-CXYLhG_G.mjs";
2
+ import { transformLogs, transformMetrics, transformTraces } from "../transformer-CFrJQkUg.mjs";
3
3
 
4
4
  export { transformLogs, transformMetrics, transformTraces };
@@ -1,4 +1,4 @@
1
- const require_types = require('../types-BMiHgsi4.cjs');
1
+ const require_types = require('../types-BBeTDpHr.cjs');
2
2
 
3
3
  exports.AggregationTemporality = require_types.AggregationTemporality;
4
4
  exports.SeverityNumber = require_types.SeverityNumber;
@@ -1,3 +1,3 @@
1
- import { AggregationTemporality, SeverityNumber, SpanKind, SpanStatusCode } from "../types-Cj59nqy7.mjs";
1
+ import { AggregationTemporality, SeverityNumber, SpanKind, SpanStatusCode } from "../types-CXYLhG_G.mjs";
2
2
 
3
3
  export { AggregationTemporality, SeverityNumber, SpanKind, SpanStatusCode };
@@ -1,4 +1,4 @@
1
- const require_transformer = require('./transformer-Csl6fbgv.cjs');
1
+ const require_transformer = require('./transformer-DvDYyFRQ.cjs');
2
2
 
3
3
  //#region src/otlp/receiver.ts
4
4
  /**
@@ -91,4 +91,4 @@ Object.defineProperty(exports, 'OTLPReceiver', {
91
91
  return OTLPReceiver;
92
92
  }
93
93
  });
94
- //# sourceMappingURL=receiver-slCoAFat.cjs.map
94
+ //# sourceMappingURL=receiver-BW_4go_X.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"receiver-slCoAFat.cjs","names":["options: OTLPReceiverOptions","request: ExportTraceServiceRequest","request: ExportLogsServiceRequest","request: ExportMetricsServiceRequest"],"sources":["../src/otlp/receiver.ts"],"sourcesContent":["import type { Telescope } from '../Telescope';\nimport {\n\ttype MetricDataPoint,\n\ttransformLogs,\n\ttransformMetrics,\n\ttransformTraces,\n} from './transformer';\nimport type {\n\tExportLogsServiceRequest,\n\tExportLogsServiceResponse,\n\tExportMetricsServiceRequest,\n\tExportMetricsServiceResponse,\n\tExportTraceServiceRequest,\n\tExportTraceServiceResponse,\n} from './types';\n\n/**\n * Callback for handling OTLP metrics\n */\nexport type MetricsHandler = (\n\tpoints: MetricDataPoint[],\n) => void | Promise<void>;\n\n/**\n * Options for OTLPReceiver\n */\nexport interface OTLPReceiverOptions {\n\t/**\n\t * The Telescope instance to record data to\n\t */\n\ttelescope: Telescope;\n\n\t/**\n\t * Optional callback for handling OTLP metrics.\n\t * OTLP metrics are more granular than Telescope's request metrics,\n\t * so a custom handler allows integration with metrics systems like Prometheus.\n\t */\n\tonMetrics?: MetricsHandler;\n\n\t/**\n\t * Whether to also log OTLP metrics to Telescope as log entries.\n\t * Useful for debugging OTLP integration. Default: false\n\t */\n\tlogMetrics?: boolean;\n}\n\n/**\n * OTLP Receiver for ingesting OpenTelemetry data into Telescope.\n *\n * Supports the OTLP/JSON protocol for:\n * - Traces (POST /v1/traces) - HTTP server spans become RequestEntries\n * - Logs (POST /v1/logs) - Log records become LogEntries\n * - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers\n */\nexport class OTLPReceiver {\n\tprivate telescope: Telescope;\n\tprivate onMetrics?: MetricsHandler;\n\tprivate logMetrics: boolean;\n\n\tconstructor(options: OTLPReceiverOptions) {\n\t\tthis.telescope = options.telescope;\n\t\tthis.onMetrics = options.onMetrics;\n\t\tthis.logMetrics = options.logMetrics ?? false;\n\t}\n\n\t/**\n\t * Handle incoming trace data\n\t * Transforms HTTP server spans to Telescope request entries\n\t */\n\tasync receiveTraces(\n\t\trequest: ExportTraceServiceRequest,\n\t): Promise<ExportTraceServiceResponse> {\n\t\tconst entries = transformTraces(request);\n\t\tlet rejected = 0;\n\n\t\tfor (const entry of entries) {\n\t\t\ttry {\n\t\t\t\tawait this.telescope.recordRequest(entry);\n\t\t\t} catch {\n\t\t\t\trejected++;\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedSpans: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming log data\n\t * Transforms OTLP log records to Telescope log entries\n\t */\n\tasync receiveLogs(\n\t\trequest: ExportLogsServiceRequest,\n\t): Promise<ExportLogsServiceResponse> {\n\t\tconst entries = transformLogs(request);\n\t\tlet rejected = 0;\n\n\t\t// Batch log entries for efficiency\n\t\tconst batchEntries = entries.map((entry) => ({\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message,\n\t\t\tcontext: entry.context,\n\t\t\trequestId: entry.requestId,\n\t\t}));\n\n\t\ttry {\n\t\t\tawait this.telescope.log(batchEntries);\n\t\t} catch {\n\t\t\trejected = entries.length;\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedLogRecords: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming metrics data\n\t * Forwards to custom handler and optionally logs to Telescope\n\t */\n\tasync receiveMetrics(\n\t\trequest: ExportMetricsServiceRequest,\n\t): Promise<ExportMetricsServiceResponse> {\n\t\tconst points = transformMetrics(request);\n\t\tlet rejected = 0;\n\n\t\t// Forward to custom metrics handler\n\t\tif (this.onMetrics) {\n\t\t\ttry {\n\t\t\t\tawait this.onMetrics(points);\n\t\t\t} catch {\n\t\t\t\trejected = points.length;\n\t\t\t}\n\t\t}\n\n\t\t// Optionally log metrics to Telescope for debugging\n\t\tif (this.logMetrics && points.length > 0) {\n\t\t\tconst logEntries = points.map((point) => ({\n\t\t\t\tlevel: 'debug' as const,\n\t\t\t\tmessage: `OTLP Metric: ${point.name}`,\n\t\t\t\tcontext: {\n\t\t\t\t\tname: point.name,\n\t\t\t\t\tvalue: point.value,\n\t\t\t\t\ttype: point.type,\n\t\t\t\t\tunit: point.unit,\n\t\t\t\t\tattributes: point.attributes,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\ttry {\n\t\t\t\tawait this.telescope.log(logEntries);\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedDataPoints: String(rejected) } }\n\t\t\t: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KACZ,YAAY,MAAM;IAClB;GACD,GAAE;AAEH,OAAI;AACH,UAAM,KAAK,UAAU,IAAI,WAAW;GACpC,QAAO,CAEP;EACD;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;AACD"}
1
+ {"version":3,"file":"receiver-BW_4go_X.cjs","names":["options: OTLPReceiverOptions","request: ExportTraceServiceRequest","request: ExportLogsServiceRequest","request: ExportMetricsServiceRequest"],"sources":["../src/otlp/receiver.ts"],"sourcesContent":["import type { Telescope } from '../Telescope';\nimport {\n\ttype MetricDataPoint,\n\ttransformLogs,\n\ttransformMetrics,\n\ttransformTraces,\n} from './transformer';\nimport type {\n\tExportLogsServiceRequest,\n\tExportLogsServiceResponse,\n\tExportMetricsServiceRequest,\n\tExportMetricsServiceResponse,\n\tExportTraceServiceRequest,\n\tExportTraceServiceResponse,\n} from './types';\n\n/**\n * Callback for handling OTLP metrics\n */\nexport type MetricsHandler = (\n\tpoints: MetricDataPoint[],\n) => void | Promise<void>;\n\n/**\n * Options for OTLPReceiver\n */\nexport interface OTLPReceiverOptions {\n\t/**\n\t * The Telescope instance to record data to\n\t */\n\ttelescope: Telescope;\n\n\t/**\n\t * Optional callback for handling OTLP metrics.\n\t * OTLP metrics are more granular than Telescope's request metrics,\n\t * so a custom handler allows integration with metrics systems like Prometheus.\n\t */\n\tonMetrics?: MetricsHandler;\n\n\t/**\n\t * Whether to also log OTLP metrics to Telescope as log entries.\n\t * Useful for debugging OTLP integration. Default: false\n\t */\n\tlogMetrics?: boolean;\n}\n\n/**\n * OTLP Receiver for ingesting OpenTelemetry data into Telescope.\n *\n * Supports the OTLP/JSON protocol for:\n * - Traces (POST /v1/traces) - HTTP server spans become RequestEntries\n * - Logs (POST /v1/logs) - Log records become LogEntries\n * - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers\n */\nexport class OTLPReceiver {\n\tprivate telescope: Telescope;\n\tprivate onMetrics?: MetricsHandler;\n\tprivate logMetrics: boolean;\n\n\tconstructor(options: OTLPReceiverOptions) {\n\t\tthis.telescope = options.telescope;\n\t\tthis.onMetrics = options.onMetrics;\n\t\tthis.logMetrics = options.logMetrics ?? false;\n\t}\n\n\t/**\n\t * Handle incoming trace data\n\t * Transforms HTTP server spans to Telescope request entries\n\t */\n\tasync receiveTraces(\n\t\trequest: ExportTraceServiceRequest,\n\t): Promise<ExportTraceServiceResponse> {\n\t\tconst entries = transformTraces(request);\n\t\tlet rejected = 0;\n\n\t\tfor (const entry of entries) {\n\t\t\ttry {\n\t\t\t\tawait this.telescope.recordRequest(entry);\n\t\t\t} catch {\n\t\t\t\trejected++;\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedSpans: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming log data\n\t * Transforms OTLP log records to Telescope log entries\n\t */\n\tasync receiveLogs(\n\t\trequest: ExportLogsServiceRequest,\n\t): Promise<ExportLogsServiceResponse> {\n\t\tconst entries = transformLogs(request);\n\t\tlet rejected = 0;\n\n\t\t// Batch log entries for efficiency\n\t\tconst batchEntries = entries.map((entry) => ({\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message,\n\t\t\tcontext: entry.context,\n\t\t\trequestId: entry.requestId,\n\t\t}));\n\n\t\ttry {\n\t\t\tawait this.telescope.log(batchEntries);\n\t\t} catch {\n\t\t\trejected = entries.length;\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedLogRecords: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming metrics data\n\t * Forwards to custom handler and optionally logs to Telescope\n\t */\n\tasync receiveMetrics(\n\t\trequest: ExportMetricsServiceRequest,\n\t): Promise<ExportMetricsServiceResponse> {\n\t\tconst points = transformMetrics(request);\n\t\tlet rejected = 0;\n\n\t\t// Forward to custom metrics handler\n\t\tif (this.onMetrics) {\n\t\t\ttry {\n\t\t\t\tawait this.onMetrics(points);\n\t\t\t} catch {\n\t\t\t\trejected = points.length;\n\t\t\t}\n\t\t}\n\n\t\t// Optionally log metrics to Telescope for debugging\n\t\tif (this.logMetrics && points.length > 0) {\n\t\t\tconst logEntries = points.map((point) => ({\n\t\t\t\tlevel: 'debug' as const,\n\t\t\t\tmessage: `OTLP Metric: ${point.name}`,\n\t\t\t\tcontext: {\n\t\t\t\t\tname: point.name,\n\t\t\t\t\tvalue: point.value,\n\t\t\t\t\ttype: point.type,\n\t\t\t\t\tunit: point.unit,\n\t\t\t\t\tattributes: point.attributes,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\ttry {\n\t\t\t\tawait this.telescope.log(logEntries);\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedDataPoints: String(rejected) } }\n\t\t\t: {};\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAsDA,IAAa,eAAb,MAA0B;CACzB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAYA,SAA8B;AACzC,OAAK,YAAY,QAAQ;AACzB,OAAK,YAAY,QAAQ;AACzB,OAAK,aAAa,QAAQ,cAAc;CACxC;;;;;CAMD,MAAM,cACLC,SACsC;EACtC,MAAM,UAAU,oCAAgB,QAAQ;EACxC,IAAI,WAAW;AAEf,OAAK,MAAM,SAAS,QACnB,KAAI;AACH,SAAM,KAAK,UAAU,cAAc,MAAM;EACzC,QAAO;AACP;EACA;AAGF,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,eAAe,OAAO,SAAS,CAAE,EAAE,IACvD,CAAE;CACL;;;;;CAMD,MAAM,YACLC,SACqC;EACrC,MAAM,UAAU,kCAAc,QAAQ;EACtC,IAAI,WAAW;EAGf,MAAM,eAAe,QAAQ,IAAI,CAAC,WAAW;GAC5C,OAAO,MAAM;GACb,SAAS,MAAM;GACf,SAAS,MAAM;GACf,WAAW,MAAM;EACjB,GAAE;AAEH,MAAI;AACH,SAAM,KAAK,UAAU,IAAI,aAAa;EACtC,QAAO;AACP,cAAW,QAAQ;EACnB;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;;;;;CAMD,MAAM,eACLC,SACwC;EACxC,MAAM,SAAS,qCAAiB,QAAQ;EACxC,IAAI,WAAW;AAGf,MAAI,KAAK,UACR,KAAI;AACH,SAAM,KAAK,UAAU,OAAO;EAC5B,QAAO;AACP,cAAW,OAAO;EAClB;AAIF,MAAI,KAAK,cAAc,OAAO,SAAS,GAAG;GACzC,MAAM,aAAa,OAAO,IAAI,CAAC,WAAW;IACzC,OAAO;IACP,UAAU,eAAe,MAAM,KAAK;IACpC,SAAS;KACR,MAAM,MAAM;KACZ,OAAO,MAAM;KACb,MAAM,MAAM;KACZ,MAAM,MAAM;KACZ,YAAY,MAAM;IAClB;GACD,GAAE;AAEH,OAAI;AACH,UAAM,KAAK,UAAU,IAAI,WAAW;GACpC,QAAO,CAEP;EACD;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;AACD"}
@@ -1,4 +1,4 @@
1
- import { transformLogs, transformMetrics, transformTraces } from "./transformer-CFQ4WFk6.mjs";
1
+ import { transformLogs, transformMetrics, transformTraces } from "./transformer-CFrJQkUg.mjs";
2
2
 
3
3
  //#region src/otlp/receiver.ts
4
4
  /**
@@ -86,4 +86,4 @@ var OTLPReceiver = class {
86
86
 
87
87
  //#endregion
88
88
  export { OTLPReceiver };
89
- //# sourceMappingURL=receiver-D46dfkYI.mjs.map
89
+ //# sourceMappingURL=receiver-q4f7eirs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"receiver-D46dfkYI.mjs","names":["options: OTLPReceiverOptions","request: ExportTraceServiceRequest","request: ExportLogsServiceRequest","request: ExportMetricsServiceRequest"],"sources":["../src/otlp/receiver.ts"],"sourcesContent":["import type { Telescope } from '../Telescope';\nimport {\n\ttype MetricDataPoint,\n\ttransformLogs,\n\ttransformMetrics,\n\ttransformTraces,\n} from './transformer';\nimport type {\n\tExportLogsServiceRequest,\n\tExportLogsServiceResponse,\n\tExportMetricsServiceRequest,\n\tExportMetricsServiceResponse,\n\tExportTraceServiceRequest,\n\tExportTraceServiceResponse,\n} from './types';\n\n/**\n * Callback for handling OTLP metrics\n */\nexport type MetricsHandler = (\n\tpoints: MetricDataPoint[],\n) => void | Promise<void>;\n\n/**\n * Options for OTLPReceiver\n */\nexport interface OTLPReceiverOptions {\n\t/**\n\t * The Telescope instance to record data to\n\t */\n\ttelescope: Telescope;\n\n\t/**\n\t * Optional callback for handling OTLP metrics.\n\t * OTLP metrics are more granular than Telescope's request metrics,\n\t * so a custom handler allows integration with metrics systems like Prometheus.\n\t */\n\tonMetrics?: MetricsHandler;\n\n\t/**\n\t * Whether to also log OTLP metrics to Telescope as log entries.\n\t * Useful for debugging OTLP integration. Default: false\n\t */\n\tlogMetrics?: boolean;\n}\n\n/**\n * OTLP Receiver for ingesting OpenTelemetry data into Telescope.\n *\n * Supports the OTLP/JSON protocol for:\n * - Traces (POST /v1/traces) - HTTP server spans become RequestEntries\n * - Logs (POST /v1/logs) - Log records become LogEntries\n * - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers\n */\nexport class OTLPReceiver {\n\tprivate telescope: Telescope;\n\tprivate onMetrics?: MetricsHandler;\n\tprivate logMetrics: boolean;\n\n\tconstructor(options: OTLPReceiverOptions) {\n\t\tthis.telescope = options.telescope;\n\t\tthis.onMetrics = options.onMetrics;\n\t\tthis.logMetrics = options.logMetrics ?? false;\n\t}\n\n\t/**\n\t * Handle incoming trace data\n\t * Transforms HTTP server spans to Telescope request entries\n\t */\n\tasync receiveTraces(\n\t\trequest: ExportTraceServiceRequest,\n\t): Promise<ExportTraceServiceResponse> {\n\t\tconst entries = transformTraces(request);\n\t\tlet rejected = 0;\n\n\t\tfor (const entry of entries) {\n\t\t\ttry {\n\t\t\t\tawait this.telescope.recordRequest(entry);\n\t\t\t} catch {\n\t\t\t\trejected++;\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedSpans: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming log data\n\t * Transforms OTLP log records to Telescope log entries\n\t */\n\tasync receiveLogs(\n\t\trequest: ExportLogsServiceRequest,\n\t): Promise<ExportLogsServiceResponse> {\n\t\tconst entries = transformLogs(request);\n\t\tlet rejected = 0;\n\n\t\t// Batch log entries for efficiency\n\t\tconst batchEntries = entries.map((entry) => ({\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message,\n\t\t\tcontext: entry.context,\n\t\t\trequestId: entry.requestId,\n\t\t}));\n\n\t\ttry {\n\t\t\tawait this.telescope.log(batchEntries);\n\t\t} catch {\n\t\t\trejected = entries.length;\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedLogRecords: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming metrics data\n\t * Forwards to custom handler and optionally logs to Telescope\n\t */\n\tasync receiveMetrics(\n\t\trequest: ExportMetricsServiceRequest,\n\t): Promise<ExportMetricsServiceResponse> {\n\t\tconst points = transformMetrics(request);\n\t\tlet rejected = 0;\n\n\t\t// Forward to custom metrics handler\n\t\tif (this.onMetrics) {\n\t\t\ttry {\n\t\t\t\tawait this.onMetrics(points);\n\t\t\t} catch {\n\t\t\t\trejected = points.length;\n\t\t\t}\n\t\t}\n\n\t\t// Optionally log metrics to Telescope for debugging\n\t\tif (this.logMetrics && points.length > 0) {\n\t\t\tconst logEntries = points.map((point) => ({\n\t\t\t\tlevel: 'debug' as const,\n\t\t\t\tmessage: `OTLP Metric: ${point.name}`,\n\t\t\t\tcontext: {\n\t\t\t\t\tname: point.name,\n\t\t\t\t\tvalue: point.value,\n\t\t\t\t\ttype: point.type,\n\t\t\t\t\tunit: point.unit,\n\t\t\t\t\tattributes: point.attributes,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\ttry {\n\t\t\t\tawait this.telescope.log(logEntries);\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedDataPoints: String(rejected) } }\n\t\t\t: {};\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAsDA,IAAa,eAAb,MAA0B;CACzB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAYA,SAA8B;AACzC,OAAK,YAAY,QAAQ;AACzB,OAAK,YAAY,QAAQ;AACzB,OAAK,aAAa,QAAQ,cAAc;CACxC;;;;;CAMD,MAAM,cACLC,SACsC;EACtC,MAAM,UAAU,gBAAgB,QAAQ;EACxC,IAAI,WAAW;AAEf,OAAK,MAAM,SAAS,QACnB,KAAI;AACH,SAAM,KAAK,UAAU,cAAc,MAAM;EACzC,QAAO;AACP;EACA;AAGF,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,eAAe,OAAO,SAAS,CAAE,EAAE,IACvD,CAAE;CACL;;;;;CAMD,MAAM,YACLC,SACqC;EACrC,MAAM,UAAU,cAAc,QAAQ;EACtC,IAAI,WAAW;EAGf,MAAM,eAAe,QAAQ,IAAI,CAAC,WAAW;GAC5C,OAAO,MAAM;GACb,SAAS,MAAM;GACf,SAAS,MAAM;GACf,WAAW,MAAM;EACjB,GAAE;AAEH,MAAI;AACH,SAAM,KAAK,UAAU,IAAI,aAAa;EACtC,QAAO;AACP,cAAW,QAAQ;EACnB;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;;;;;CAMD,MAAM,eACLC,SACwC;EACxC,MAAM,SAAS,iBAAiB,QAAQ;EACxC,IAAI,WAAW;AAGf,MAAI,KAAK,UACR,KAAI;AACH,SAAM,KAAK,UAAU,OAAO;EAC5B,QAAO;AACP,cAAW,OAAO;EAClB;AAIF,MAAI,KAAK,cAAc,OAAO,SAAS,GAAG;GACzC,MAAM,aAAa,OAAO,IAAI,CAAC,WAAW;IACzC,OAAO;IACP,UAAU,eAAe,MAAM,KAAK;IACpC,SAAS;KACR,MAAM,MAAM;KACZ,OAAO,MAAM;KACb,MAAM,MAAM;KACZ,MAAM,MAAM;KACZ,YAAY,MAAM;IAClB;GACD,GAAE;AAEH,OAAI;AACH,UAAM,KAAK,UAAU,IAAI,WAAW;GACpC,QAAO,CAEP;EACD;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;AACD"}
1
+ {"version":3,"file":"receiver-q4f7eirs.mjs","names":["options: OTLPReceiverOptions","request: ExportTraceServiceRequest","request: ExportLogsServiceRequest","request: ExportMetricsServiceRequest"],"sources":["../src/otlp/receiver.ts"],"sourcesContent":["import type { Telescope } from '../Telescope';\nimport {\n\ttype MetricDataPoint,\n\ttransformLogs,\n\ttransformMetrics,\n\ttransformTraces,\n} from './transformer';\nimport type {\n\tExportLogsServiceRequest,\n\tExportLogsServiceResponse,\n\tExportMetricsServiceRequest,\n\tExportMetricsServiceResponse,\n\tExportTraceServiceRequest,\n\tExportTraceServiceResponse,\n} from './types';\n\n/**\n * Callback for handling OTLP metrics\n */\nexport type MetricsHandler = (\n\tpoints: MetricDataPoint[],\n) => void | Promise<void>;\n\n/**\n * Options for OTLPReceiver\n */\nexport interface OTLPReceiverOptions {\n\t/**\n\t * The Telescope instance to record data to\n\t */\n\ttelescope: Telescope;\n\n\t/**\n\t * Optional callback for handling OTLP metrics.\n\t * OTLP metrics are more granular than Telescope's request metrics,\n\t * so a custom handler allows integration with metrics systems like Prometheus.\n\t */\n\tonMetrics?: MetricsHandler;\n\n\t/**\n\t * Whether to also log OTLP metrics to Telescope as log entries.\n\t * Useful for debugging OTLP integration. Default: false\n\t */\n\tlogMetrics?: boolean;\n}\n\n/**\n * OTLP Receiver for ingesting OpenTelemetry data into Telescope.\n *\n * Supports the OTLP/JSON protocol for:\n * - Traces (POST /v1/traces) - HTTP server spans become RequestEntries\n * - Logs (POST /v1/logs) - Log records become LogEntries\n * - Metrics (POST /v1/metrics) - Metrics can be forwarded to custom handlers\n */\nexport class OTLPReceiver {\n\tprivate telescope: Telescope;\n\tprivate onMetrics?: MetricsHandler;\n\tprivate logMetrics: boolean;\n\n\tconstructor(options: OTLPReceiverOptions) {\n\t\tthis.telescope = options.telescope;\n\t\tthis.onMetrics = options.onMetrics;\n\t\tthis.logMetrics = options.logMetrics ?? false;\n\t}\n\n\t/**\n\t * Handle incoming trace data\n\t * Transforms HTTP server spans to Telescope request entries\n\t */\n\tasync receiveTraces(\n\t\trequest: ExportTraceServiceRequest,\n\t): Promise<ExportTraceServiceResponse> {\n\t\tconst entries = transformTraces(request);\n\t\tlet rejected = 0;\n\n\t\tfor (const entry of entries) {\n\t\t\ttry {\n\t\t\t\tawait this.telescope.recordRequest(entry);\n\t\t\t} catch {\n\t\t\t\trejected++;\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedSpans: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming log data\n\t * Transforms OTLP log records to Telescope log entries\n\t */\n\tasync receiveLogs(\n\t\trequest: ExportLogsServiceRequest,\n\t): Promise<ExportLogsServiceResponse> {\n\t\tconst entries = transformLogs(request);\n\t\tlet rejected = 0;\n\n\t\t// Batch log entries for efficiency\n\t\tconst batchEntries = entries.map((entry) => ({\n\t\t\tlevel: entry.level,\n\t\t\tmessage: entry.message,\n\t\t\tcontext: entry.context,\n\t\t\trequestId: entry.requestId,\n\t\t}));\n\n\t\ttry {\n\t\t\tawait this.telescope.log(batchEntries);\n\t\t} catch {\n\t\t\trejected = entries.length;\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedLogRecords: String(rejected) } }\n\t\t\t: {};\n\t}\n\n\t/**\n\t * Handle incoming metrics data\n\t * Forwards to custom handler and optionally logs to Telescope\n\t */\n\tasync receiveMetrics(\n\t\trequest: ExportMetricsServiceRequest,\n\t): Promise<ExportMetricsServiceResponse> {\n\t\tconst points = transformMetrics(request);\n\t\tlet rejected = 0;\n\n\t\t// Forward to custom metrics handler\n\t\tif (this.onMetrics) {\n\t\t\ttry {\n\t\t\t\tawait this.onMetrics(points);\n\t\t\t} catch {\n\t\t\t\trejected = points.length;\n\t\t\t}\n\t\t}\n\n\t\t// Optionally log metrics to Telescope for debugging\n\t\tif (this.logMetrics && points.length > 0) {\n\t\t\tconst logEntries = points.map((point) => ({\n\t\t\t\tlevel: 'debug' as const,\n\t\t\t\tmessage: `OTLP Metric: ${point.name}`,\n\t\t\t\tcontext: {\n\t\t\t\t\tname: point.name,\n\t\t\t\t\tvalue: point.value,\n\t\t\t\t\ttype: point.type,\n\t\t\t\t\tunit: point.unit,\n\t\t\t\t\tattributes: point.attributes,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\ttry {\n\t\t\t\tawait this.telescope.log(logEntries);\n\t\t\t} catch {\n\t\t\t\t// Ignore logging errors\n\t\t\t}\n\t\t}\n\n\t\treturn rejected > 0\n\t\t\t? { partialSuccess: { rejectedDataPoints: String(rejected) } }\n\t\t\t: {};\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAsDA,IAAa,eAAb,MAA0B;CACzB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAYA,SAA8B;AACzC,OAAK,YAAY,QAAQ;AACzB,OAAK,YAAY,QAAQ;AACzB,OAAK,aAAa,QAAQ,cAAc;CACxC;;;;;CAMD,MAAM,cACLC,SACsC;EACtC,MAAM,UAAU,gBAAgB,QAAQ;EACxC,IAAI,WAAW;AAEf,OAAK,MAAM,SAAS,QACnB,KAAI;AACH,SAAM,KAAK,UAAU,cAAc,MAAM;EACzC,QAAO;AACP;EACA;AAGF,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,eAAe,OAAO,SAAS,CAAE,EAAE,IACvD,CAAE;CACL;;;;;CAMD,MAAM,YACLC,SACqC;EACrC,MAAM,UAAU,cAAc,QAAQ;EACtC,IAAI,WAAW;EAGf,MAAM,eAAe,QAAQ,IAAI,CAAC,WAAW;GAC5C,OAAO,MAAM;GACb,SAAS,MAAM;GACf,SAAS,MAAM;GACf,WAAW,MAAM;EACjB,GAAE;AAEH,MAAI;AACH,SAAM,KAAK,UAAU,IAAI,aAAa;EACtC,QAAO;AACP,cAAW,QAAQ;EACnB;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;;;;;CAMD,MAAM,eACLC,SACwC;EACxC,MAAM,SAAS,iBAAiB,QAAQ;EACxC,IAAI,WAAW;AAGf,MAAI,KAAK,UACR,KAAI;AACH,SAAM,KAAK,UAAU,OAAO;EAC5B,QAAO;AACP,cAAW,OAAO;EAClB;AAIF,MAAI,KAAK,cAAc,OAAO,SAAS,GAAG;GACzC,MAAM,aAAa,OAAO,IAAI,CAAC,WAAW;IACzC,OAAO;IACP,UAAU,eAAe,MAAM,KAAK;IACpC,SAAS;KACR,MAAM,MAAM;KACZ,OAAO,MAAM;KACb,MAAM,MAAM;KACZ,MAAM,MAAM;KACZ,YAAY,MAAM;IAClB;GACD,GAAE;AAEH,OAAI;AACH,UAAM,KAAK,UAAU,IAAI,WAAW;GACpC,QAAO,CAEP;EACD;AAED,SAAO,WAAW,IACf,EAAE,gBAAgB,EAAE,oBAAoB,OAAO,SAAS,CAAE,EAAE,IAC5D,CAAE;CACL;AACD"}
@@ -95,4 +95,4 @@ async function shutdownTelemetry() {
95
95
 
96
96
  //#endregion
97
97
  export { setupTelemetry, shutdownTelemetry };
98
- //# sourceMappingURL=setup-DC9JMEYZ.mjs.map
98
+ //# sourceMappingURL=setup-BhCp2LUp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-DC9JMEYZ.mjs","names":["sdk: NodeSDK | null","options: TelemetryOptions","traceExporter: SpanExporter"],"sources":["../src/instrumentation/setup.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n\tConsoleSpanExporter,\n\ttype SpanExporter,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanProcessorStrategy } from '../adapters/types';\nimport {\n\tcreateSpanProcessor,\n\tgetRecommendedStrategy,\n\tsetGlobalLogProcessor,\n\tsetGlobalSpanProcessor,\n} from './core';\n\n/**\n * Options for configuring telemetry\n */\nexport interface TelemetryOptions {\n\t/**\n\t * Service name for resource identification\n\t */\n\tserviceName: string;\n\n\t/**\n\t * Service version\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL (e.g., 'http://localhost:3000/__telescope/v1')\n\t * If not provided, traces will be logged to console\n\t */\n\tendpoint?: string;\n\n\t/**\n\t * Whether to instrument Pino for log correlation\n\t * @default true\n\t */\n\tinstrumentPino?: boolean;\n\n\t/**\n\t * Whether to enable auto-instrumentation for common libraries\n\t * (http, fetch, express, etc.)\n\t * @default true\n\t */\n\tautoInstrument?: boolean;\n\n\t/**\n\t * Enable debug logging for OTel SDK\n\t * @default false\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Additional resource attributes\n\t */\n\tresourceAttributes?: Record<string, string>;\n\n\t/**\n\t * Headers to send with OTLP requests\n\t */\n\theaders?: Record<string, string>;\n\n\t/**\n\t * Span processor strategy.\n\t * - 'batch': Efficient batching for long-running servers (default)\n\t * - 'simple': Immediate export for serverless environments (Lambda, Edge)\n\t *\n\t * If not specified, automatically selected based on environment detection.\n\t */\n\tspanProcessorStrategy?: SpanProcessorStrategy;\n\n\t/**\n\t * Environment type for automatic configuration\n\t * @default 'server'\n\t */\n\tenvironment?: 'server' | 'lambda' | 'edge' | 'custom';\n}\n\nlet sdk: NodeSDK | null = null;\n\n/**\n * Set up OpenTelemetry instrumentation.\n * Call this BEFORE importing your application code.\n *\n * @example\n * ```typescript\n * // instrumentation.ts (create this file)\n * import { setupTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * setupTelemetry({\n * serviceName: 'my-api',\n * endpoint: 'http://localhost:3000/__telescope/v1',\n * });\n *\n * // Then in your entry point:\n * // import './instrumentation';\n * // import { app } from './app';\n * ```\n */\nexport function setupTelemetry(options: TelemetryOptions): void {\n\tif (sdk) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tserviceName,\n\t\tserviceVersion = '1.0.0',\n\t\tendpoint,\n\t\tinstrumentPino = true,\n\t\tautoInstrument = true,\n\t\tdebug = false,\n\t\tresourceAttributes = {},\n\t\theaders = {},\n\t\tspanProcessorStrategy,\n\t\tenvironment = 'server',\n\t} = options;\n\n\t// Enable debug logging if requested\n\tif (debug) {\n\t\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n\t}\n\n\t// Create resource\n\tconst resource = new Resource({\n\t\t[ATTR_SERVICE_NAME]: serviceName,\n\t\t[ATTR_SERVICE_VERSION]: serviceVersion,\n\t\t...resourceAttributes,\n\t});\n\n\t// Build instrumentations list\n\tconst instrumentations = [];\n\n\t// Add Pino instrumentation for log correlation\n\tif (instrumentPino) {\n\t\tinstrumentations.push(\n\t\t\tnew PinoInstrumentation({\n\t\t\t\t// Inject trace context into log records\n\t\t\t\tlogHook: (span, record) => {\n\t\t\t\t\trecord.trace_id = span.spanContext().traceId;\n\t\t\t\t\trecord.span_id = span.spanContext().spanId;\n\t\t\t\t\trecord.trace_flags = span.spanContext().traceFlags;\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Add auto-instrumentations for common libraries\n\tif (autoInstrument) {\n\t\tinstrumentations.push(\n\t\t\tgetNodeAutoInstrumentations({\n\t\t\t\t// Disable file system instrumentation (too noisy)\n\t\t\t\t'@opentelemetry/instrumentation-fs': { enabled: false },\n\t\t\t\t// Configure HTTP instrumentation\n\t\t\t\t'@opentelemetry/instrumentation-http': {\n\t\t\t\t\tignoreIncomingRequestHook: (request) => {\n\t\t\t\t\t\t// Ignore health checks and internal routes\n\t\t\t\t\t\tconst path = request.url || '';\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tpath.includes('/__health') ||\n\t\t\t\t\t\t\tpath.includes('/__telescope') ||\n\t\t\t\t\t\t\tpath.includes('/favicon')\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Create exporters\n\tlet traceExporter: SpanExporter;\n\tif (endpoint) {\n\t\ttraceExporter = new OTLPTraceExporter({\n\t\t\turl: `${endpoint}/traces`,\n\t\t\theaders,\n\t\t});\n\t} else {\n\t\t// Fall back to console exporter for debugging\n\t\ttraceExporter = new ConsoleSpanExporter();\n\t}\n\n\t// Determine span processor strategy\n\tconst strategy = spanProcessorStrategy ?? getRecommendedStrategy(environment);\n\tconst spanProcessor = createSpanProcessor(traceExporter, { strategy });\n\n\t// Register globally for flush operations\n\tsetGlobalSpanProcessor(spanProcessor);\n\n\t// Create and configure SDK\n\tsdk = new NodeSDK({\n\t\tresource,\n\t\ttraceExporter,\n\t\tspanProcessors: [spanProcessor],\n\t\tinstrumentations,\n\t});\n\n\t// Set up log exporter if endpoint is provided\n\tif (endpoint) {\n\t\tconst logExporter = new OTLPLogExporter({\n\t\t\turl: `${endpoint}/logs`,\n\t\t\theaders,\n\t\t});\n\n\t\tconst loggerProvider = new LoggerProvider({ resource });\n\t\tconst logProcessor = new BatchLogRecordProcessor(logExporter);\n\t\tloggerProvider.addLogRecordProcessor(logProcessor);\n\n\t\t// Register for flush operations\n\t\tsetGlobalLogProcessor(logProcessor);\n\t}\n\n\t// Start the SDK\n\tsdk.start();\n\n\t// Graceful shutdown\n\tprocess.on('SIGTERM', () => {\n\t\tsdk\n\t\t\t?.shutdown()\n\t\t\t.then(() => {})\n\t\t\t.catch((_error) => {})\n\t\t\t.finally(() => process.exit(0));\n\t});\n}\n\n/**\n * Shut down telemetry (for testing or graceful shutdown)\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tif (sdk) {\n\t\tawait sdk.shutdown();\n\t\tsdk = null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA4FA,IAAIA,MAAsB;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgB,eAAeC,SAAiC;AAC/D,KAAI,IACH;CAGD,MAAM,EACL,aACA,iBAAiB,SACjB,UACA,iBAAiB,MACjB,iBAAiB,MACjB,QAAQ,OACR,qBAAqB,CAAE,GACvB,UAAU,CAAE,GACZ,uBACA,cAAc,UACd,GAAG;AAGJ,KAAI,MACH,MAAK,UAAU,IAAI,qBAAqB,aAAa,MAAM;CAI5D,MAAM,WAAW,IAAI,SAAS;GAC5B,oBAAoB;GACpB,uBAAuB;EACxB,GAAG;CACH;CAGD,MAAM,mBAAmB,CAAE;AAG3B,KAAI,eACH,kBAAiB,KAChB,IAAI,oBAAoB,EAEvB,SAAS,CAAC,MAAM,WAAW;AAC1B,SAAO,WAAW,KAAK,aAAa,CAAC;AACrC,SAAO,UAAU,KAAK,aAAa,CAAC;AACpC,SAAO,cAAc,KAAK,aAAa,CAAC;CACxC,EACD,GACD;AAIF,KAAI,eACH,kBAAiB,KAChB,4BAA4B;EAE3B,qCAAqC,EAAE,SAAS,MAAO;EAEvD,uCAAuC,EACtC,2BAA2B,CAAC,YAAY;GAEvC,MAAM,OAAO,QAAQ,OAAO;AAC5B,UACC,KAAK,SAAS,YAAY,IAC1B,KAAK,SAAS,eAAe,IAC7B,KAAK,SAAS,WAAW;EAE1B,EACD;CACD,EAAC,CACF;CAIF,IAAIC;AACJ,KAAI,SACH,iBAAgB,IAAI,kBAAkB;EACrC,MAAM,EAAE,SAAS;EACjB;CACA;KAGD,iBAAgB,IAAI;CAIrB,MAAM,WAAW,yBAAyB,uBAAuB,YAAY;CAC7E,MAAM,gBAAgB,oBAAoB,eAAe,EAAE,SAAU,EAAC;AAGtE,wBAAuB,cAAc;AAGrC,OAAM,IAAI,QAAQ;EACjB;EACA;EACA,gBAAgB,CAAC,aAAc;EAC/B;CACA;AAGD,KAAI,UAAU;EACb,MAAM,cAAc,IAAI,gBAAgB;GACvC,MAAM,EAAE,SAAS;GACjB;EACA;EAED,MAAM,iBAAiB,IAAI,eAAe,EAAE,SAAU;EACtD,MAAM,eAAe,IAAI,wBAAwB;AACjD,iBAAe,sBAAsB,aAAa;AAGlD,wBAAsB,aAAa;CACnC;AAGD,KAAI,OAAO;AAGX,SAAQ,GAAG,WAAW,MAAM;AAC3B,OACG,UAAU,CACX,KAAK,MAAM,CAAE,EAAC,CACd,MAAM,CAAC,WAAW,CAAE,EAAC,CACrB,QAAQ,MAAM,QAAQ,KAAK,EAAE,CAAC;CAChC,EAAC;AACF;;;;AAKD,eAAsB,oBAAmC;AACxD,KAAI,KAAK;AACR,QAAM,IAAI,UAAU;AACpB,QAAM;CACN;AACD"}
1
+ {"version":3,"file":"setup-BhCp2LUp.mjs","names":["sdk: NodeSDK | null","options: TelemetryOptions","traceExporter: SpanExporter"],"sources":["../src/instrumentation/setup.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n\tConsoleSpanExporter,\n\ttype SpanExporter,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanProcessorStrategy } from '../adapters/types';\nimport {\n\tcreateSpanProcessor,\n\tgetRecommendedStrategy,\n\tsetGlobalLogProcessor,\n\tsetGlobalSpanProcessor,\n} from './core';\n\n/**\n * Options for configuring telemetry\n */\nexport interface TelemetryOptions {\n\t/**\n\t * Service name for resource identification\n\t */\n\tserviceName: string;\n\n\t/**\n\t * Service version\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL (e.g., 'http://localhost:3000/__telescope/v1')\n\t * If not provided, traces will be logged to console\n\t */\n\tendpoint?: string;\n\n\t/**\n\t * Whether to instrument Pino for log correlation\n\t * @default true\n\t */\n\tinstrumentPino?: boolean;\n\n\t/**\n\t * Whether to enable auto-instrumentation for common libraries\n\t * (http, fetch, express, etc.)\n\t * @default true\n\t */\n\tautoInstrument?: boolean;\n\n\t/**\n\t * Enable debug logging for OTel SDK\n\t * @default false\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Additional resource attributes\n\t */\n\tresourceAttributes?: Record<string, string>;\n\n\t/**\n\t * Headers to send with OTLP requests\n\t */\n\theaders?: Record<string, string>;\n\n\t/**\n\t * Span processor strategy.\n\t * - 'batch': Efficient batching for long-running servers (default)\n\t * - 'simple': Immediate export for serverless environments (Lambda, Edge)\n\t *\n\t * If not specified, automatically selected based on environment detection.\n\t */\n\tspanProcessorStrategy?: SpanProcessorStrategy;\n\n\t/**\n\t * Environment type for automatic configuration\n\t * @default 'server'\n\t */\n\tenvironment?: 'server' | 'lambda' | 'edge' | 'custom';\n}\n\nlet sdk: NodeSDK | null = null;\n\n/**\n * Set up OpenTelemetry instrumentation.\n * Call this BEFORE importing your application code.\n *\n * @example\n * ```typescript\n * // instrumentation.ts (create this file)\n * import { setupTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * setupTelemetry({\n * serviceName: 'my-api',\n * endpoint: 'http://localhost:3000/__telescope/v1',\n * });\n *\n * // Then in your entry point:\n * // import './instrumentation';\n * // import { app } from './app';\n * ```\n */\nexport function setupTelemetry(options: TelemetryOptions): void {\n\tif (sdk) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tserviceName,\n\t\tserviceVersion = '1.0.0',\n\t\tendpoint,\n\t\tinstrumentPino = true,\n\t\tautoInstrument = true,\n\t\tdebug = false,\n\t\tresourceAttributes = {},\n\t\theaders = {},\n\t\tspanProcessorStrategy,\n\t\tenvironment = 'server',\n\t} = options;\n\n\t// Enable debug logging if requested\n\tif (debug) {\n\t\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n\t}\n\n\t// Create resource\n\tconst resource = new Resource({\n\t\t[ATTR_SERVICE_NAME]: serviceName,\n\t\t[ATTR_SERVICE_VERSION]: serviceVersion,\n\t\t...resourceAttributes,\n\t});\n\n\t// Build instrumentations list\n\tconst instrumentations = [];\n\n\t// Add Pino instrumentation for log correlation\n\tif (instrumentPino) {\n\t\tinstrumentations.push(\n\t\t\tnew PinoInstrumentation({\n\t\t\t\t// Inject trace context into log records\n\t\t\t\tlogHook: (span, record) => {\n\t\t\t\t\trecord.trace_id = span.spanContext().traceId;\n\t\t\t\t\trecord.span_id = span.spanContext().spanId;\n\t\t\t\t\trecord.trace_flags = span.spanContext().traceFlags;\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Add auto-instrumentations for common libraries\n\tif (autoInstrument) {\n\t\tinstrumentations.push(\n\t\t\tgetNodeAutoInstrumentations({\n\t\t\t\t// Disable file system instrumentation (too noisy)\n\t\t\t\t'@opentelemetry/instrumentation-fs': { enabled: false },\n\t\t\t\t// Configure HTTP instrumentation\n\t\t\t\t'@opentelemetry/instrumentation-http': {\n\t\t\t\t\tignoreIncomingRequestHook: (request) => {\n\t\t\t\t\t\t// Ignore health checks and internal routes\n\t\t\t\t\t\tconst path = request.url || '';\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tpath.includes('/__health') ||\n\t\t\t\t\t\t\tpath.includes('/__telescope') ||\n\t\t\t\t\t\t\tpath.includes('/favicon')\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Create exporters\n\tlet traceExporter: SpanExporter;\n\tif (endpoint) {\n\t\ttraceExporter = new OTLPTraceExporter({\n\t\t\turl: `${endpoint}/traces`,\n\t\t\theaders,\n\t\t});\n\t} else {\n\t\t// Fall back to console exporter for debugging\n\t\ttraceExporter = new ConsoleSpanExporter();\n\t}\n\n\t// Determine span processor strategy\n\tconst strategy = spanProcessorStrategy ?? getRecommendedStrategy(environment);\n\tconst spanProcessor = createSpanProcessor(traceExporter, { strategy });\n\n\t// Register globally for flush operations\n\tsetGlobalSpanProcessor(spanProcessor);\n\n\t// Create and configure SDK\n\tsdk = new NodeSDK({\n\t\tresource,\n\t\ttraceExporter,\n\t\tspanProcessors: [spanProcessor],\n\t\tinstrumentations,\n\t});\n\n\t// Set up log exporter if endpoint is provided\n\tif (endpoint) {\n\t\tconst logExporter = new OTLPLogExporter({\n\t\t\turl: `${endpoint}/logs`,\n\t\t\theaders,\n\t\t});\n\n\t\tconst loggerProvider = new LoggerProvider({ resource });\n\t\tconst logProcessor = new BatchLogRecordProcessor(logExporter);\n\t\tloggerProvider.addLogRecordProcessor(logProcessor);\n\n\t\t// Register for flush operations\n\t\tsetGlobalLogProcessor(logProcessor);\n\t}\n\n\t// Start the SDK\n\tsdk.start();\n\n\t// Graceful shutdown\n\tprocess.on('SIGTERM', () => {\n\t\tsdk\n\t\t\t?.shutdown()\n\t\t\t.then(() => {})\n\t\t\t.catch((_error) => {})\n\t\t\t.finally(() => process.exit(0));\n\t});\n}\n\n/**\n * Shut down telemetry (for testing or graceful shutdown)\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tif (sdk) {\n\t\tawait sdk.shutdown();\n\t\tsdk = null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA4FA,IAAIA,MAAsB;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgB,eAAeC,SAAiC;AAC/D,KAAI,IACH;CAGD,MAAM,EACL,aACA,iBAAiB,SACjB,UACA,iBAAiB,MACjB,iBAAiB,MACjB,QAAQ,OACR,qBAAqB,CAAE,GACvB,UAAU,CAAE,GACZ,uBACA,cAAc,UACd,GAAG;AAGJ,KAAI,MACH,MAAK,UAAU,IAAI,qBAAqB,aAAa,MAAM;CAI5D,MAAM,WAAW,IAAI,SAAS;GAC5B,oBAAoB;GACpB,uBAAuB;EACxB,GAAG;CACH;CAGD,MAAM,mBAAmB,CAAE;AAG3B,KAAI,eACH,kBAAiB,KAChB,IAAI,oBAAoB,EAEvB,SAAS,CAAC,MAAM,WAAW;AAC1B,SAAO,WAAW,KAAK,aAAa,CAAC;AACrC,SAAO,UAAU,KAAK,aAAa,CAAC;AACpC,SAAO,cAAc,KAAK,aAAa,CAAC;CACxC,EACD,GACD;AAIF,KAAI,eACH,kBAAiB,KAChB,4BAA4B;EAE3B,qCAAqC,EAAE,SAAS,MAAO;EAEvD,uCAAuC,EACtC,2BAA2B,CAAC,YAAY;GAEvC,MAAM,OAAO,QAAQ,OAAO;AAC5B,UACC,KAAK,SAAS,YAAY,IAC1B,KAAK,SAAS,eAAe,IAC7B,KAAK,SAAS,WAAW;EAE1B,EACD;CACD,EAAC,CACF;CAIF,IAAIC;AACJ,KAAI,SACH,iBAAgB,IAAI,kBAAkB;EACrC,MAAM,EAAE,SAAS;EACjB;CACA;KAGD,iBAAgB,IAAI;CAIrB,MAAM,WAAW,yBAAyB,uBAAuB,YAAY;CAC7E,MAAM,gBAAgB,oBAAoB,eAAe,EAAE,SAAU,EAAC;AAGtE,wBAAuB,cAAc;AAGrC,OAAM,IAAI,QAAQ;EACjB;EACA;EACA,gBAAgB,CAAC,aAAc;EAC/B;CACA;AAGD,KAAI,UAAU;EACb,MAAM,cAAc,IAAI,gBAAgB;GACvC,MAAM,EAAE,SAAS;GACjB;EACA;EAED,MAAM,iBAAiB,IAAI,eAAe,EAAE,SAAU;EACtD,MAAM,eAAe,IAAI,wBAAwB;AACjD,iBAAe,sBAAsB,aAAa;AAGlD,wBAAsB,aAAa;CACnC;AAGD,KAAI,OAAO;AAGX,SAAQ,GAAG,WAAW,MAAM;AAC3B,OACG,UAAU,CACX,KAAK,MAAM,CAAE,EAAC,CACd,MAAM,CAAC,WAAW,CAAE,EAAC,CACrB,QAAQ,MAAM,QAAQ,KAAK,EAAE,CAAC;CAChC,EAAC;AACF;;;;AAKD,eAAsB,oBAAmC;AACxD,KAAI,KAAK;AACR,QAAM,IAAI,UAAU;AACpB,QAAM;CACN;AACD"}
@@ -107,4 +107,4 @@ Object.defineProperty(exports, 'shutdownTelemetry', {
107
107
  return shutdownTelemetry;
108
108
  }
109
109
  });
110
- //# sourceMappingURL=setup-DufxQpi9.cjs.map
110
+ //# sourceMappingURL=setup-_uT4L_x5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-DufxQpi9.cjs","names":["sdk: NodeSDK | null","options: TelemetryOptions","DiagConsoleLogger","DiagLogLevel","Resource","ATTR_SERVICE_NAME","ATTR_SERVICE_VERSION","PinoInstrumentation","traceExporter: SpanExporter","OTLPTraceExporter","ConsoleSpanExporter","NodeSDK","OTLPLogExporter","LoggerProvider","BatchLogRecordProcessor"],"sources":["../src/instrumentation/setup.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n\tConsoleSpanExporter,\n\ttype SpanExporter,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanProcessorStrategy } from '../adapters/types';\nimport {\n\tcreateSpanProcessor,\n\tgetRecommendedStrategy,\n\tsetGlobalLogProcessor,\n\tsetGlobalSpanProcessor,\n} from './core';\n\n/**\n * Options for configuring telemetry\n */\nexport interface TelemetryOptions {\n\t/**\n\t * Service name for resource identification\n\t */\n\tserviceName: string;\n\n\t/**\n\t * Service version\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL (e.g., 'http://localhost:3000/__telescope/v1')\n\t * If not provided, traces will be logged to console\n\t */\n\tendpoint?: string;\n\n\t/**\n\t * Whether to instrument Pino for log correlation\n\t * @default true\n\t */\n\tinstrumentPino?: boolean;\n\n\t/**\n\t * Whether to enable auto-instrumentation for common libraries\n\t * (http, fetch, express, etc.)\n\t * @default true\n\t */\n\tautoInstrument?: boolean;\n\n\t/**\n\t * Enable debug logging for OTel SDK\n\t * @default false\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Additional resource attributes\n\t */\n\tresourceAttributes?: Record<string, string>;\n\n\t/**\n\t * Headers to send with OTLP requests\n\t */\n\theaders?: Record<string, string>;\n\n\t/**\n\t * Span processor strategy.\n\t * - 'batch': Efficient batching for long-running servers (default)\n\t * - 'simple': Immediate export for serverless environments (Lambda, Edge)\n\t *\n\t * If not specified, automatically selected based on environment detection.\n\t */\n\tspanProcessorStrategy?: SpanProcessorStrategy;\n\n\t/**\n\t * Environment type for automatic configuration\n\t * @default 'server'\n\t */\n\tenvironment?: 'server' | 'lambda' | 'edge' | 'custom';\n}\n\nlet sdk: NodeSDK | null = null;\n\n/**\n * Set up OpenTelemetry instrumentation.\n * Call this BEFORE importing your application code.\n *\n * @example\n * ```typescript\n * // instrumentation.ts (create this file)\n * import { setupTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * setupTelemetry({\n * serviceName: 'my-api',\n * endpoint: 'http://localhost:3000/__telescope/v1',\n * });\n *\n * // Then in your entry point:\n * // import './instrumentation';\n * // import { app } from './app';\n * ```\n */\nexport function setupTelemetry(options: TelemetryOptions): void {\n\tif (sdk) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tserviceName,\n\t\tserviceVersion = '1.0.0',\n\t\tendpoint,\n\t\tinstrumentPino = true,\n\t\tautoInstrument = true,\n\t\tdebug = false,\n\t\tresourceAttributes = {},\n\t\theaders = {},\n\t\tspanProcessorStrategy,\n\t\tenvironment = 'server',\n\t} = options;\n\n\t// Enable debug logging if requested\n\tif (debug) {\n\t\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n\t}\n\n\t// Create resource\n\tconst resource = new Resource({\n\t\t[ATTR_SERVICE_NAME]: serviceName,\n\t\t[ATTR_SERVICE_VERSION]: serviceVersion,\n\t\t...resourceAttributes,\n\t});\n\n\t// Build instrumentations list\n\tconst instrumentations = [];\n\n\t// Add Pino instrumentation for log correlation\n\tif (instrumentPino) {\n\t\tinstrumentations.push(\n\t\t\tnew PinoInstrumentation({\n\t\t\t\t// Inject trace context into log records\n\t\t\t\tlogHook: (span, record) => {\n\t\t\t\t\trecord.trace_id = span.spanContext().traceId;\n\t\t\t\t\trecord.span_id = span.spanContext().spanId;\n\t\t\t\t\trecord.trace_flags = span.spanContext().traceFlags;\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Add auto-instrumentations for common libraries\n\tif (autoInstrument) {\n\t\tinstrumentations.push(\n\t\t\tgetNodeAutoInstrumentations({\n\t\t\t\t// Disable file system instrumentation (too noisy)\n\t\t\t\t'@opentelemetry/instrumentation-fs': { enabled: false },\n\t\t\t\t// Configure HTTP instrumentation\n\t\t\t\t'@opentelemetry/instrumentation-http': {\n\t\t\t\t\tignoreIncomingRequestHook: (request) => {\n\t\t\t\t\t\t// Ignore health checks and internal routes\n\t\t\t\t\t\tconst path = request.url || '';\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tpath.includes('/__health') ||\n\t\t\t\t\t\t\tpath.includes('/__telescope') ||\n\t\t\t\t\t\t\tpath.includes('/favicon')\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Create exporters\n\tlet traceExporter: SpanExporter;\n\tif (endpoint) {\n\t\ttraceExporter = new OTLPTraceExporter({\n\t\t\turl: `${endpoint}/traces`,\n\t\t\theaders,\n\t\t});\n\t} else {\n\t\t// Fall back to console exporter for debugging\n\t\ttraceExporter = new ConsoleSpanExporter();\n\t}\n\n\t// Determine span processor strategy\n\tconst strategy = spanProcessorStrategy ?? getRecommendedStrategy(environment);\n\tconst spanProcessor = createSpanProcessor(traceExporter, { strategy });\n\n\t// Register globally for flush operations\n\tsetGlobalSpanProcessor(spanProcessor);\n\n\t// Create and configure SDK\n\tsdk = new NodeSDK({\n\t\tresource,\n\t\ttraceExporter,\n\t\tspanProcessors: [spanProcessor],\n\t\tinstrumentations,\n\t});\n\n\t// Set up log exporter if endpoint is provided\n\tif (endpoint) {\n\t\tconst logExporter = new OTLPLogExporter({\n\t\t\turl: `${endpoint}/logs`,\n\t\t\theaders,\n\t\t});\n\n\t\tconst loggerProvider = new LoggerProvider({ resource });\n\t\tconst logProcessor = new BatchLogRecordProcessor(logExporter);\n\t\tloggerProvider.addLogRecordProcessor(logProcessor);\n\n\t\t// Register for flush operations\n\t\tsetGlobalLogProcessor(logProcessor);\n\t}\n\n\t// Start the SDK\n\tsdk.start();\n\n\t// Graceful shutdown\n\tprocess.on('SIGTERM', () => {\n\t\tsdk\n\t\t\t?.shutdown()\n\t\t\t.then(() => {})\n\t\t\t.catch((_error) => {})\n\t\t\t.finally(() => process.exit(0));\n\t});\n}\n\n/**\n * Shut down telemetry (for testing or graceful shutdown)\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tif (sdk) {\n\t\tawait sdk.shutdown();\n\t\tsdk = null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4FA,IAAIA,MAAsB;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgB,eAAeC,SAAiC;AAC/D,KAAI,IACH;CAGD,MAAM,EACL,aACA,iBAAiB,SACjB,UACA,iBAAiB,MACjB,iBAAiB,MACjB,QAAQ,OACR,qBAAqB,CAAE,GACvB,UAAU,CAAE,GACZ,uBACA,cAAc,UACd,GAAG;AAGJ,KAAI,MACH,0BAAK,UAAU,IAAIC,yCAAqBC,iCAAa,MAAM;CAI5D,MAAM,WAAW,IAAIC,mCAAS;GAC5BC,yDAAoB;GACpBC,4DAAuB;EACxB,GAAG;CACH;CAGD,MAAM,mBAAmB,CAAE;AAG3B,KAAI,eACH,kBAAiB,KAChB,IAAIC,yDAAoB,EAEvB,SAAS,CAAC,MAAM,WAAW;AAC1B,SAAO,WAAW,KAAK,aAAa,CAAC;AACrC,SAAO,UAAU,KAAK,aAAa,CAAC;AACpC,SAAO,cAAc,KAAK,aAAa,CAAC;CACxC,EACD,GACD;AAIF,KAAI,eACH,kBAAiB,KAChB,4EAA4B;EAE3B,qCAAqC,EAAE,SAAS,MAAO;EAEvD,uCAAuC,EACtC,2BAA2B,CAAC,YAAY;GAEvC,MAAM,OAAO,QAAQ,OAAO;AAC5B,UACC,KAAK,SAAS,YAAY,IAC1B,KAAK,SAAS,eAAe,IAC7B,KAAK,SAAS,WAAW;EAE1B,EACD;CACD,EAAC,CACF;CAIF,IAAIC;AACJ,KAAI,SACH,iBAAgB,IAAIC,2DAAkB;EACrC,MAAM,EAAE,SAAS;EACjB;CACA;KAGD,iBAAgB,IAAIC;CAIrB,MAAM,WAAW,yBAAyB,oCAAuB,YAAY;CAC7E,MAAM,gBAAgB,iCAAoB,eAAe,EAAE,SAAU,EAAC;AAGtE,qCAAuB,cAAc;AAGrC,OAAM,IAAIC,iCAAQ;EACjB;EACA;EACA,gBAAgB,CAAC,aAAc;EAC/B;CACA;AAGD,KAAI,UAAU;EACb,MAAM,cAAc,IAAIC,wDAAgB;GACvC,MAAM,EAAE,SAAS;GACjB;EACA;EAED,MAAM,iBAAiB,IAAIC,wCAAe,EAAE,SAAU;EACtD,MAAM,eAAe,IAAIC,iDAAwB;AACjD,iBAAe,sBAAsB,aAAa;AAGlD,qCAAsB,aAAa;CACnC;AAGD,KAAI,OAAO;AAGX,SAAQ,GAAG,WAAW,MAAM;AAC3B,OACG,UAAU,CACX,KAAK,MAAM,CAAE,EAAC,CACd,MAAM,CAAC,WAAW,CAAE,EAAC,CACrB,QAAQ,MAAM,QAAQ,KAAK,EAAE,CAAC;CAChC,EAAC;AACF;;;;AAKD,eAAsB,oBAAmC;AACxD,KAAI,KAAK;AACR,QAAM,IAAI,UAAU;AACpB,QAAM;CACN;AACD"}
1
+ {"version":3,"file":"setup-_uT4L_x5.cjs","names":["sdk: NodeSDK | null","options: TelemetryOptions","DiagConsoleLogger","DiagLogLevel","Resource","ATTR_SERVICE_NAME","ATTR_SERVICE_VERSION","PinoInstrumentation","traceExporter: SpanExporter","OTLPTraceExporter","ConsoleSpanExporter","NodeSDK","OTLPLogExporter","LoggerProvider","BatchLogRecordProcessor"],"sources":["../src/instrumentation/setup.ts"],"sourcesContent":["import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';\nimport { Resource } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nimport {\n\tConsoleSpanExporter,\n\ttype SpanExporter,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport type { SpanProcessorStrategy } from '../adapters/types';\nimport {\n\tcreateSpanProcessor,\n\tgetRecommendedStrategy,\n\tsetGlobalLogProcessor,\n\tsetGlobalSpanProcessor,\n} from './core';\n\n/**\n * Options for configuring telemetry\n */\nexport interface TelemetryOptions {\n\t/**\n\t * Service name for resource identification\n\t */\n\tserviceName: string;\n\n\t/**\n\t * Service version\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL (e.g., 'http://localhost:3000/__telescope/v1')\n\t * If not provided, traces will be logged to console\n\t */\n\tendpoint?: string;\n\n\t/**\n\t * Whether to instrument Pino for log correlation\n\t * @default true\n\t */\n\tinstrumentPino?: boolean;\n\n\t/**\n\t * Whether to enable auto-instrumentation for common libraries\n\t * (http, fetch, express, etc.)\n\t * @default true\n\t */\n\tautoInstrument?: boolean;\n\n\t/**\n\t * Enable debug logging for OTel SDK\n\t * @default false\n\t */\n\tdebug?: boolean;\n\n\t/**\n\t * Additional resource attributes\n\t */\n\tresourceAttributes?: Record<string, string>;\n\n\t/**\n\t * Headers to send with OTLP requests\n\t */\n\theaders?: Record<string, string>;\n\n\t/**\n\t * Span processor strategy.\n\t * - 'batch': Efficient batching for long-running servers (default)\n\t * - 'simple': Immediate export for serverless environments (Lambda, Edge)\n\t *\n\t * If not specified, automatically selected based on environment detection.\n\t */\n\tspanProcessorStrategy?: SpanProcessorStrategy;\n\n\t/**\n\t * Environment type for automatic configuration\n\t * @default 'server'\n\t */\n\tenvironment?: 'server' | 'lambda' | 'edge' | 'custom';\n}\n\nlet sdk: NodeSDK | null = null;\n\n/**\n * Set up OpenTelemetry instrumentation.\n * Call this BEFORE importing your application code.\n *\n * @example\n * ```typescript\n * // instrumentation.ts (create this file)\n * import { setupTelemetry } from '@geekmidas/telescope/instrumentation';\n *\n * setupTelemetry({\n * serviceName: 'my-api',\n * endpoint: 'http://localhost:3000/__telescope/v1',\n * });\n *\n * // Then in your entry point:\n * // import './instrumentation';\n * // import { app } from './app';\n * ```\n */\nexport function setupTelemetry(options: TelemetryOptions): void {\n\tif (sdk) {\n\t\treturn;\n\t}\n\n\tconst {\n\t\tserviceName,\n\t\tserviceVersion = '1.0.0',\n\t\tendpoint,\n\t\tinstrumentPino = true,\n\t\tautoInstrument = true,\n\t\tdebug = false,\n\t\tresourceAttributes = {},\n\t\theaders = {},\n\t\tspanProcessorStrategy,\n\t\tenvironment = 'server',\n\t} = options;\n\n\t// Enable debug logging if requested\n\tif (debug) {\n\t\tdiag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);\n\t}\n\n\t// Create resource\n\tconst resource = new Resource({\n\t\t[ATTR_SERVICE_NAME]: serviceName,\n\t\t[ATTR_SERVICE_VERSION]: serviceVersion,\n\t\t...resourceAttributes,\n\t});\n\n\t// Build instrumentations list\n\tconst instrumentations = [];\n\n\t// Add Pino instrumentation for log correlation\n\tif (instrumentPino) {\n\t\tinstrumentations.push(\n\t\t\tnew PinoInstrumentation({\n\t\t\t\t// Inject trace context into log records\n\t\t\t\tlogHook: (span, record) => {\n\t\t\t\t\trecord.trace_id = span.spanContext().traceId;\n\t\t\t\t\trecord.span_id = span.spanContext().spanId;\n\t\t\t\t\trecord.trace_flags = span.spanContext().traceFlags;\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Add auto-instrumentations for common libraries\n\tif (autoInstrument) {\n\t\tinstrumentations.push(\n\t\t\tgetNodeAutoInstrumentations({\n\t\t\t\t// Disable file system instrumentation (too noisy)\n\t\t\t\t'@opentelemetry/instrumentation-fs': { enabled: false },\n\t\t\t\t// Configure HTTP instrumentation\n\t\t\t\t'@opentelemetry/instrumentation-http': {\n\t\t\t\t\tignoreIncomingRequestHook: (request) => {\n\t\t\t\t\t\t// Ignore health checks and internal routes\n\t\t\t\t\t\tconst path = request.url || '';\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tpath.includes('/__health') ||\n\t\t\t\t\t\t\tpath.includes('/__telescope') ||\n\t\t\t\t\t\t\tpath.includes('/favicon')\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Create exporters\n\tlet traceExporter: SpanExporter;\n\tif (endpoint) {\n\t\ttraceExporter = new OTLPTraceExporter({\n\t\t\turl: `${endpoint}/traces`,\n\t\t\theaders,\n\t\t});\n\t} else {\n\t\t// Fall back to console exporter for debugging\n\t\ttraceExporter = new ConsoleSpanExporter();\n\t}\n\n\t// Determine span processor strategy\n\tconst strategy = spanProcessorStrategy ?? getRecommendedStrategy(environment);\n\tconst spanProcessor = createSpanProcessor(traceExporter, { strategy });\n\n\t// Register globally for flush operations\n\tsetGlobalSpanProcessor(spanProcessor);\n\n\t// Create and configure SDK\n\tsdk = new NodeSDK({\n\t\tresource,\n\t\ttraceExporter,\n\t\tspanProcessors: [spanProcessor],\n\t\tinstrumentations,\n\t});\n\n\t// Set up log exporter if endpoint is provided\n\tif (endpoint) {\n\t\tconst logExporter = new OTLPLogExporter({\n\t\t\turl: `${endpoint}/logs`,\n\t\t\theaders,\n\t\t});\n\n\t\tconst loggerProvider = new LoggerProvider({ resource });\n\t\tconst logProcessor = new BatchLogRecordProcessor(logExporter);\n\t\tloggerProvider.addLogRecordProcessor(logProcessor);\n\n\t\t// Register for flush operations\n\t\tsetGlobalLogProcessor(logProcessor);\n\t}\n\n\t// Start the SDK\n\tsdk.start();\n\n\t// Graceful shutdown\n\tprocess.on('SIGTERM', () => {\n\t\tsdk\n\t\t\t?.shutdown()\n\t\t\t.then(() => {})\n\t\t\t.catch((_error) => {})\n\t\t\t.finally(() => process.exit(0));\n\t});\n}\n\n/**\n * Shut down telemetry (for testing or graceful shutdown)\n */\nexport async function shutdownTelemetry(): Promise<void> {\n\tif (sdk) {\n\t\tawait sdk.shutdown();\n\t\tsdk = null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4FA,IAAIA,MAAsB;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgB,eAAeC,SAAiC;AAC/D,KAAI,IACH;CAGD,MAAM,EACL,aACA,iBAAiB,SACjB,UACA,iBAAiB,MACjB,iBAAiB,MACjB,QAAQ,OACR,qBAAqB,CAAE,GACvB,UAAU,CAAE,GACZ,uBACA,cAAc,UACd,GAAG;AAGJ,KAAI,MACH,0BAAK,UAAU,IAAIC,yCAAqBC,iCAAa,MAAM;CAI5D,MAAM,WAAW,IAAIC,mCAAS;GAC5BC,yDAAoB;GACpBC,4DAAuB;EACxB,GAAG;CACH;CAGD,MAAM,mBAAmB,CAAE;AAG3B,KAAI,eACH,kBAAiB,KAChB,IAAIC,yDAAoB,EAEvB,SAAS,CAAC,MAAM,WAAW;AAC1B,SAAO,WAAW,KAAK,aAAa,CAAC;AACrC,SAAO,UAAU,KAAK,aAAa,CAAC;AACpC,SAAO,cAAc,KAAK,aAAa,CAAC;CACxC,EACD,GACD;AAIF,KAAI,eACH,kBAAiB,KAChB,4EAA4B;EAE3B,qCAAqC,EAAE,SAAS,MAAO;EAEvD,uCAAuC,EACtC,2BAA2B,CAAC,YAAY;GAEvC,MAAM,OAAO,QAAQ,OAAO;AAC5B,UACC,KAAK,SAAS,YAAY,IAC1B,KAAK,SAAS,eAAe,IAC7B,KAAK,SAAS,WAAW;EAE1B,EACD;CACD,EAAC,CACF;CAIF,IAAIC;AACJ,KAAI,SACH,iBAAgB,IAAIC,2DAAkB;EACrC,MAAM,EAAE,SAAS;EACjB;CACA;KAGD,iBAAgB,IAAIC;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;;;;;;;;;;;;;;;;;;iBAkOX,qBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"tracing-BX8uY2nR.d.cts","names":[],"sources":["../src/instrumentation/tracing.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAOgB,iBAPA,aAAA,CAAA,CAO8B,EAPb,IAOuB,GAAA,SAAA;AAUxD;;;AAAmE,iBAVnD,iBAAA,CAUmD,UAAA,EAVrB,UAUqB,CAAA,EAAA,IAAA;AAAI;AAkBvE;;AAEY,iBApBI,UAAA,CAoBJ,IAAA,EAAA,MAAA,EAAA,UAAA,CAAA,EApB0C,UAoB1C,CAAA,EApBuD,IAoBvD;;;;;;AAEF;AA4BV;;;;;;AAII,iBApCkB,QAoClB,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,EAAA,EAAA,CAAA,IAAA,EAlCQ,IAkCR,EAAA,GAlCiB,OAkCjB,CAlCyB,CAkCzB,CAAA,EAAA,UAAA,CAAA,EAjCU,UAiCV,CAAA,EAhCD,OAgCC,CAhCO,CAgCP,CAAA;AA2BJ;AAQA;AAQA;AAcgB,iBA7DA,YA6DwC,CAAA,CAAA,CAAA,CAAU,IAAA,EAAA,MAAA,EAAA,EAAA,EAAA,CAAA,IAAA,EA3DtD,IA2DsD,EAAA,GA3D7C,CA2D6C,EAAA,UAAA,CAAA,EA1DpD,UA0DoD,CAAA,EAzD/D,CAyD+D;;;;iBA9BlD,UAAA,CAAA;;;;iBAQA,SAAA,CAAA;;;;iBAQA,eAAA,QAAuB;;;;iBAcvB,YAAA,4BAAwC"}
1
+ {"version":3,"file":"tracing-BX8uY2nR.d.cts","names":[],"sources":["../src/instrumentation/tracing.ts"],"sourcesContent":[],"mappings":";;;;;;AAWA;AAOgB,iBAPA,aAAA,CAAA,CAO8B,EAPb,IAOa,GAAU,SAAA;AAUxD;;;AAAmE,iBAVnD,iBAAA,CAUmD,UAAA,EAVrB,UAUqB,CAAA,EAAA,IAAA;AAAI;AAkBvE;;AAE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AA;;;;iBAQA,eAAA,QAAuB;;;;iBAcvB,YAAA,4BAAwC"}
@@ -1,4 +1,4 @@
1
- import { SeverityNumber, SpanKind, SpanStatusCode } from "./types-Cj59nqy7.mjs";
1
+ import { SeverityNumber, SpanKind, SpanStatusCode } from "./types-CXYLhG_G.mjs";
2
2
 
3
3
  //#region src/otlp/transformer.ts
4
4
  /**
@@ -212,4 +212,4 @@ function transformMetrics(request) {
212
212
 
213
213
  //#endregion
214
214
  export { transformLogs, transformMetrics, transformTraces };
215
- //# sourceMappingURL=transformer-CFQ4WFk6.mjs.map
215
+ //# sourceMappingURL=transformer-CFrJQkUg.mjs.map