@geekmidas/telescope 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/adapters/lambda.cjs +1 -1
- package/dist/adapters/lambda.mjs +1 -1
- package/dist/adapters/middy.cjs +1 -1
- package/dist/adapters/middy.mjs +1 -1
- package/dist/{hono-CPHX7FAm.cjs → hono-C4EgpbKQ.cjs} +2 -2
- package/dist/{hono-CPHX7FAm.cjs.map → hono-C4EgpbKQ.cjs.map} +1 -1
- package/dist/{hono-Bw-ey6CT.mjs → hono-DxhvnVbF.mjs} +2 -2
- package/dist/{hono-Bw-ey6CT.mjs.map → hono-DxhvnVbF.mjs.map} +1 -1
- package/dist/{http-BIvr0YdI.mjs → http-DQzgLczm.mjs} +1 -1
- package/dist/{http-BIvr0YdI.mjs.map → http-DQzgLczm.mjs.map} +1 -1
- package/dist/{http-BsqmhurZ.cjs → http-D_Z8sYXZ.cjs} +1 -1
- package/dist/{http-BsqmhurZ.cjs.map → http-D_Z8sYXZ.cjs.map} +1 -1
- package/dist/instrumentation/hono.cjs +2 -2
- package/dist/instrumentation/hono.mjs +2 -2
- package/dist/instrumentation/http.cjs +1 -1
- package/dist/instrumentation/http.mjs +1 -1
- package/dist/instrumentation/index.cjs +5 -5
- package/dist/instrumentation/index.mjs +5 -5
- package/dist/instrumentation/middleware.cjs +2 -2
- package/dist/instrumentation/middleware.mjs +2 -2
- package/dist/instrumentation/otel.cjs +2 -2
- package/dist/instrumentation/otel.mjs +2 -2
- package/dist/instrumentation/setup.cjs +1 -1
- package/dist/instrumentation/setup.mjs +1 -1
- package/dist/{middleware-DqPQpcup.cjs → middleware-B2jFUukM.cjs} +2 -2
- package/dist/{middleware-DqPQpcup.cjs.map → middleware-B2jFUukM.cjs.map} +1 -1
- package/dist/{middleware-4-GrQlOT.mjs → middleware-BTDncHwm.mjs} +2 -2
- package/dist/{middleware-4-GrQlOT.mjs.map → middleware-BTDncHwm.mjs.map} +1 -1
- package/dist/{middy-DHWLmUAD.mjs → middy-BTR3cyvk.mjs} +1 -1
- package/dist/{middy-DHWLmUAD.mjs.map → middy-BTR3cyvk.mjs.map} +1 -1
- package/dist/{middy-DlWnZilH.cjs → middy-y5Zp27eG.cjs} +1 -1
- package/dist/{middy-DlWnZilH.cjs.map → middy-y5Zp27eG.cjs.map} +1 -1
- package/dist/{otel-COrpz_GZ.cjs → otel-C1HqHA2O.cjs} +2 -2
- package/dist/{otel-COrpz_GZ.cjs.map → otel-C1HqHA2O.cjs.map} +1 -1
- package/dist/otel-SBVoVEHr.d.cts.map +1 -1
- package/dist/{otel-40udNP5g.mjs → otel-wulj5B-X.mjs} +2 -2
- package/dist/{otel-40udNP5g.mjs.map → otel-wulj5B-X.mjs.map} +1 -1
- package/dist/otlp/hono.cjs +3 -3
- package/dist/otlp/hono.mjs +3 -3
- package/dist/otlp/index.cjs +3 -3
- package/dist/otlp/index.mjs +3 -3
- package/dist/otlp/receiver.cjs +3 -3
- package/dist/otlp/receiver.mjs +3 -3
- package/dist/otlp/transformer.cjs +2 -2
- package/dist/otlp/transformer.mjs +2 -2
- package/dist/otlp/types.cjs +1 -1
- package/dist/otlp/types.mjs +1 -1
- package/dist/{receiver-slCoAFat.cjs → receiver-Cj1lbAOO.cjs} +2 -2
- package/dist/{receiver-slCoAFat.cjs.map → receiver-Cj1lbAOO.cjs.map} +1 -1
- package/dist/{receiver-D46dfkYI.mjs → receiver-CxVd_9CB.mjs} +2 -2
- package/dist/{receiver-D46dfkYI.mjs.map → receiver-CxVd_9CB.mjs.map} +1 -1
- package/dist/{setup-DC9JMEYZ.mjs → setup-B9jM77Qk.mjs} +1 -1
- package/dist/{setup-DC9JMEYZ.mjs.map → setup-B9jM77Qk.mjs.map} +1 -1
- package/dist/{setup-DufxQpi9.cjs → setup-CYpff5B9.cjs} +1 -1
- package/dist/{setup-DufxQpi9.cjs.map → setup-CYpff5B9.cjs.map} +1 -1
- package/dist/storage/kysely.d.cts.map +1 -1
- package/dist/storage/kysely.d.mts.map +1 -1
- package/dist/{transformer-CFQ4WFk6.mjs → transformer-BXQPhzql.mjs} +2 -2
- package/dist/{transformer-CFQ4WFk6.mjs.map → transformer-BXQPhzql.mjs.map} +1 -1
- package/dist/{transformer-Csl6fbgv.cjs → transformer-CLGZ0EQc.cjs} +2 -2
- package/dist/{transformer-Csl6fbgv.cjs.map → transformer-CLGZ0EQc.cjs.map} +1 -1
- package/dist/{types-Cj59nqy7.mjs → types-Bwm_jNU7.mjs} +1 -1
- package/dist/{types-Cj59nqy7.mjs.map → types-Bwm_jNU7.mjs.map} +1 -1
- package/dist/{types-BMiHgsi4.cjs → types-Dsh-DIO_.cjs} +1 -1
- package/dist/{types-BMiHgsi4.cjs.map → types-Dsh-DIO_.cjs.map} +1 -1
- package/package.json +115 -45
- package/ui/node_modules/.bin/vite +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-
|
|
1
|
+
{"version":3,"file":"setup-CYpff5B9.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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C,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely.d.cts","names":[],"sources":["../../src/storage/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;AAqBA;AAeiB,UApCA,qBAAA,
|
|
1
|
+
{"version":3,"file":"kysely.d.cts","names":[],"sources":["../../src/storage/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;AAqBA;AAeiB,UApCA,qBAAA,CA0CD;EAiBC,EAAA,EAAA,MAAA;EAAe,MAAA,EAAA,MAAA;EAAA,IACX,EAAA,MAAA;EAAqB,GACnB,EAAA,MAAA;EAAuB,OAC7B,EAAA,OAAA;EAAiB,IAAA,EAAA,OAAA,GAAA,IAAA;EAMjB,KAAA,EAAA,OAAA,GAAA,IAAA;EAAmB,MAAA,EAAA,MAAA;EAAA,gBAExB,EAAA,OAAA;EAAE,aAAT,EAAA,OAAA,GAAA,IAAA;EAAM,QAAA,EAAA,MAAA;EA6BE,SAAA,EAvFD,IAuFC;EAAa,EAAA,EAAA,MAAA,GAAA,IAAA;EAAA,OAMe,EAAA,MAAA,GAAA,IAAA;EAAE,IAAtB,EAAA,OAAA,GAAA,IAAA;;;;;AA2BQ,UA/GZ,uBAAA,CA+GY;EAAY,EAAA,EAAW,MAAA;EAAY,IAApB,EAAA,MAAA;EAAO,OAoCZ,EAAA,MAAA;EAAY,KAApB,EAAA,OAAA;EAAO,MAcV,EAAA,OAAA,GAAA,IAAA;EAAc,UAAG,EAAA,MAAA,GAAA,IAAA;EAAO,SAQrB,EAlKnB,IAkKmB;EAAc,OAAK,EAAA,OAAA;EAAO,IAU1B,EAAA,OAAA,GAAA,IAAA;;;;;AA0BT,UA9LL,iBAAA,CA8LK;EAAQ,EAAA,EAAG,MAAA;EAAO,KAKf,EAAA,MAAA;EAAQ,OAAK,EAAA,MAAA;EAAO,OAOpB,EAAA,OAAA,GAAA,IAAA;EAAY,UAAW,EAAA,MAAA,GAAA,IAAA;EAAQ,SAAhB,EApM5B,IAoM4B;;;;;;AA3IkB;AA4Z1D;;;;;;;;;UApciB,eAAA;sBACI;wBACE;kBACN;;;;;UAMA;;MAEZ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6BC,6BAA6B;;;;;sBAMrB,oBAAoB;qBAYf,eAAe;wBAKZ,iBAAiB;wBAUjB,eAAe,QAAQ;0BAoCrB,QAAQ;uBAcX,iBAAiB;0BAQd,mBAAmB;0BAUnB,eAAe,QAAQ;4BAYrB,QAAQ;iBAcnB,WAAW;oBAKR,aAAa;oBAOb,eAAe,QAAQ;mBAqBxB,OAAO;cA0BZ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkOX,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely.d.mts","names":[],"sources":["../../src/storage/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;AAqBA;AAeiB,UApCA,qBAAA,
|
|
1
|
+
{"version":3,"file":"kysely.d.mts","names":[],"sources":["../../src/storage/kysely.ts"],"sourcesContent":[],"mappings":";;;;;;;AAcA;AAqBA;AAeiB,UApCA,qBAAA,CA0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,QAAQ;4BAYrB,QAAQ;iBAcnB,WAAW;oBAKR,aAAa;oBAOb,eAAe,QAAQ;mBAqBxB,OAAO;cA0BZ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkOX,qBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SeverityNumber, SpanKind, SpanStatusCode } from "./types-
|
|
1
|
+
import { SeverityNumber, SpanKind, SpanStatusCode } from "./types-Bwm_jNU7.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-
|
|
215
|
+
//# sourceMappingURL=transformer-BXQPhzql.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer-CFQ4WFk6.mjs","names":["value?: AnyValue","attrs?: KeyValue[]","result: Record<string, unknown>","nanoStr: string","severity?: SeverityNumber","span: Span","resourceAttrs: Record<string, unknown>","headers: Record<string, string>","request: ExportTraceServiceRequest","entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>>","record: LogRecord","scopeName?: string","context: Record<string, unknown>","request: ExportLogsServiceRequest","entries: Array<Omit<LogEntry, 'id' | 'timestamp'>>","request: ExportMetricsServiceRequest","points: MetricDataPoint[]"],"sources":["../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'summary',\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\treturn points;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,aAAaA,OAA2B;AAChD,MAAK,MAAO;AACZ,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,qBAAyB,QAAO,MAAM;AAChD,KAAI,MAAM,oBAAwB,QAAO,SAAS,MAAM,UAAU,GAAG;AACrE,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,sBAA0B,QAAO,MAAM;AACjD,KAAI,MAAM,WAAY,QAAO,MAAM,WAAW,OAAO,IAAI,aAAa;AACtE,KAAI,MAAM,YAAa,QAAO,mBAAmB,MAAM,YAAY,OAAO;AAC1E;AACA;;;;AAKD,SAAS,mBAAmBC,OAA6C;AACxE,MAAK,MAAO,QAAO,CAAE;CACrB,MAAMC,SAAkC,CAAE;AAC1C,MAAK,MAAM,QAAQ,MAClB,QAAO,KAAK,OAAO,aAAa,KAAK,MAAM;AAE5C,QAAO;AACP;;;;AAKD,SAAS,WAAWC,S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O,KAAK;IACX,GAAG;IACH,OAAO,GAAG,aAAa,GAAG,QAAQ,SAAS,GAAG,OAAO,GAAG,GAAG;IAC3D,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY,mBAAmB,GAAG,WAAW;IAC7C,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,UACV,MAAK,MAAM,MAAM,OAAO,UAAU,WACjC,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,KAAK,GAAG;KACR,KAAK,GAAG;IACR;IACD,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,QACV,MAAK,MAAM,MAAM,OAAO,QAAQ,WAC/B,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,WAAW,GAAG;IACd;IACD,MAAM;GACN,EAAC;EAGJ;CAEF;AAED,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"transformer-BXQPhzql.mjs","names":["value?: AnyValue","attrs?: KeyValue[]","result: Record<string, unknown>","nanoStr: string","severity?: SeverityNumber","span: Span","resourceAttrs: Record<string, unknown>","headers: Record<string, string>","request: ExportTraceServiceRequest","entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>>","record: LogRecord","scopeName?: string","context: Record<string, unknown>","request: ExportLogsServiceRequest","entries: Array<Omit<LogEntry, 'id' | 'timestamp'>>","request: ExportMetricsServiceRequest","points: MetricDataPoint[]"],"sources":["../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'summary',\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\treturn points;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,aAAaA,OAA2B;AAChD,MAAK,MAAO;AACZ,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,qBAAyB,QAAO,MAAM;AAChD,KAAI,MAAM,oBAAwB,QAAO,SAAS,MAAM,UAAU,GAAG;AACrE,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,sBAA0B,QAAO,MAAM;AACjD,KAAI,MAAM,WAAY,QAAO,MAAM,WAAW,OAAO,IAAI,aAAa;AACtE,KAAI,MAAM,YAAa,QAAO,mBAAmB,MAAM,YAAY,OAAO;AAC1E;AACA;;;;AAKD,SAAS,mBAAmBC,OA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,OAAO,GAAG,GAAG;IAC3D,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY,mBAAmB,GAAG,WAAW;IAC7C,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,IACV,MAAK,MAAM,MAAM,OAAO,IAAI,WAC3B,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,aAAa,GAAG,QAAQ,SAAS,GAAG,OAAO,GAAG,GAAG;IAC3D,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY,mBAAmB,GAAG,WAAW;IAC7C,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,UACV,MAAK,MAAM,MAAM,OAAO,UAAU,WACjC,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,KAAK,GAAG;KACR,KAAK,GAAG;IACR;IACD,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,QACV,MAAK,MAAM,MAAM,OAAO,QAAQ,WAC/B,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,WAAW,GAAG;IACd;IACD,MAAM;GACN,EAAC;EAGJ;CAEF;AAED,QAAO;AACP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_types = require('./types-
|
|
1
|
+
const require_types = require('./types-Dsh-DIO_.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/otlp/transformer.ts
|
|
4
4
|
/**
|
|
@@ -229,4 +229,4 @@ Object.defineProperty(exports, 'transformTraces', {
|
|
|
229
229
|
return transformTraces;
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
|
-
//# sourceMappingURL=transformer-
|
|
232
|
+
//# sourceMappingURL=transformer-CLGZ0EQc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer-Csl6fbgv.cjs","names":["value?: AnyValue","attrs?: KeyValue[]","result: Record<string, unknown>","nanoStr: string","severity?: SeverityNumber","SeverityNumber","span: Span","SpanStatusCode","SpanKind","resourceAttrs: Record<string, unknown>","headers: Record<string, string>","request: ExportTraceServiceRequest","entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>>","record: LogRecord","scopeName?: string","context: Record<string, unknown>","request: ExportLogsServiceRequest","entries: Array<Omit<LogEntry, 'id' | 'timestamp'>>","request: ExportMetricsServiceRequest","points: MetricDataPoint[]"],"sources":["../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\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AM,OAAO,QAAQ,WAC/B,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,WAAW,GAAG;IACd;IACD,MAAM;GACN,EAAC;EAGJ;CAEF;AAED,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"transformer-CLGZ0EQc.cjs","names":["value?: AnyValue","attrs?: KeyValue[]","result: Record<string, unknown>","nanoStr: string","severity?: SeverityNumber","SeverityNumber","span: Span","SpanStatusCode","SpanKind","resourceAttrs: Record<string, unknown>","headers: Record<string, string>","request: ExportTraceServiceRequest","entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>>","record: LogRecord","scopeName?: string","context: Record<string, unknown>","request: ExportLogsServiceRequest","entries: Array<Omit<LogEntry, 'id' | 'timestamp'>>","request: ExportMetricsServiceRequest","points: MetricDataPoint[]"],"sources":["../src/otlp/transformer.ts"],"sourcesContent":["import type { LogEntry, RequestEntry } from '../types';\nimport {\n\ttype AnyValue,\n\ttype ExportLogsServiceRequest,\n\ttype ExportMetricsServiceRequest,\n\ttype ExportTraceServiceRequest,\n\ttype KeyValue,\n\ttype LogRecord,\n\tSeverityNumber,\n\ttype Span,\n\tSpanKind,\n\tSpanStatusCode,\n} from './types';\n\n/**\n * Extract a primitive value from an AnyValue\n */\nfunction extractValue(value?: AnyValue): unknown {\n\tif (!value) return undefined;\n\tif (value.stringValue !== undefined) return value.stringValue;\n\tif (value.boolValue !== undefined) return value.boolValue;\n\tif (value.intValue !== undefined) return parseInt(value.intValue, 10);\n\tif (value.doubleValue !== undefined) return value.doubleValue;\n\tif (value.bytesValue !== undefined) return value.bytesValue;\n\tif (value.arrayValue) return value.arrayValue.values.map(extractValue);\n\tif (value.kvlistValue) return attributesToObject(value.kvlistValue.values);\n\treturn undefined;\n}\n\n/**\n * Convert KeyValue array to a plain object\n */\nfunction attributesToObject(attrs?: KeyValue[]): Record<string, unknown> {\n\tif (!attrs) return {};\n\tconst result: Record<string, unknown> = {};\n\tfor (const attr of attrs) {\n\t\tresult[attr.key] = extractValue(attr.value);\n\t}\n\treturn result;\n}\n\n/**\n * Convert nanoseconds string to Date\n */\nfunction nanoToDate(nanoStr: string): Date {\n\tconst nano = BigInt(nanoStr);\n\tconst ms = Number(nano / BigInt(1_000_000));\n\treturn new Date(ms);\n}\n\n/**\n * Convert nanoseconds string to milliseconds number\n */\nfunction nanoToMs(nanoStr: string): number {\n\tconst nano = BigInt(nanoStr);\n\treturn Number(nano / BigInt(1_000_000));\n}\n\n/**\n * Map OTLP severity number to Telescope log level\n */\nfunction mapSeverity(\n\tseverity?: SeverityNumber,\n): 'debug' | 'info' | 'warn' | 'error' {\n\tif (severity === undefined) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_DEBUG4) return 'debug';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_INFO4) return 'info';\n\tif (severity <= SeverityNumber.SEVERITY_NUMBER_WARN4) return 'warn';\n\treturn 'error';\n}\n\n/**\n * Determine HTTP status from span attributes and status\n */\nfunction getHttpStatus(span: Span): number {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Look for HTTP status code in various attribute names\n\tconst statusCode =\n\t\tattrs['http.status_code'] ??\n\t\tattrs['http.response.status_code'] ??\n\t\tattrs['http.response_status_code'];\n\n\tif (typeof statusCode === 'number') return statusCode;\n\tif (typeof statusCode === 'string') return parseInt(statusCode, 10) || 200;\n\n\t// Fall back to span status\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_ERROR) return 500;\n\tif (span.status?.code === SpanStatusCode.STATUS_CODE_OK) return 200;\n\n\treturn 200;\n}\n\n/**\n * Check if a span represents an HTTP server request\n */\nfunction isHttpServerSpan(span: Span): boolean {\n\tif (span.kind !== SpanKind.SPAN_KIND_SERVER) return false;\n\n\tconst attrs = attributesToObject(span.attributes);\n\treturn !!(\n\t\tattrs['http.method'] ||\n\t\tattrs['http.request.method'] ||\n\t\tattrs['http.url'] ||\n\t\tattrs['http.target'] ||\n\t\tattrs['url.path']\n\t);\n}\n\n/**\n * Transform HTTP-related span attributes to RequestEntry format\n */\nfunction transformHttpSpan(\n\tspan: Span,\n\tresourceAttrs: Record<string, unknown>,\n): Omit<RequestEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(span.attributes);\n\n\t// Extract HTTP method\n\tconst method = String(\n\t\tattrs['http.method'] ?? attrs['http.request.method'] ?? 'GET',\n\t).toUpperCase();\n\n\t// Extract path\n\tconst path = String(\n\t\tattrs['http.target'] ?? attrs['url.path'] ?? attrs['http.route'] ?? '/',\n\t);\n\n\t// Extract full URL\n\tconst url = String(\n\t\tattrs['http.url'] ?? attrs['url.full'] ?? `http://localhost${path}`,\n\t);\n\n\t// Extract headers (if available)\n\tconst headers: Record<string, string> = {};\n\tconst userAgent = attrs['http.user_agent'] ?? attrs['user_agent.original'];\n\tif (userAgent) headers['user-agent'] = String(userAgent);\n\n\tconst contentType = attrs['http.request.header.content_type'];\n\tif (contentType) headers['content-type'] = String(contentType);\n\n\t// Calculate duration\n\tconst startTime = nanoToMs(span.startTimeUnixNano);\n\tconst endTime = nanoToMs(span.endTimeUnixNano);\n\tconst duration = endTime - startTime;\n\n\t// Get status code\n\tconst status = getHttpStatus(span);\n\n\t// Extract client IP\n\tconst ip =\n\t\tattrs['net.peer.ip'] ?? attrs['client.address'] ?? attrs['http.client_ip'];\n\n\treturn {\n\t\tmethod,\n\t\tpath,\n\t\turl,\n\t\theaders,\n\t\tquery: {},\n\t\tstatus,\n\t\tresponseHeaders: {},\n\t\tduration,\n\t\tip: ip ? String(ip) : undefined,\n\t\ttags: [\n\t\t\t`trace:${span.traceId}`,\n\t\t\t`span:${span.spanId}`,\n\t\t\t...(resourceAttrs['service.name']\n\t\t\t\t? [`service:${resourceAttrs['service.name']}`]\n\t\t\t\t: []),\n\t\t],\n\t};\n}\n\n/**\n * Transform OTLP traces to Telescope RequestEntries\n * Only transforms HTTP server spans to request entries\n */\nexport function transformTraces(\n\trequest: ExportTraceServiceRequest,\n): Array<Omit<RequestEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<RequestEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceSpans of request.resourceSpans ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceSpans.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeSpans of resourceSpans.scopeSpans ?? []) {\n\t\t\tfor (const span of scopeSpans.spans ?? []) {\n\t\t\t\t// Only transform HTTP server spans\n\t\t\t\tif (isHttpServerSpan(span)) {\n\t\t\t\t\tentries.push(transformHttpSpan(span, resourceAttrs));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Transform a single OTLP log record to Telescope LogEntry\n */\nfunction transformLogRecord(\n\trecord: LogRecord,\n\tresourceAttrs: Record<string, unknown>,\n\tscopeName?: string,\n): Omit<LogEntry, 'id' | 'timestamp'> {\n\tconst attrs = attributesToObject(record.attributes);\n\n\t// Extract message from body\n\tlet message = '';\n\tif (record.body) {\n\t\tconst bodyValue = extractValue(record.body);\n\t\tmessage =\n\t\t\ttypeof bodyValue === 'string' ? bodyValue : JSON.stringify(bodyValue);\n\t}\n\n\t// Build context from attributes\n\tconst context: Record<string, unknown> = {\n\t\t...attrs,\n\t\t...resourceAttrs,\n\t};\n\n\tif (scopeName) {\n\t\tcontext['instrumentation.scope'] = scopeName;\n\t}\n\n\t// Add severity text if present\n\tif (record.severityText) {\n\t\tcontext['severity.text'] = record.severityText;\n\t}\n\n\treturn {\n\t\tlevel: mapSeverity(record.severityNumber),\n\t\tmessage,\n\t\tcontext: Object.keys(context).length > 0 ? context : undefined,\n\t\trequestId: record.spanId ? `span:${record.spanId}` : undefined,\n\t};\n}\n\n/**\n * Transform OTLP logs to Telescope LogEntries\n */\nexport function transformLogs(\n\trequest: ExportLogsServiceRequest,\n): Array<Omit<LogEntry, 'id' | 'timestamp'>> {\n\tconst entries: Array<Omit<LogEntry, 'id' | 'timestamp'>> = [];\n\n\tfor (const resourceLogs of request.resourceLogs ?? []) {\n\t\tconst resourceAttrs = attributesToObject(resourceLogs.resource?.attributes);\n\n\t\tfor (const scopeLogs of resourceLogs.scopeLogs ?? []) {\n\t\t\tconst scopeName = scopeLogs.scope?.name;\n\n\t\t\tfor (const record of scopeLogs.logRecords ?? []) {\n\t\t\t\tentries.push(transformLogRecord(record, resourceAttrs, scopeName));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\n/**\n * Extracted metric data point for recording\n */\nexport interface MetricDataPoint {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tvalue: number;\n\ttimestamp: Date;\n\tattributes: Record<string, unknown>;\n\tresourceAttributes: Record<string, unknown>;\n\ttype: 'gauge' | 'sum' | 'histogram' | 'summary';\n}\n\n/**\n * Transform OTLP metrics to normalized data points\n * These can be used for custom metrics processing or forwarding\n */\nexport function transformMetrics(\n\trequest: ExportMetricsServiceRequest,\n): MetricDataPoint[] {\n\tconst points: MetricDataPoint[] = [];\n\n\tfor (const resourceMetrics of request.resourceMetrics ?? []) {\n\t\tconst resourceAttrs = attributesToObject(\n\t\t\tresourceMetrics.resource?.attributes,\n\t\t);\n\n\t\tfor (const scopeMetrics of resourceMetrics.scopeMetrics ?? []) {\n\t\t\tfor (const metric of scopeMetrics.metrics ?? []) {\n\t\t\t\tconst baseMeta = {\n\t\t\t\t\tname: metric.name,\n\t\t\t\t\tdescription: metric.description,\n\t\t\t\t\tunit: metric.unit,\n\t\t\t\t\tresourceAttributes: resourceAttrs,\n\t\t\t\t};\n\n\t\t\t\t// Handle gauge\n\t\t\t\tif (metric.gauge) {\n\t\t\t\t\tfor (const dp of metric.gauge.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'gauge',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle sum (counter)\n\t\t\t\tif (metric.sum) {\n\t\t\t\t\tfor (const dp of metric.sum.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.asDouble ?? (dp.asInt ? parseInt(dp.asInt, 10) : 0),\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: attributesToObject(dp.attributes),\n\t\t\t\t\t\t\ttype: 'sum',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle histogram (extract sum as the value)\n\t\t\t\tif (metric.histogram) {\n\t\t\t\t\tfor (const dp of metric.histogram.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tmin: dp.min,\n\t\t\t\t\t\t\t\tmax: dp.max,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'histogram',\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Handle summary\n\t\t\t\tif (metric.summary) {\n\t\t\t\t\tfor (const dp of metric.summary.dataPoints) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\t...baseMeta,\n\t\t\t\t\t\t\tvalue: dp.sum ?? 0,\n\t\t\t\t\t\t\ttimestamp: nanoToDate(dp.timeUnixNano),\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t...attributesToObject(dp.attributes),\n\t\t\t\t\t\t\t\tcount: parseInt(dp.count, 10),\n\t\t\t\t\t\t\t\tquantiles: dp.quantileValues,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttype: 'summary',\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\treturn points;\n}\n"],"mappings":";;;;;;AAiBA,SAAS,aAAaA,OAA2B;AAChD,MAAK,MAAO;AACZ,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,qBAAyB,QAAO,MAAM;AAChD,KAAI,MAAM,oBAAwB,QAAO,SAAS,MAAM,UAAU,GAAG;AACrE,KAAI,MAAM,uBAA2B,QAAO,MAAM;AAClD,KAAI,MAAM,sBAA0B,QAAO,MAAM;AACjD,KAAI,MAAM,WAAY,QAAO,MAAM,WAAW,OAAO,IAAI,aAAa;AACtE,KAAI,MAAM,YAAa,QAAO,mBAAmB,MAAM,YAAY,OAAO;AAC1E;AACA;;;;AAKD,SAAS,mBAAmBC,OAA6C;AACxE,MAAK,MAAO,QAAO,CAAE;CACrB,MAAMC,SAAkC,CAAE;AAC1C,MAAK,MAAM,QAAQ,MAClB,QAAO,KAAK,OAAO,aAAa,KAAK,MAAM;AAE5C,QAAO;AACP;;;;AAKD,SAAS,WAAWC,SAAuB;CAC1C,MAAM,OAAO,OAAO,QAAQ;CAC5B,MAAM,KAAK,OAAO,OAAO,OAAO,IAAU,CAAC;AAC3C,QAAO,IAAI,KAAK;AAChB;;;;AAKD,SAAS,SAASA,SAAyB;CAC1C,MAAM,OAAO,OAAO,QAAQ;AAC5B,QAAO,OAAO,OAAO,OAAO,IAAU,CAAC;AACvC;;;;AAKD,SAAS,YACRC,UACsC;AACtC,KAAI,oBAAwB,QAAO;AACn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O;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,KAAK,GAAG;KACR,KAAK,GAAG;IACR;IACD,MAAM;GACN,EAAC;AAKJ,OAAI,OAAO,QACV,MAAK,MAAM,MAAM,OAAO,QAAQ,WAC/B,QAAO,KAAK;IACX,GAAG;IACH,OAAO,GAAG,OAAO;IACjB,WAAW,WAAW,GAAG,aAAa;IACtC,YAAY;KACX,GAAG,mBAAmB,GAAG,WAAW;KACpC,OAAO,SAAS,GAAG,OAAO,GAAG;KAC7B,WAAW,GAAG;IACd;IACD,MAAM;GACN,EAAC;EAGJ;CAEF;AAED,QAAO;AACP"}
|
|
@@ -51,4 +51,4 @@ let AggregationTemporality = /* @__PURE__ */ function(AggregationTemporality$1)
|
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
export { AggregationTemporality, SeverityNumber, SpanKind, SpanStatusCode };
|
|
54
|
-
//# sourceMappingURL=types-
|
|
54
|
+
//# sourceMappingURL=types-Bwm_jNU7.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-Bwm_jNU7.mjs","names":[],"sources":["../src/otlp/types.ts"],"sourcesContent":["/**\n * OTLP JSON types based on OpenTelemetry Protocol specification.\n * These types represent the JSON encoding of OTLP protobuf messages.\n * @see https://opentelemetry.io/docs/specs/otlp/\n */\n\n// ============================================\n// Common Types\n// ============================================\n\n/**\n * Key-value pair for attributes\n */\nexport interface KeyValue {\n\tkey: string;\n\tvalue: AnyValue;\n}\n\n/**\n * Any value type (string, bool, int, double, array, kvlist, bytes)\n */\nexport interface AnyValue {\n\tstringValue?: string;\n\tboolValue?: boolean;\n\tintValue?: string; // int64 as string\n\tdoubleValue?: number;\n\tarrayValue?: ArrayValue;\n\tkvlistValue?: KeyValueList;\n\tbytesValue?: string; // base64 encoded\n}\n\nexport interface ArrayValue {\n\tvalues: AnyValue[];\n}\n\nexport interface KeyValueList {\n\tvalues: KeyValue[];\n}\n\n/**\n * Resource represents the entity producing telemetry\n */\nexport interface Resource {\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\n/**\n * InstrumentationScope represents the instrumentation library\n */\nexport interface InstrumentationScope {\n\tname: string;\n\tversion?: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\n// ============================================\n// Trace Types\n// ============================================\n\n/**\n * Root message for trace export\n */\nexport interface ExportTraceServiceRequest {\n\tresourceSpans?: ResourceSpans[];\n}\n\nexport interface ResourceSpans {\n\tresource?: Resource;\n\tscopeSpans?: ScopeSpans[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeSpans {\n\tscope?: InstrumentationScope;\n\tspans?: Span[];\n\tschemaUrl?: string;\n}\n\nexport interface Span {\n\ttraceId: string; // hex encoded 16 bytes\n\tspanId: string; // hex encoded 8 bytes\n\ttraceState?: string;\n\tparentSpanId?: string; // hex encoded 8 bytes\n\tflags?: number;\n\tname: string;\n\tkind?: SpanKind;\n\tstartTimeUnixNano: string; // uint64 as string\n\tendTimeUnixNano: string; // uint64 as string\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tevents?: SpanEvent[];\n\tdroppedEventsCount?: number;\n\tlinks?: SpanLink[];\n\tdroppedLinksCount?: number;\n\tstatus?: SpanStatus;\n}\n\nexport enum SpanKind {\n\tSPAN_KIND_UNSPECIFIED = 0,\n\tSPAN_KIND_INTERNAL = 1,\n\tSPAN_KIND_SERVER = 2,\n\tSPAN_KIND_CLIENT = 3,\n\tSPAN_KIND_PRODUCER = 4,\n\tSPAN_KIND_CONSUMER = 5,\n}\n\nexport interface SpanEvent {\n\ttimeUnixNano: string;\n\tname: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\nexport interface SpanLink {\n\ttraceId: string;\n\tspanId: string;\n\ttraceState?: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tflags?: number;\n}\n\nexport interface SpanStatus {\n\tmessage?: string;\n\tcode?: SpanStatusCode;\n}\n\nexport enum SpanStatusCode {\n\tSTATUS_CODE_UNSET = 0,\n\tSTATUS_CODE_OK = 1,\n\tSTATUS_CODE_ERROR = 2,\n}\n\n// ============================================\n// Log Types\n// ============================================\n\n/**\n * Root message for log export\n */\nexport interface ExportLogsServiceRequest {\n\tresourceLogs?: ResourceLogs[];\n}\n\nexport interface ResourceLogs {\n\tresource?: Resource;\n\tscopeLogs?: ScopeLogs[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeLogs {\n\tscope?: InstrumentationScope;\n\tlogRecords?: LogRecord[];\n\tschemaUrl?: string;\n}\n\nexport interface LogRecord {\n\ttimeUnixNano?: string;\n\tobservedTimeUnixNano: string;\n\tseverityNumber?: SeverityNumber;\n\tseverityText?: string;\n\tbody?: AnyValue;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tflags?: number;\n\ttraceId?: string;\n\tspanId?: string;\n}\n\nexport enum SeverityNumber {\n\tSEVERITY_NUMBER_UNSPECIFIED = 0,\n\tSEVERITY_NUMBER_TRACE = 1,\n\tSEVERITY_NUMBER_TRACE2 = 2,\n\tSEVERITY_NUMBER_TRACE3 = 3,\n\tSEVERITY_NUMBER_TRACE4 = 4,\n\tSEVERITY_NUMBER_DEBUG = 5,\n\tSEVERITY_NUMBER_DEBUG2 = 6,\n\tSEVERITY_NUMBER_DEBUG3 = 7,\n\tSEVERITY_NUMBER_DEBUG4 = 8,\n\tSEVERITY_NUMBER_INFO = 9,\n\tSEVERITY_NUMBER_INFO2 = 10,\n\tSEVERITY_NUMBER_INFO3 = 11,\n\tSEVERITY_NUMBER_INFO4 = 12,\n\tSEVERITY_NUMBER_WARN = 13,\n\tSEVERITY_NUMBER_WARN2 = 14,\n\tSEVERITY_NUMBER_WARN3 = 15,\n\tSEVERITY_NUMBER_WARN4 = 16,\n\tSEVERITY_NUMBER_ERROR = 17,\n\tSEVERITY_NUMBER_ERROR2 = 18,\n\tSEVERITY_NUMBER_ERROR3 = 19,\n\tSEVERITY_NUMBER_ERROR4 = 20,\n\tSEVERITY_NUMBER_FATAL = 21,\n\tSEVERITY_NUMBER_FATAL2 = 22,\n\tSEVERITY_NUMBER_FATAL3 = 23,\n\tSEVERITY_NUMBER_FATAL4 = 24,\n}\n\n// ============================================\n// Metrics Types\n// ============================================\n\n/**\n * Root message for metrics export\n */\nexport interface ExportMetricsServiceRequest {\n\tresourceMetrics?: ResourceMetrics[];\n}\n\nexport interface ResourceMetrics {\n\tresource?: Resource;\n\tscopeMetrics?: ScopeMetrics[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeMetrics {\n\tscope?: InstrumentationScope;\n\tmetrics?: Metric[];\n\tschemaUrl?: string;\n}\n\nexport interface Metric {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tmetadata?: KeyValue[];\n\tgauge?: Gauge;\n\tsum?: Sum;\n\thistogram?: Histogram;\n\texponentialHistogram?: ExponentialHistogram;\n\tsummary?: Summary;\n}\n\nexport interface Gauge {\n\tdataPoints: NumberDataPoint[];\n}\n\nexport interface Sum {\n\tdataPoints: NumberDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n\tisMonotonic?: boolean;\n}\n\nexport interface Histogram {\n\tdataPoints: HistogramDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n}\n\nexport interface ExponentialHistogram {\n\tdataPoints: ExponentialHistogramDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n}\n\nexport interface Summary {\n\tdataPoints: SummaryDataPoint[];\n}\n\nexport enum AggregationTemporality {\n\tAGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n\tAGGREGATION_TEMPORALITY_DELTA = 1,\n\tAGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n}\n\nexport interface NumberDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tasDouble?: number;\n\tasInt?: string;\n\texemplars?: Exemplar[];\n\tflags?: number;\n}\n\nexport interface HistogramDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tbucketCounts?: string[];\n\texplicitBounds?: number[];\n\texemplars?: Exemplar[];\n\tflags?: number;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport interface ExponentialHistogramDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tscale?: number;\n\tzeroCount?: string;\n\tpositive?: Buckets;\n\tnegative?: Buckets;\n\tflags?: number;\n\texemplars?: Exemplar[];\n\tmin?: number;\n\tmax?: number;\n\tzeroThreshold?: number;\n}\n\nexport interface Buckets {\n\toffset?: number;\n\tbucketCounts?: string[];\n}\n\nexport interface SummaryDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tquantileValues?: ValueAtQuantile[];\n\tflags?: number;\n}\n\nexport interface ValueAtQuantile {\n\tquantile: number;\n\tvalue: number;\n}\n\nexport interface Exemplar {\n\tfilteredAttributes?: KeyValue[];\n\ttimeUnixNano: string;\n\tasDouble?: number;\n\tasInt?: string;\n\tspanId?: string;\n\ttraceId?: string;\n}\n\n// ============================================\n// Response Types\n// ============================================\n\nexport interface ExportTraceServiceResponse {\n\tpartialSuccess?: ExportTracePartialSuccess;\n}\n\nexport interface ExportTracePartialSuccess {\n\trejectedSpans?: string;\n\terrorMessage?: string;\n}\n\nexport interface ExportLogsServiceResponse {\n\tpartialSuccess?: ExportLogsPartialSuccess;\n}\n\nexport interface ExportLogsPartialSuccess {\n\trejectedLogRecords?: string;\n\terrorMessage?: string;\n}\n\nexport interface ExportMetricsServiceResponse {\n\tpartialSuccess?: ExportMetricsPartialSuccess;\n}\n\nexport interface ExportMetricsPartialSuccess {\n\trejectedDataPoints?: string;\n\terrorMessage?: string;\n}\n"],"mappings":";AAmGA,IAAY,gDAAL;AACN;AACA;AACA;AACA;AACA;AACA;;AACA;AAuBD,IAAY,4DAAL;AACN;AACA;AACA;;AACA;AAsCD,IAAY,4DAAL;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AA6DD,IAAY,4EAAL;AACN;AACA;AACA;;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-Dsh-DIO_.cjs","names":[],"sources":["../src/otlp/types.ts"],"sourcesContent":["/**\n * OTLP JSON types based on OpenTelemetry Protocol specification.\n * These types represent the JSON encoding of OTLP protobuf messages.\n * @see https://opentelemetry.io/docs/specs/otlp/\n */\n\n// ============================================\n// Common Types\n// ============================================\n\n/**\n * Key-value pair for attributes\n */\nexport interface KeyValue {\n\tkey: string;\n\tvalue: AnyValue;\n}\n\n/**\n * Any value type (string, bool, int, double, array, kvlist, bytes)\n */\nexport interface AnyValue {\n\tstringValue?: string;\n\tboolValue?: boolean;\n\tintValue?: string; // int64 as string\n\tdoubleValue?: number;\n\tarrayValue?: ArrayValue;\n\tkvlistValue?: KeyValueList;\n\tbytesValue?: string; // base64 encoded\n}\n\nexport interface ArrayValue {\n\tvalues: AnyValue[];\n}\n\nexport interface KeyValueList {\n\tvalues: KeyValue[];\n}\n\n/**\n * Resource represents the entity producing telemetry\n */\nexport interface Resource {\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\n/**\n * InstrumentationScope represents the instrumentation library\n */\nexport interface InstrumentationScope {\n\tname: string;\n\tversion?: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\n// ============================================\n// Trace Types\n// ============================================\n\n/**\n * Root message for trace export\n */\nexport interface ExportTraceServiceRequest {\n\tresourceSpans?: ResourceSpans[];\n}\n\nexport interface ResourceSpans {\n\tresource?: Resource;\n\tscopeSpans?: ScopeSpans[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeSpans {\n\tscope?: InstrumentationScope;\n\tspans?: Span[];\n\tschemaUrl?: string;\n}\n\nexport interface Span {\n\ttraceId: string; // hex encoded 16 bytes\n\tspanId: string; // hex encoded 8 bytes\n\ttraceState?: string;\n\tparentSpanId?: string; // hex encoded 8 bytes\n\tflags?: number;\n\tname: string;\n\tkind?: SpanKind;\n\tstartTimeUnixNano: string; // uint64 as string\n\tendTimeUnixNano: string; // uint64 as string\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tevents?: SpanEvent[];\n\tdroppedEventsCount?: number;\n\tlinks?: SpanLink[];\n\tdroppedLinksCount?: number;\n\tstatus?: SpanStatus;\n}\n\nexport enum SpanKind {\n\tSPAN_KIND_UNSPECIFIED = 0,\n\tSPAN_KIND_INTERNAL = 1,\n\tSPAN_KIND_SERVER = 2,\n\tSPAN_KIND_CLIENT = 3,\n\tSPAN_KIND_PRODUCER = 4,\n\tSPAN_KIND_CONSUMER = 5,\n}\n\nexport interface SpanEvent {\n\ttimeUnixNano: string;\n\tname: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n}\n\nexport interface SpanLink {\n\ttraceId: string;\n\tspanId: string;\n\ttraceState?: string;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tflags?: number;\n}\n\nexport interface SpanStatus {\n\tmessage?: string;\n\tcode?: SpanStatusCode;\n}\n\nexport enum SpanStatusCode {\n\tSTATUS_CODE_UNSET = 0,\n\tSTATUS_CODE_OK = 1,\n\tSTATUS_CODE_ERROR = 2,\n}\n\n// ============================================\n// Log Types\n// ============================================\n\n/**\n * Root message for log export\n */\nexport interface ExportLogsServiceRequest {\n\tresourceLogs?: ResourceLogs[];\n}\n\nexport interface ResourceLogs {\n\tresource?: Resource;\n\tscopeLogs?: ScopeLogs[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeLogs {\n\tscope?: InstrumentationScope;\n\tlogRecords?: LogRecord[];\n\tschemaUrl?: string;\n}\n\nexport interface LogRecord {\n\ttimeUnixNano?: string;\n\tobservedTimeUnixNano: string;\n\tseverityNumber?: SeverityNumber;\n\tseverityText?: string;\n\tbody?: AnyValue;\n\tattributes?: KeyValue[];\n\tdroppedAttributesCount?: number;\n\tflags?: number;\n\ttraceId?: string;\n\tspanId?: string;\n}\n\nexport enum SeverityNumber {\n\tSEVERITY_NUMBER_UNSPECIFIED = 0,\n\tSEVERITY_NUMBER_TRACE = 1,\n\tSEVERITY_NUMBER_TRACE2 = 2,\n\tSEVERITY_NUMBER_TRACE3 = 3,\n\tSEVERITY_NUMBER_TRACE4 = 4,\n\tSEVERITY_NUMBER_DEBUG = 5,\n\tSEVERITY_NUMBER_DEBUG2 = 6,\n\tSEVERITY_NUMBER_DEBUG3 = 7,\n\tSEVERITY_NUMBER_DEBUG4 = 8,\n\tSEVERITY_NUMBER_INFO = 9,\n\tSEVERITY_NUMBER_INFO2 = 10,\n\tSEVERITY_NUMBER_INFO3 = 11,\n\tSEVERITY_NUMBER_INFO4 = 12,\n\tSEVERITY_NUMBER_WARN = 13,\n\tSEVERITY_NUMBER_WARN2 = 14,\n\tSEVERITY_NUMBER_WARN3 = 15,\n\tSEVERITY_NUMBER_WARN4 = 16,\n\tSEVERITY_NUMBER_ERROR = 17,\n\tSEVERITY_NUMBER_ERROR2 = 18,\n\tSEVERITY_NUMBER_ERROR3 = 19,\n\tSEVERITY_NUMBER_ERROR4 = 20,\n\tSEVERITY_NUMBER_FATAL = 21,\n\tSEVERITY_NUMBER_FATAL2 = 22,\n\tSEVERITY_NUMBER_FATAL3 = 23,\n\tSEVERITY_NUMBER_FATAL4 = 24,\n}\n\n// ============================================\n// Metrics Types\n// ============================================\n\n/**\n * Root message for metrics export\n */\nexport interface ExportMetricsServiceRequest {\n\tresourceMetrics?: ResourceMetrics[];\n}\n\nexport interface ResourceMetrics {\n\tresource?: Resource;\n\tscopeMetrics?: ScopeMetrics[];\n\tschemaUrl?: string;\n}\n\nexport interface ScopeMetrics {\n\tscope?: InstrumentationScope;\n\tmetrics?: Metric[];\n\tschemaUrl?: string;\n}\n\nexport interface Metric {\n\tname: string;\n\tdescription?: string;\n\tunit?: string;\n\tmetadata?: KeyValue[];\n\tgauge?: Gauge;\n\tsum?: Sum;\n\thistogram?: Histogram;\n\texponentialHistogram?: ExponentialHistogram;\n\tsummary?: Summary;\n}\n\nexport interface Gauge {\n\tdataPoints: NumberDataPoint[];\n}\n\nexport interface Sum {\n\tdataPoints: NumberDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n\tisMonotonic?: boolean;\n}\n\nexport interface Histogram {\n\tdataPoints: HistogramDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n}\n\nexport interface ExponentialHistogram {\n\tdataPoints: ExponentialHistogramDataPoint[];\n\taggregationTemporality: AggregationTemporality;\n}\n\nexport interface Summary {\n\tdataPoints: SummaryDataPoint[];\n}\n\nexport enum AggregationTemporality {\n\tAGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n\tAGGREGATION_TEMPORALITY_DELTA = 1,\n\tAGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n}\n\nexport interface NumberDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tasDouble?: number;\n\tasInt?: string;\n\texemplars?: Exemplar[];\n\tflags?: number;\n}\n\nexport interface HistogramDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tbucketCounts?: string[];\n\texplicitBounds?: number[];\n\texemplars?: Exemplar[];\n\tflags?: number;\n\tmin?: number;\n\tmax?: number;\n}\n\nexport interface ExponentialHistogramDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tscale?: number;\n\tzeroCount?: string;\n\tpositive?: Buckets;\n\tnegative?: Buckets;\n\tflags?: number;\n\texemplars?: Exemplar[];\n\tmin?: number;\n\tmax?: number;\n\tzeroThreshold?: number;\n}\n\nexport interface Buckets {\n\toffset?: number;\n\tbucketCounts?: string[];\n}\n\nexport interface SummaryDataPoint {\n\tattributes?: KeyValue[];\n\tstartTimeUnixNano?: string;\n\ttimeUnixNano: string;\n\tcount: string;\n\tsum?: number;\n\tquantileValues?: ValueAtQuantile[];\n\tflags?: number;\n}\n\nexport interface ValueAtQuantile {\n\tquantile: number;\n\tvalue: number;\n}\n\nexport interface Exemplar {\n\tfilteredAttributes?: KeyValue[];\n\ttimeUnixNano: string;\n\tasDouble?: number;\n\tasInt?: string;\n\tspanId?: string;\n\ttraceId?: string;\n}\n\n// ============================================\n// Response Types\n// ============================================\n\nexport interface ExportTraceServiceResponse {\n\tpartialSuccess?: ExportTracePartialSuccess;\n}\n\nexport interface ExportTracePartialSuccess {\n\trejectedSpans?: string;\n\terrorMessage?: string;\n}\n\nexport interface ExportLogsServiceResponse {\n\tpartialSuccess?: ExportLogsPartialSuccess;\n}\n\nexport interface ExportLogsPartialSuccess {\n\trejectedLogRecords?: string;\n\terrorMessage?: string;\n}\n\nexport interface ExportMetricsServiceResponse {\n\tpartialSuccess?: ExportMetricsPartialSuccess;\n}\n\nexport interface ExportMetricsPartialSuccess {\n\trejectedDataPoints?: string;\n\terrorMessage?: string;\n}\n"],"mappings":";;AAmGA,IAAY,gDAAL;AACN;AACA;AACA;AACA;AACA;AACA;;AACA;AAuBD,IAAY,4DAAL;AACN;AACA;AACA;;AACA;AAsCD,IAAY,4DAAL;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AA6DD,IAAY,4EAAL;AACN;AACA;AACA;;AACA"}
|
package/package.json
CHANGED
|
@@ -1,78 +1,148 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/telescope",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Laravel Telescope-style debugging and monitoring for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"import": {
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"default": "./dist/index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./dist/index.d.cts",
|
|
14
|
+
"default": "./dist/index.cjs"
|
|
15
|
+
}
|
|
11
16
|
},
|
|
12
17
|
"./storage/memory": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/storage/memory.d.mts",
|
|
20
|
+
"default": "./dist/storage/memory.mjs"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/storage/memory.d.cts",
|
|
24
|
+
"default": "./dist/storage/memory.cjs"
|
|
25
|
+
}
|
|
16
26
|
},
|
|
17
27
|
"./storage/kysely": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/storage/kysely.d.mts",
|
|
30
|
+
"default": "./dist/storage/kysely.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/storage/kysely.d.cts",
|
|
34
|
+
"default": "./dist/storage/kysely.cjs"
|
|
35
|
+
}
|
|
21
36
|
},
|
|
22
37
|
"./server/hono": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
"import": {
|
|
39
|
+
"types": "./dist/server/hono.d.mts",
|
|
40
|
+
"default": "./dist/server/hono.mjs"
|
|
41
|
+
},
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/server/hono.d.cts",
|
|
44
|
+
"default": "./dist/server/hono.cjs"
|
|
45
|
+
}
|
|
26
46
|
},
|
|
27
47
|
"./hono": {
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
"import": {
|
|
49
|
+
"types": "./dist/server/hono.d.mts",
|
|
50
|
+
"default": "./dist/server/hono.mjs"
|
|
51
|
+
},
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./dist/server/hono.d.cts",
|
|
54
|
+
"default": "./dist/server/hono.cjs"
|
|
55
|
+
}
|
|
31
56
|
},
|
|
32
57
|
"./logger/pino": {
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
58
|
+
"import": {
|
|
59
|
+
"types": "./dist/logger/pino.d.mts",
|
|
60
|
+
"default": "./dist/logger/pino.mjs"
|
|
61
|
+
},
|
|
62
|
+
"require": {
|
|
63
|
+
"types": "./dist/logger/pino.d.cts",
|
|
64
|
+
"default": "./dist/logger/pino.cjs"
|
|
65
|
+
}
|
|
36
66
|
},
|
|
37
67
|
"./logger/console": {
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
68
|
+
"import": {
|
|
69
|
+
"types": "./dist/logger/console.d.mts",
|
|
70
|
+
"default": "./dist/logger/console.mjs"
|
|
71
|
+
},
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./dist/logger/console.d.cts",
|
|
74
|
+
"default": "./dist/logger/console.cjs"
|
|
75
|
+
}
|
|
41
76
|
},
|
|
42
77
|
"./metrics": {
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
78
|
+
"import": {
|
|
79
|
+
"types": "./dist/metrics/index.d.mts",
|
|
80
|
+
"default": "./dist/metrics/index.mjs"
|
|
81
|
+
},
|
|
82
|
+
"require": {
|
|
83
|
+
"types": "./dist/metrics/index.d.cts",
|
|
84
|
+
"default": "./dist/metrics/index.cjs"
|
|
85
|
+
}
|
|
46
86
|
},
|
|
47
87
|
"./otlp": {
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./dist/otlp/index.d.mts",
|
|
90
|
+
"default": "./dist/otlp/index.mjs"
|
|
91
|
+
},
|
|
92
|
+
"require": {
|
|
93
|
+
"types": "./dist/otlp/index.d.cts",
|
|
94
|
+
"default": "./dist/otlp/index.cjs"
|
|
95
|
+
}
|
|
51
96
|
},
|
|
52
97
|
"./otlp/hono": {
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/otlp/hono.d.mts",
|
|
100
|
+
"default": "./dist/otlp/hono.mjs"
|
|
101
|
+
},
|
|
102
|
+
"require": {
|
|
103
|
+
"types": "./dist/otlp/hono.d.cts",
|
|
104
|
+
"default": "./dist/otlp/hono.cjs"
|
|
105
|
+
}
|
|
56
106
|
},
|
|
57
107
|
"./instrumentation": {
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
108
|
+
"import": {
|
|
109
|
+
"types": "./dist/instrumentation/index.d.mts",
|
|
110
|
+
"default": "./dist/instrumentation/index.mjs"
|
|
111
|
+
},
|
|
112
|
+
"require": {
|
|
113
|
+
"types": "./dist/instrumentation/index.d.cts",
|
|
114
|
+
"default": "./dist/instrumentation/index.cjs"
|
|
115
|
+
}
|
|
61
116
|
},
|
|
62
117
|
"./instrumentation/hono": {
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
118
|
+
"import": {
|
|
119
|
+
"types": "./dist/instrumentation/hono.d.mts",
|
|
120
|
+
"default": "./dist/instrumentation/hono.mjs"
|
|
121
|
+
},
|
|
122
|
+
"require": {
|
|
123
|
+
"types": "./dist/instrumentation/hono.d.cts",
|
|
124
|
+
"default": "./dist/instrumentation/hono.cjs"
|
|
125
|
+
}
|
|
66
126
|
},
|
|
67
127
|
"./core": {
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
128
|
+
"import": {
|
|
129
|
+
"types": "./dist/core.d.mts",
|
|
130
|
+
"default": "./dist/core.mjs"
|
|
131
|
+
},
|
|
132
|
+
"require": {
|
|
133
|
+
"types": "./dist/core.d.cts",
|
|
134
|
+
"default": "./dist/core.cjs"
|
|
135
|
+
}
|
|
71
136
|
},
|
|
72
137
|
"./lambda": {
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
138
|
+
"import": {
|
|
139
|
+
"types": "./dist/adapters/lambda.d.mts",
|
|
140
|
+
"default": "./dist/adapters/lambda.mjs"
|
|
141
|
+
},
|
|
142
|
+
"require": {
|
|
143
|
+
"types": "./dist/adapters/lambda.d.cts",
|
|
144
|
+
"default": "./dist/adapters/lambda.cjs"
|
|
145
|
+
}
|
|
76
146
|
}
|
|
77
147
|
},
|
|
78
148
|
"repository": {
|
|
@@ -105,7 +175,7 @@
|
|
|
105
175
|
"kysely": "^0.28.0",
|
|
106
176
|
"pino": "^9.0.0",
|
|
107
177
|
"pino-abstract-transport": "^2.0.0 || ^3.0.0",
|
|
108
|
-
"@geekmidas/logger": "^1.0.
|
|
178
|
+
"@geekmidas/logger": "^1.0.2"
|
|
109
179
|
},
|
|
110
180
|
"peerDependenciesMeta": {
|
|
111
181
|
"@geekmidas/logger": {
|
|
@@ -181,7 +251,7 @@
|
|
|
181
251
|
"kysely": "~0.28.2",
|
|
182
252
|
"pino": "^9.6.0",
|
|
183
253
|
"pino-abstract-transport": "~3.0.0",
|
|
184
|
-
"@geekmidas/logger": "^1.0.
|
|
254
|
+
"@geekmidas/logger": "^1.0.2"
|
|
185
255
|
},
|
|
186
256
|
"scripts": {
|
|
187
257
|
"build:ui": "pnpm --filter @geekmidas/telescope-ui build && tsx ../ui/scripts/embed-ui.ts dist/ui src/ui-assets.ts"
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.
|
|
13
|
+
export NODE_PATH="/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules/vite/bin/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.
|
|
15
|
+
export NODE_PATH="/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules/vite/bin/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/vite@6.3.5_@types+node@24.9.1_jiti@2.6.1_lightningcss@1.30.2_terser@5.43.1_tsx@4.20.6_yaml@2.8.2/node_modules:/home/runner/work/toolbox/toolbox/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|