autotel 4.2.3 → 4.2.5
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/LICENSE +191 -21
- package/README.md +1 -1
- package/dist/{attributes-CmYpdqCN.js → attributes-B7wix2VG.js} +2 -2
- package/dist/{attributes-CmYpdqCN.js.map → attributes-B7wix2VG.js.map} +1 -1
- package/dist/{attributes-PZ5doLgw.cjs → attributes-aDmJYral.cjs} +2 -2
- package/dist/{attributes-PZ5doLgw.cjs.map → attributes-aDmJYral.cjs.map} +1 -1
- package/dist/attributes.cjs +1 -1
- package/dist/attributes.js +1 -1
- package/dist/auto.cjs +3 -3
- package/dist/auto.js +1 -1
- package/dist/{canonical-log-line-processor--RlFDHhm.cjs → canonical-log-line-processor-CcrDi6TO.cjs} +2 -2
- package/dist/{canonical-log-line-processor--RlFDHhm.cjs.map → canonical-log-line-processor-CcrDi6TO.cjs.map} +1 -1
- package/dist/{canonical-log-line-processor-DbBQT5vY.js → canonical-log-line-processor-FLezvFCB.js} +2 -2
- package/dist/{canonical-log-line-processor-DbBQT5vY.js.map → canonical-log-line-processor-FLezvFCB.js.map} +1 -1
- package/dist/correlation-id.cjs +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/decorators.cjs +1 -1
- package/dist/decorators.js +1 -1
- package/dist/diagnostics.cjs +1 -1
- package/dist/drain-pipeline.cjs +8 -2
- package/dist/drain-pipeline.cjs.map +1 -1
- package/dist/drain-pipeline.js +8 -2
- package/dist/drain-pipeline.js.map +1 -1
- package/dist/{event-531asIM6.js → event-BEm5IJ8U.js} +3 -3
- package/dist/{event-531asIM6.js.map → event-BEm5IJ8U.js.map} +1 -1
- package/dist/{event-CcZYwp50.cjs → event-rzA1X5h3.cjs} +4 -4
- package/dist/{event-CcZYwp50.cjs.map → event-rzA1X5h3.cjs.map} +1 -1
- package/dist/event.cjs +1 -1
- package/dist/event.js +1 -1
- package/dist/{functional-C8B0Qa7o.cjs → functional-BCtxvYir.cjs} +9 -9
- package/dist/{functional-C8B0Qa7o.cjs.map → functional-BCtxvYir.cjs.map} +1 -1
- package/dist/{functional-r-AUIRy_.js → functional-CrAq8Az8.js} +4 -4
- package/dist/{functional-r-AUIRy_.js.map → functional-CrAq8Az8.js.map} +1 -1
- package/dist/functional.cjs +1 -1
- package/dist/functional.js +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.js +1 -1
- package/dist/index.cjs +17 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/{init-BS2JVkrL.js → init-BvBB45-T.js} +4 -4
- package/dist/{init-BS2JVkrL.js.map → init-BvBB45-T.js.map} +1 -1
- package/dist/{init-BXiuPK6j.cjs → init-BxJEJ9Tn.cjs} +5 -5
- package/dist/{init-BXiuPK6j.cjs.map → init-BxJEJ9Tn.cjs.map} +1 -1
- package/dist/instrumentation.cjs +4 -4
- package/dist/instrumentation.cjs.map +1 -1
- package/dist/instrumentation.js +3 -3
- package/dist/instrumentation.js.map +1 -1
- package/dist/logger-thMPLpOG.cjs +487 -0
- package/dist/logger-thMPLpOG.cjs.map +1 -0
- package/dist/logger.cjs +8 -236
- package/dist/messaging.cjs +1 -1
- package/dist/messaging.js +1 -1
- package/dist/{node-require-CZ_PU448.cjs → node-require-PFqDihze.cjs} +3 -3
- package/dist/{node-require-CZ_PU448.cjs.map → node-require-PFqDihze.cjs.map} +1 -1
- package/dist/{operation-context-D6LDf4W_.cjs → operation-context-hzKbTKnt.cjs} +3 -3
- package/dist/{operation-context-D6LDf4W_.cjs.map → operation-context-hzKbTKnt.cjs.map} +1 -1
- package/dist/processors.cjs +1 -1
- package/dist/processors.js +1 -1
- package/dist/register.cjs +2 -2
- package/dist/semantic-helpers.cjs +1 -1
- package/dist/semantic-helpers.js +1 -1
- package/dist/{stable-hash-brKISGf1.cjs → stable-hash-CS9BxvVQ.cjs} +3 -3
- package/dist/{stable-hash-brKISGf1.cjs.map → stable-hash-CS9BxvVQ.cjs.map} +1 -1
- package/dist/testing.cjs +4 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +4 -2
- package/dist/testing.js.map +1 -1
- package/dist/trace-helpers.cjs +1 -1
- package/dist/{track-COUuU48p.js → track-D7O7oIZa.js} +9 -5
- package/dist/{track-COUuU48p.js.map → track-D7O7oIZa.js.map} +1 -1
- package/dist/{track-Cb3Q4QmS.cjs → track-eovhCJ-I.cjs} +11 -7
- package/dist/{track-Cb3Q4QmS.cjs.map → track-eovhCJ-I.cjs.map} +1 -1
- package/dist/validate.cjs +1 -1
- package/dist/webhook.cjs +1 -1
- package/dist/webhook.js +1 -1
- package/dist/workflow-distributed.cjs +1 -1
- package/dist/workflow-distributed.js +1 -1
- package/dist/workflow.cjs +3 -3
- package/dist/workflow.js +1 -1
- package/dist/yaml-config.cjs +4 -4
- package/package.json +41 -41
- package/dist/logger.cjs.map +0 -1
- /package/dist/{chunk-C_NdSu1c.cjs → rolldown-runtime-C_NdSu1c.cjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes-PZ5doLgw.cjs","names":["UserAttributes","SessionAttributes","DeviceAttributes","HTTPAttributes","DBAttributes","ServiceAttributes","NetworkAttributes","ServerAddressAttributes","URLAttributes","ErrorAttributes","ExceptionAttributes","ProcessAttributes","ThreadAttributes","ContainerAttributes","K8sAttributes","CloudAttributes","FaaSAttributes","FeatureFlagAttributes","MessagingAttributes","RPCAttributes","GraphQLAttributes","OTelAttributes","CodeAttributes","TLSAttributes","REDACTOR_PATTERNS"],"sources":["../src/attributes/builders.ts","../src/attributes/validators.ts","../src/attributes/utils.ts","../src/attributes/attachers.ts","../src/attributes/domains.ts"],"sourcesContent":["/**\n * Attribute builders for constructing OpenTelemetry attributes\n * Provides both key builders (Pattern A) and object builders (Pattern B)\n *\n * @example Pattern A: Key builders\n * ```typescript\n * attrs.user.id('123') // { 'user.id': '123' }\n * attrs.user.email('user@example.com') // { 'user.email': 'user@example.com' }\n * attrs.http.request.method('GET') // { 'http.request.method': 'GET' }\n * attrs.http.response.statusCode(200) // { 'http.response.status_code': 200 }\n * ```\n *\n * @example Pattern B: Object builders\n * ```typescript\n * attrs.user({ id: '123', email: 'user@example.com' })\n * attrs.http.server({ method: 'GET', route: '/users/:id', statusCode: 200 })\n * attrs.db.client({ system: 'postgresql', operation: 'SELECT', collectionName: 'users' })\n * ```\n */\n\nimport {\n UserAttributes,\n SessionAttributes,\n DeviceAttributes,\n HTTPAttributes,\n DBAttributes,\n ServiceAttributes,\n NetworkAttributes,\n ServerAddressAttributes,\n URLAttributes,\n ErrorAttributes,\n ExceptionAttributes,\n ProcessAttributes,\n ThreadAttributes,\n ContainerAttributes,\n K8sAttributes,\n CloudAttributes,\n FaaSAttributes,\n FeatureFlagAttributes,\n MessagingAttributes,\n RPCAttributes,\n GraphQLAttributes,\n OTelAttributes,\n CodeAttributes,\n TLSAttributes,\n} from './registry';\n\nimport type {\n UserAttrs,\n SessionAttrs,\n DeviceAttrs,\n HTTPServerAttrs,\n HTTPClientAttrs,\n DBAttrs,\n ServiceAttrs,\n NetworkAttrs,\n ErrorAttrs,\n MessagingAttrs,\n CloudAttrs,\n ServerAddressAttrs,\n URLAttrs,\n ProcessAttrs,\n ContainerAttrs,\n ExceptionAttrs,\n} from './types';\n\nexport const attrs = {\n user: {\n id: (value: string) => ({ [UserAttributes.id]: value }),\n email: (value: string) => ({ [UserAttributes.email]: value }),\n name: (value: string) => ({ [UserAttributes.name]: value }),\n fullName: (value: string) => ({ [UserAttributes.fullName]: value }),\n hash: (value: string) => ({ [UserAttributes.hash]: value }),\n roles: (value: string[]) => ({ [UserAttributes.roles]: value }),\n\n data: (data: UserAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[UserAttributes.id] = data.id;\n if (data.email !== undefined) result[UserAttributes.email] = data.email;\n if (data.name !== undefined) result[UserAttributes.name] = data.name;\n if (data.fullName !== undefined)\n result[UserAttributes.fullName] = data.fullName;\n if (data.hash !== undefined) result[UserAttributes.hash] = data.hash;\n if (data.roles !== undefined) result[UserAttributes.roles] = data.roles;\n return result;\n },\n },\n\n session: {\n id: (value: string) => ({ [SessionAttributes.id]: value }),\n previousId: (value: string) => ({ [SessionAttributes.previousId]: value }),\n\n data: (data: SessionAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[SessionAttributes.id] = data.id;\n if (data.previousId !== undefined)\n result[SessionAttributes.previousId] = data.previousId;\n return result;\n },\n },\n\n device: {\n id: (value: string) => ({ [DeviceAttributes.id]: value }),\n manufacturer: (value: string) => ({\n [DeviceAttributes.manufacturer]: value,\n }),\n modelIdentifier: (value: string) => ({\n [DeviceAttributes.modelIdentifier]: value,\n }),\n modelName: (value: string) => ({ [DeviceAttributes.modelName]: value }),\n\n data: (data: DeviceAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[DeviceAttributes.id] = data.id;\n if (data.manufacturer !== undefined)\n result[DeviceAttributes.manufacturer] = data.manufacturer;\n if (data.modelIdentifier !== undefined)\n result[DeviceAttributes.modelIdentifier] = data.modelIdentifier;\n if (data.modelName !== undefined)\n result[DeviceAttributes.modelName] = data.modelName;\n return result;\n },\n },\n\n http: {\n request: {\n method: (value: string) => ({ [HTTPAttributes.requestMethod]: value }),\n methodOriginal: (value: string) => ({\n [HTTPAttributes.requestMethodOriginal]: value,\n }),\n resendCount: (value: number) => ({\n [HTTPAttributes.requestResendCount]: value,\n }),\n size: (value: number) => ({ [HTTPAttributes.requestSize]: value }),\n bodySize: (value: number) => ({\n [HTTPAttributes.requestBodySize]: value,\n }),\n },\n\n response: {\n statusCode: (value: number) => ({\n [HTTPAttributes.responseStatusCode]: value,\n }),\n size: (value: number) => ({ [HTTPAttributes.responseSize]: value }),\n bodySize: (value: number) => ({\n [HTTPAttributes.responseBodySize]: value,\n }),\n },\n\n route: (value: string) => ({ [HTTPAttributes.route]: value }),\n connectionState: (value: string) => ({\n [HTTPAttributes.connectionState]: value,\n }),\n\n server: (data: HTTPServerAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.method !== undefined)\n result[HTTPAttributes.requestMethod] = data.method;\n if (data.route !== undefined) result[HTTPAttributes.route] = data.route;\n if (data.statusCode !== undefined)\n result[HTTPAttributes.responseStatusCode] = data.statusCode;\n if (data.bodySize !== undefined)\n result[HTTPAttributes.requestBodySize] = data.bodySize;\n if (data.requestSize !== undefined)\n result[HTTPAttributes.requestSize] = data.requestSize;\n if (data.responseSize !== undefined)\n result[HTTPAttributes.responseSize] = data.responseSize;\n if (data.resendCount !== undefined)\n result[HTTPAttributes.requestResendCount] = data.resendCount;\n return result;\n },\n\n client: (data: HTTPClientAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.method !== undefined)\n result[HTTPAttributes.requestMethod] = data.method;\n if (data.url !== undefined) result[HTTPAttributes.route] = data.url;\n if (data.statusCode !== undefined)\n result[HTTPAttributes.responseStatusCode] = data.statusCode;\n return result;\n },\n },\n\n db: {\n client: {\n system: (value: string) => ({ [DBAttributes.systemName]: value }),\n operation: (value: string) => ({ [DBAttributes.operationName]: value }),\n collectionName: (value: string) => ({\n [DBAttributes.collectionName]: value,\n }),\n namespace: (value: string) => ({ [DBAttributes.namespace]: value }),\n statement: (value: string) => ({ [DBAttributes.statement]: value }),\n querySummary: (value: string) => ({ [DBAttributes.querySummary]: value }),\n queryText: (value: string) => ({ [DBAttributes.queryText]: value }),\n responseStatus: (value: string | number) => ({\n [DBAttributes.responseStatusCode]: value,\n }),\n rowsReturned: (value: number) => ({\n [DBAttributes.responseReturnedRows]: value,\n }),\n\n data: (data: DBAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.system !== undefined)\n result[DBAttributes.systemName] = data.system;\n if (data.operation !== undefined)\n result[DBAttributes.operationName] = data.operation;\n if (data.collectionName !== undefined)\n result[DBAttributes.collectionName] = data.collectionName;\n // 'name' maps to db.namespace (db.name is deprecated per OTel semantic conventions)\n if (data.name !== undefined) result[DBAttributes.namespace] = data.name;\n // 'namespace' takes precedence over 'name' if both are provided\n if (data.namespace !== undefined)\n result[DBAttributes.namespace] = data.namespace;\n if (data.statement !== undefined)\n result[DBAttributes.statement] = data.statement;\n if (data.querySummary !== undefined)\n result[DBAttributes.querySummary] = data.querySummary;\n if (data.queryText !== undefined)\n result[DBAttributes.queryText] = data.queryText;\n if (data.responseStatus !== undefined)\n result[DBAttributes.responseStatusCode] = data.responseStatus;\n if (data.rowsReturned !== undefined)\n result[DBAttributes.responseReturnedRows] = data.rowsReturned;\n return result;\n },\n },\n },\n\n service: {\n name: (value: string) => ({ [ServiceAttributes.name]: value }),\n instance: (value: string) => ({ [ServiceAttributes.instance]: value }),\n version: (value: string) => ({ [ServiceAttributes.version]: value }),\n\n data: (data: ServiceAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.name !== undefined) result[ServiceAttributes.name] = data.name;\n if (data.instance !== undefined)\n result[ServiceAttributes.instance] = data.instance;\n if (data.version !== undefined)\n result[ServiceAttributes.version] = data.version;\n return result;\n },\n },\n\n network: {\n peerAddress: (value: string) => ({\n [NetworkAttributes.peerAddress]: value,\n }),\n peerPort: (value: number) => ({ [NetworkAttributes.peerPort]: value }),\n transport: (value: string) => ({ [NetworkAttributes.transport]: value }),\n protocolName: (value: string) => ({\n [NetworkAttributes.protocolName]: value,\n }),\n protocolVersion: (value: string) => ({\n [NetworkAttributes.protocolVersion]: value,\n }),\n\n data: (data: NetworkAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.peerAddress !== undefined)\n result[NetworkAttributes.peerAddress] = data.peerAddress;\n if (data.peerPort !== undefined)\n result[NetworkAttributes.peerPort] = data.peerPort;\n if (data.transport !== undefined)\n result[NetworkAttributes.transport] = data.transport;\n if (data.protocolName !== undefined)\n result[NetworkAttributes.protocolName] = data.protocolName;\n if (data.protocolVersion !== undefined)\n result[NetworkAttributes.protocolVersion] = data.protocolVersion;\n return result;\n },\n },\n\n server: {\n address: (value: string) => ({ [ServerAddressAttributes.address]: value }),\n port: (value: number) => ({ [ServerAddressAttributes.port]: value }),\n socketAddress: (value: string) => ({\n [ServerAddressAttributes.socketAddress]: value,\n }),\n\n data: (data: ServerAddressAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.address !== undefined)\n result[ServerAddressAttributes.address] = data.address;\n if (data.port !== undefined)\n result[ServerAddressAttributes.port] = data.port;\n if (data.socketAddress !== undefined)\n result[ServerAddressAttributes.socketAddress] = data.socketAddress;\n return result;\n },\n },\n\n url: {\n scheme: (value: string) => ({ [URLAttributes.scheme]: value }),\n full: (value: string) => ({ [URLAttributes.full]: value }),\n path: (value: string) => ({ [URLAttributes.path]: value }),\n query: (value: string) => ({ [URLAttributes.query]: value }),\n fragment: (value: string) => ({ [URLAttributes.fragment]: value }),\n\n data: (data: URLAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.scheme !== undefined) result[URLAttributes.scheme] = data.scheme;\n if (data.full !== undefined) result[URLAttributes.full] = data.full;\n if (data.path !== undefined) result[URLAttributes.path] = data.path;\n if (data.query !== undefined) result[URLAttributes.query] = data.query;\n if (data.fragment !== undefined)\n result[URLAttributes.fragment] = data.fragment;\n return result;\n },\n },\n\n error: {\n type: (value: string) => ({ [ErrorAttributes.type]: value }),\n message: (value: string) => ({ [ErrorAttributes.message]: value }),\n stackTrace: (value: string) => ({ [ErrorAttributes.stackTrace]: value }),\n code: (value: string | number) => ({ [ErrorAttributes.code]: value }),\n\n data: (data: ErrorAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.type !== undefined) result[ErrorAttributes.type] = data.type;\n if (data.message !== undefined)\n result[ErrorAttributes.message] = data.message;\n if (data.stackTrace !== undefined)\n result[ErrorAttributes.stackTrace] = data.stackTrace;\n if (data.code !== undefined) result[ErrorAttributes.code] = data.code;\n return result;\n },\n },\n\n exception: {\n escaped: (value: boolean) => ({ [ExceptionAttributes.escaped]: value }),\n message: (value: string) => ({ [ExceptionAttributes.message]: value }),\n stackTrace: (value: string) => ({\n [ExceptionAttributes.stackTrace]: value,\n }),\n type: (value: string) => ({ [ExceptionAttributes.type]: value }),\n moduleName: (value: string) => ({\n [ExceptionAttributes.moduleName]: value,\n }),\n\n data: (data: ExceptionAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.escaped !== undefined)\n result[ExceptionAttributes.escaped] = data.escaped;\n if (data.message !== undefined)\n result[ExceptionAttributes.message] = data.message;\n if (data.stackTrace !== undefined)\n result[ExceptionAttributes.stackTrace] = data.stackTrace;\n if (data.type !== undefined) result[ExceptionAttributes.type] = data.type;\n if (data.moduleName !== undefined)\n result[ExceptionAttributes.moduleName] = data.moduleName;\n return result;\n },\n },\n\n process: {\n pid: (value: number) => ({ [ProcessAttributes.pid]: value }),\n executablePath: (value: string) => ({\n [ProcessAttributes.executablePath]: value,\n }),\n command: (value: string) => ({ [ProcessAttributes.command]: value }),\n owner: (value: string) => ({ [ProcessAttributes.owner]: value }),\n\n data: (data: ProcessAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.pid !== undefined) result[ProcessAttributes.pid] = data.pid;\n if (data.executablePath !== undefined)\n result[ProcessAttributes.executablePath] = data.executablePath;\n if (data.command !== undefined)\n result[ProcessAttributes.command] = data.command;\n if (data.owner !== undefined)\n result[ProcessAttributes.owner] = data.owner;\n return result;\n },\n },\n\n thread: {\n id: (value: number) => ({ [ThreadAttributes.id]: value }),\n name: (value: string) => ({ [ThreadAttributes.name]: value }),\n },\n\n container: {\n id: (value: string) => ({ [ContainerAttributes.id]: value }),\n name: (value: string) => ({ [ContainerAttributes.name]: value }),\n image: (value: string) => ({ [ContainerAttributes.image]: value }),\n tag: (value: string) => ({ [ContainerAttributes.tag]: value }),\n\n data: (data: ContainerAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[ContainerAttributes.id] = data.id;\n if (data.name !== undefined) result[ContainerAttributes.name] = data.name;\n if (data.image !== undefined)\n result[ContainerAttributes.image] = data.image;\n if (data.tag !== undefined) result[ContainerAttributes.tag] = data.tag;\n return result;\n },\n },\n\n k8s: {\n podName: (value: string) => ({ [K8sAttributes.podName]: value }),\n namespaceName: (value: string) => ({\n [K8sAttributes.namespaceName]: value,\n }),\n deploymentName: (value: string) => ({\n [K8sAttributes.deploymentName]: value,\n }),\n state: (value: string) => ({ [K8sAttributes.state]: value }),\n },\n\n cloud: {\n provider: (value: string) => ({ [CloudAttributes.provider]: value }),\n accountId: (value: string) => ({ [CloudAttributes.accountId]: value }),\n region: (value: string) => ({ [CloudAttributes.region]: value }),\n availabilityZone: (value: string) => ({\n [CloudAttributes.availabilityZone]: value,\n }),\n platform: (value: string) => ({ [CloudAttributes.platform]: value }),\n\n data: (data: CloudAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.provider !== undefined)\n result[CloudAttributes.provider] = data.provider;\n if (data.accountId !== undefined)\n result[CloudAttributes.accountId] = data.accountId;\n if (data.region !== undefined)\n result[CloudAttributes.region] = data.region;\n if (data.availabilityZone !== undefined)\n result[CloudAttributes.availabilityZone] = data.availabilityZone;\n if (data.platform !== undefined)\n result[CloudAttributes.platform] = data.platform;\n return result;\n },\n },\n\n faas: {\n name: (value: string) => ({ [FaaSAttributes.name]: value }),\n version: (value: string) => ({ [FaaSAttributes.version]: value }),\n instance: (value: string) => ({ [FaaSAttributes.instance]: value }),\n execution: (value: string) => ({ [FaaSAttributes.execution]: value }),\n coldstart: (value: boolean) => ({ [FaaSAttributes.coldstart]: value }),\n },\n\n featureFlag: {\n key: (value: string) => ({ [FeatureFlagAttributes.key]: value }),\n provider: (value: string) => ({ [FeatureFlagAttributes.provider]: value }),\n variant: (value: string) => ({ [FeatureFlagAttributes.variant]: value }),\n },\n\n messaging: {\n system: (value: string) => ({ [MessagingAttributes.system]: value }),\n destination: (value: string) => ({\n [MessagingAttributes.destination]: value,\n }),\n operation: (value: 'publish' | 'receive' | 'process') => ({\n [MessagingAttributes.operation]: value,\n }),\n messageId: (value: string) => ({ [MessagingAttributes.messageId]: value }),\n conversationId: (value: string) => ({\n [MessagingAttributes.conversationId]: value,\n }),\n\n data: (data: MessagingAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.system !== undefined)\n result[MessagingAttributes.system] = data.system;\n if (data.destination !== undefined)\n result[MessagingAttributes.destination] = data.destination;\n if (data.operation !== undefined)\n result[MessagingAttributes.operation] = data.operation;\n if (data.messageId !== undefined)\n result[MessagingAttributes.messageId] = data.messageId;\n if (data.conversationId !== undefined)\n result[MessagingAttributes.conversationId] = data.conversationId;\n return result;\n },\n },\n\n // GenAI/LLM attribute builders moved to the `autotel-genai` package\n // (canonical `gen_ai.*` semantic conventions).\n\n rpc: {\n system: (value: string) => ({ [RPCAttributes.system]: value }),\n service: (value: string) => ({ [RPCAttributes.service]: value }),\n method: (value: string) => ({ [RPCAttributes.method]: value }),\n grpcStatusCode: (value: number) => ({\n [RPCAttributes.grpcStatusCode]: value,\n }),\n },\n\n graphql: {\n document: (value: string) => ({ [GraphQLAttributes.document]: value }),\n operationName: (value: string) => ({\n [GraphQLAttributes.operationName]: value,\n }),\n operationType: (value: 'query' | 'mutation' | 'subscription') => ({\n [GraphQLAttributes.operationType]: value,\n }),\n },\n\n otel: {\n libraryName: (value: string) => ({ [OTelAttributes.libraryName]: value }),\n libraryVersion: (value: string) => ({\n [OTelAttributes.libraryVersion]: value,\n }),\n statusCode: (value: string) => ({ [OTelAttributes.statusCode]: value }),\n },\n\n code: {\n namespace: (value: string) => ({ [CodeAttributes.namespace]: value }),\n filepath: (value: string) => ({ [CodeAttributes.filepath]: value }),\n function: (value: string) => ({ [CodeAttributes.function]: value }),\n class: (value: string) => ({ [CodeAttributes.class]: value }),\n method: (value: string) => ({ [CodeAttributes.method]: value }),\n column: (value: string) => ({ [CodeAttributes.column]: value }),\n lineNumber: (value: number) => ({ [CodeAttributes.lineNumber]: value }),\n repository: (value: string) => ({ [CodeAttributes.repository]: value }),\n revision: (value: string) => ({ [CodeAttributes.revision]: value }),\n },\n\n tls: {\n protocolVersion: (value: string) => ({\n [TLSAttributes.protocolVersion]: value,\n }),\n cipher: (value: string) => ({ [TLSAttributes.cipher]: value }),\n curveName: (value: string) => ({ [TLSAttributes.curveName]: value }),\n resumed: (value: boolean) => ({ [TLSAttributes.resumed]: value }),\n },\n} as const;\n","/**\n * Attribute validation, PII detection, and guardrails\n * Provides safe-by-default attribute handling with configurable policies\n */\n\nimport { REDACTOR_PATTERNS } from '../attribute-redacting-processor';\n\nexport interface AttributeGuardrails {\n /** How to handle PII in attributes */\n pii?: 'allow' | 'redact' | 'hash' | 'block';\n\n /** Maximum length for attribute values */\n maxLength?: number;\n\n /** Validate enum values against known values */\n validateEnum?: boolean;\n\n /** Log warnings for deprecated attributes instead of throwing */\n warnDeprecated?: boolean;\n\n /** Custom deprecation warnings */\n deprecatedWarnings?: Record<string, string>;\n}\n\nexport interface AttributePolicy {\n guardrails?: AttributeGuardrails;\n /** Custom deprecation warnings for specific attributes */\n deprecatedWarnings?: Record<string, string>;\n}\n\nconst DEPRECATED_ATTRIBUTES = {\n 'enduser.id': 'user.id',\n 'enduser.role': 'user.roles',\n 'enduser.scope': undefined,\n 'http.method': 'http.request.method',\n 'http.host': 'server.address',\n 'http.status_code': 'http.response.status_code',\n 'http.target': 'url.path',\n 'http.url': 'url.full',\n 'http.user_agent': 'user_agent.original',\n 'http.flavor': 'network.protocol.name',\n 'http.scheme': 'url.scheme',\n 'http.server_name': 'server.address',\n 'db.name': 'db.namespace',\n 'db.operation': 'db.operation.name',\n 'db.statement': 'db.query.text',\n 'db.system': 'db.system.name',\n 'db.collection': 'db.collection.name',\n 'db.instance.id': undefined,\n 'db.jdbc.driver_classname': undefined,\n 'db.mssql.instance_name': 'mssql.instance.name',\n 'db.sql.table': 'db.collection.name',\n 'http.client_ip': 'client.address',\n 'user_agent.original': 'user_agent.original',\n} as const;\n\nconst HTTP_METHODS = new Set([\n 'GET',\n 'POST',\n 'PUT',\n 'DELETE',\n 'PATCH',\n 'HEAD',\n 'OPTIONS',\n 'TRACE',\n 'QUERY',\n '_OTHER',\n]);\n\nexport function validateAttribute(\n key: string,\n value: unknown,\n policy: AttributePolicy = {},\n): unknown {\n const { guardrails = {} } = policy;\n\n if (value === undefined || value === null) {\n return undefined;\n }\n\n // For non-string values that don't need transformation, preserve the original type\n if (typeof value !== 'string') {\n // PII checks only apply to strings\n // maxLength only applies to strings\n // validateEnum only applies to strings\n return value;\n }\n\n const stringValue = value;\n\n if (guardrails.pii) {\n const piiResult = applyPIIPolicy(key, stringValue, guardrails.pii);\n if (piiResult !== stringValue) {\n return piiResult;\n }\n }\n\n if (guardrails.maxLength && stringValue.length > guardrails.maxLength) {\n return truncateValue(key, stringValue, guardrails.maxLength);\n }\n\n if (guardrails.validateEnum && HTTP_METHODS.has(stringValue)) {\n const normalizedMethod = normalizeHTTPMethod(stringValue);\n if (normalizedMethod !== stringValue) {\n return normalizedMethod;\n }\n }\n\n return stringValue;\n}\n\nfunction applyPIIPolicy(\n key: string,\n value: string,\n pii: AttributeGuardrails['pii'],\n): string {\n if (pii === 'allow') {\n return value;\n }\n\n if (pii === 'redact') {\n return redactIfPII(key, value);\n }\n\n if (pii === 'hash') {\n return hashIfPII(key, value);\n }\n\n if (pii === 'block' && isPIIKey(key)) {\n throw new Error(\n `PII attribute \"${key}\" is blocked by guardrails. Use pii: \"allow\" to enable it.`,\n );\n }\n\n return value;\n}\n\nfunction isPIIKey(key: string): boolean {\n const piiKeyPatterns = [\n 'email',\n 'phone',\n 'ssn',\n 'credit_card',\n 'password',\n 'secret',\n 'token',\n 'api_key',\n 'authorization',\n ];\n const lowerKey = key.toLowerCase();\n return piiKeyPatterns.some((pattern) => lowerKey.includes(pattern));\n}\n\nfunction redactIfPII(key: string, value: string): string {\n if (isPIIKey(key)) {\n // REDACTOR_PATTERNS values are RegExp patterns\n for (const [, pattern] of Object.entries(REDACTOR_PATTERNS)) {\n if (pattern instanceof RegExp && pattern.test(value)) {\n return '[REDACTED]';\n }\n }\n // If no pattern matched but key is PII, still redact\n return '[REDACTED]';\n }\n return value;\n}\n\nfunction hashIfPII(key: string, value: string): string {\n if (!isPIIKey(key)) {\n return value;\n }\n\n // Use a simple but consistent hash that produces 32-char hex\n // FNV-1a hash variant producing 128-bit output (32 hex chars)\n const FNV_PRIME = 0x01_00_01_93;\n const FNV_OFFSET = 0x81_1c_9d_c5;\n\n // Generate 4 32-bit hashes to produce 32 hex chars\n const hashes: number[] = [];\n for (let round = 0; round < 4; round++) {\n let hash = FNV_OFFSET;\n for (let i = 0; i < value.length; i++) {\n hash ^= (value.codePointAt(i) ?? 0) + round;\n hash = Math.imul(hash, FNV_PRIME);\n }\n hashes.push(hash >>> 0); // Convert to unsigned\n }\n\n return `hash_${hashes.map((h) => h.toString(16).padStart(8, '0')).join('')}`;\n}\n\nfunction truncateValue(key: string, value: string, maxLength: number): string {\n if (value.length <= maxLength) {\n return value;\n }\n return value.slice(0, maxLength - 3) + '...';\n}\n\nfunction normalizeHTTPMethod(method: string): string {\n const upper = method.toUpperCase();\n if (HTTP_METHODS.has(upper)) {\n return upper;\n }\n return upper;\n}\n\nexport function checkDeprecatedAttribute(\n key: string,\n policy: AttributePolicy = {},\n): string | null {\n const { guardrails = {}, deprecatedWarnings = {} } = policy;\n const { warnDeprecated = true } = guardrails;\n\n if (!warnDeprecated) {\n return null;\n }\n\n // Check if the key exists in the deprecated attributes map\n const isDeprecated = key in DEPRECATED_ATTRIBUTES;\n if (isDeprecated) {\n const replacement =\n DEPRECATED_ATTRIBUTES[key as keyof typeof DEPRECATED_ATTRIBUTES];\n if (replacement === undefined) {\n // Deprecated with no replacement (e.g., enduser.scope)\n console.warn(\n `[autotel/attributes] Attribute \"${key}\" is deprecated and has no replacement. ` +\n `Remove or find a replacement in OpenTelemetry semantic conventions.`,\n );\n } else {\n // Deprecated with a known replacement\n console.warn(\n `[autotel/attributes] Attribute \"${key}\" is deprecated. Use \"${replacement}\" instead.`,\n );\n }\n }\n\n if (deprecatedWarnings[key]) {\n console.warn(`[autotel/attributes] ${deprecatedWarnings[key]}`);\n }\n\n const replacement =\n DEPRECATED_ATTRIBUTES[key as keyof typeof DEPRECATED_ATTRIBUTES];\n return replacement ?? null;\n}\n\nexport function autoRedactPII(\n attributes: Record<string, unknown>,\n policy: AttributePolicy = {},\n): Record<string, unknown> {\n const { guardrails = { pii: 'redact' } } = policy;\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n redacted[key] = validateAttribute(key, value, { guardrails });\n }\n return redacted;\n}\n\nexport function defaultGuardrails(): AttributeGuardrails {\n return {\n pii: 'redact',\n maxLength: 255,\n validateEnum: true,\n warnDeprecated: true,\n };\n}\n","/**\n * Attribute utility functions\n */\n\nimport type { AttributeValue } from '../trace-context';\nimport {\n validateAttribute,\n autoRedactPII,\n defaultGuardrails,\n checkDeprecatedAttribute,\n type AttributePolicy,\n} from './validators';\n\n// Type for objects that have setAttributes method (spans or contexts)\n// Using a generic parameter to accommodate different AttributeValue types\ntype AttributeSetter = {\n setAttributes: (attrs: Record<string, AttributeValue>) => void;\n};\n\nexport function mergeAttrs(\n ...attrSets: Array<Record<string, unknown> | undefined>\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const attrSet of attrSets) {\n if (attrSet) {\n Object.assign(result, attrSet);\n }\n }\n return result;\n}\n\nexport function safeSetAttributes(\n span: AttributeSetter,\n attrs: Record<string, unknown>,\n policy?: AttributePolicy,\n): void {\n // Merge user-supplied guardrails with defaults so callers can tweak\n // a single option without opting out of the rest\n const mergedGuardrails = {\n ...defaultGuardrails(),\n ...policy?.guardrails,\n };\n const effectivePolicy: AttributePolicy = {\n ...policy,\n guardrails: mergedGuardrails,\n };\n\n const validated = autoRedactPII(attrs, effectivePolicy);\n\n const sanitizedAttrs: Record<string, AttributeValue> = {};\n for (const [key, value] of Object.entries(validated)) {\n if (value !== undefined) {\n // Check for deprecated attributes and log warnings\n checkDeprecatedAttribute(key, effectivePolicy);\n const validatedValue = validateAttribute(key, value, effectivePolicy);\n if (validatedValue !== undefined) {\n // Cast to AttributeValue since validateAttribute ensures valid types\n sanitizedAttrs[key] = validatedValue as AttributeValue;\n }\n }\n }\n\n span.setAttributes(sanitizedAttrs);\n}\n","/**\n * Signal attachment helpers\n * These functions know WHERE to attach attributes automatically\n * They handle span, resource, and log signals correctly\n */\n\nimport type { Span, Attributes } from '@opentelemetry/api';\nimport {\n resourceFromAttributes,\n type Resource,\n} from '@opentelemetry/resources';\nimport type { TraceContext } from '../trace-context';\nimport { attrs } from './builders';\nimport { safeSetAttributes } from './utils';\n\nexport function setUser(\n spanOrContext: Span | TraceContext,\n data: import('./types').UserAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.user.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setSession(\n spanOrContext: Span | TraceContext,\n data: import('./types').SessionAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.session.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setDevice(\n spanOrContext: Span | TraceContext,\n data: import('./types').DeviceAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.device.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function httpServer(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPServerAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.http.server(data);\n\n if ('updateName' in spanOrContext && data.method && data.route) {\n const span = spanOrContext as Span;\n span.updateName(`HTTP ${data.method} ${data.route}`);\n }\n\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function httpClient(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPClientAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.http.client(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function dbClient(\n spanOrContext: Span | TraceContext,\n data: import('./types').DBAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.db.client.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\n/**\n * Merge service attributes into a Resource and return a new Resource.\n *\n * Resource.attributes is readonly, so this function returns a new merged\n * Resource rather than mutating the input.\n *\n * @param resource - The existing resource to merge with\n * @param data - Service attributes to add\n * @returns A new Resource with the merged attributes\n *\n * @example\n * ```typescript\n * const baseResource = Resource.default();\n * const enrichedResource = mergeServiceResource(baseResource, {\n * name: 'my-service',\n * version: '1.0.0',\n * });\n * ```\n */\nexport function mergeServiceResource(\n resource: Resource,\n data: import('./types').ServiceAttrs,\n): Resource {\n const attributes = attrs.service.data(data);\n return resource.merge(resourceFromAttributes(attributes as Attributes));\n}\n\nexport function identify(\n spanOrContext: Span | TraceContext,\n data: {\n user?: import('./types').UserAttrs;\n session?: import('./types').SessionAttrs;\n device?: import('./types').DeviceAttrs;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const allAttrs = [];\n\n if (data.user) {\n allAttrs.push(attrs.user.data(data.user));\n }\n if (data.session) {\n allAttrs.push(attrs.session.data(data.session));\n }\n if (data.device) {\n allAttrs.push(attrs.device.data(data.device));\n }\n\n const merged: Record<string, unknown> = {};\n for (const attrSet of allAttrs) {\n Object.assign(merged, attrSet);\n }\n\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n\nexport function request(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPServerAttrs & {\n clientIp?: string;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const httpAttrs = attrs.http.server(data);\n const networkAttrs = attrs.network.peerAddress(data.clientIp || '');\n const merged = { ...httpAttrs, ...networkAttrs };\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n\nexport function setError(\n spanOrContext: Span | TraceContext,\n data: import('./types').ErrorAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.error.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setException(\n spanOrContext: Span | TraceContext,\n data: import('./types').ExceptionAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.exception.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n","/**\n * Domain helpers for common attribute patterns\n * These bundle multiple attribute groups into semantic helpers\n */\n\nimport { attrs } from './builders';\nimport { safeSetAttributes } from './utils';\n\nexport function transaction(\n spanOrContext: import('../trace-context').TraceContext,\n config: {\n user?: import('./types').UserAttrs;\n session?: import('./types').SessionAttrs;\n method?: string;\n route?: string;\n statusCode?: number;\n clientIp?: string;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const userAttrs = attrs.user.data(config.user || {});\n const sessionAttrs = attrs.session.data(config.session || {});\n const httpAttrs = attrs.http.server({\n method: config.method,\n route: config.route,\n statusCode: config.statusCode,\n });\n const networkAttrs = attrs.network.peerAddress(config.clientIp || '');\n\n const merged = {\n ...userAttrs,\n ...sessionAttrs,\n ...httpAttrs,\n ...networkAttrs,\n };\n\n if (config.method && config.route && 'updateName' in spanOrContext) {\n spanOrContext.updateName(`HTTP ${config.method} ${config.route}`);\n }\n\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,QAAQ;CACnB,MAAM;EACJ,KAAK,WAAmB,GAAGA,gCAAe,KAAK,MAAM;EACrD,QAAQ,WAAmB,GAAGA,gCAAe,QAAQ,MAAM;EAC3D,OAAO,WAAmB,GAAGA,gCAAe,OAAO,MAAM;EACzD,WAAW,WAAmB,GAAGA,gCAAe,WAAW,MAAM;EACjE,OAAO,WAAmB,GAAGA,gCAAe,OAAO,MAAM;EACzD,QAAQ,WAAqB,GAAGA,gCAAe,QAAQ,MAAM;EAE7D,OAAO,SAAoB;GACzB,MAAM,SAAkC,CAAC;GACzC,IAAI,KAAK,OAAO,QAAW,OAAOA,gCAAe,MAAM,KAAK;GAC5D,IAAI,KAAK,UAAU,QAAW,OAAOA,gCAAe,SAAS,KAAK;GAClE,IAAI,KAAK,SAAS,QAAW,OAAOA,gCAA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;CACN,MAAM,YAAY,MAAM,KAAK,KAAK,OAAO,QAAQ,CAAC,CAAC;CACnD,MAAM,eAAe,MAAM,QAAQ,KAAK,OAAO,WAAW,CAAC,CAAC;CAC5D,MAAM,YAAY,MAAM,KAAK,OAAO;EAClC,QAAQ,OAAO;EACf,OAAO,OAAO;EACd,YAAY,OAAO;CACrB,CAAC;CACD,MAAM,eAAe,MAAM,QAAQ,YAAY,OAAO,YAAY,EAAE;CAEpE,MAAM,SAAS;EACb,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,IAAI,OAAO,UAAU,OAAO,SAAS,gBAAgB,eACnD,cAAc,WAAW,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO;CAGlE,kBAAkB,eAAe,QAAQ,UAAU;AACrD"}
|
|
1
|
+
{"version":3,"file":"attributes-aDmJYral.cjs","names":["UserAttributes","SessionAttributes","DeviceAttributes","HTTPAttributes","DBAttributes","ServiceAttributes","NetworkAttributes","ServerAddressAttributes","URLAttributes","ErrorAttributes","ExceptionAttributes","ProcessAttributes","ThreadAttributes","ContainerAttributes","K8sAttributes","CloudAttributes","FaaSAttributes","FeatureFlagAttributes","MessagingAttributes","RPCAttributes","GraphQLAttributes","OTelAttributes","CodeAttributes","TLSAttributes","REDACTOR_PATTERNS"],"sources":["../src/attributes/builders.ts","../src/attributes/validators.ts","../src/attributes/utils.ts","../src/attributes/attachers.ts","../src/attributes/domains.ts"],"sourcesContent":["/**\n * Attribute builders for constructing OpenTelemetry attributes\n * Provides both key builders (Pattern A) and object builders (Pattern B)\n *\n * @example Pattern A: Key builders\n * ```typescript\n * attrs.user.id('123') // { 'user.id': '123' }\n * attrs.user.email('user@example.com') // { 'user.email': 'user@example.com' }\n * attrs.http.request.method('GET') // { 'http.request.method': 'GET' }\n * attrs.http.response.statusCode(200) // { 'http.response.status_code': 200 }\n * ```\n *\n * @example Pattern B: Object builders\n * ```typescript\n * attrs.user({ id: '123', email: 'user@example.com' })\n * attrs.http.server({ method: 'GET', route: '/users/:id', statusCode: 200 })\n * attrs.db.client({ system: 'postgresql', operation: 'SELECT', collectionName: 'users' })\n * ```\n */\n\nimport {\n UserAttributes,\n SessionAttributes,\n DeviceAttributes,\n HTTPAttributes,\n DBAttributes,\n ServiceAttributes,\n NetworkAttributes,\n ServerAddressAttributes,\n URLAttributes,\n ErrorAttributes,\n ExceptionAttributes,\n ProcessAttributes,\n ThreadAttributes,\n ContainerAttributes,\n K8sAttributes,\n CloudAttributes,\n FaaSAttributes,\n FeatureFlagAttributes,\n MessagingAttributes,\n RPCAttributes,\n GraphQLAttributes,\n OTelAttributes,\n CodeAttributes,\n TLSAttributes,\n} from './registry';\n\nimport type {\n UserAttrs,\n SessionAttrs,\n DeviceAttrs,\n HTTPServerAttrs,\n HTTPClientAttrs,\n DBAttrs,\n ServiceAttrs,\n NetworkAttrs,\n ErrorAttrs,\n MessagingAttrs,\n CloudAttrs,\n ServerAddressAttrs,\n URLAttrs,\n ProcessAttrs,\n ContainerAttrs,\n ExceptionAttrs,\n} from './types';\n\nexport const attrs = {\n user: {\n id: (value: string) => ({ [UserAttributes.id]: value }),\n email: (value: string) => ({ [UserAttributes.email]: value }),\n name: (value: string) => ({ [UserAttributes.name]: value }),\n fullName: (value: string) => ({ [UserAttributes.fullName]: value }),\n hash: (value: string) => ({ [UserAttributes.hash]: value }),\n roles: (value: string[]) => ({ [UserAttributes.roles]: value }),\n\n data: (data: UserAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[UserAttributes.id] = data.id;\n if (data.email !== undefined) result[UserAttributes.email] = data.email;\n if (data.name !== undefined) result[UserAttributes.name] = data.name;\n if (data.fullName !== undefined)\n result[UserAttributes.fullName] = data.fullName;\n if (data.hash !== undefined) result[UserAttributes.hash] = data.hash;\n if (data.roles !== undefined) result[UserAttributes.roles] = data.roles;\n return result;\n },\n },\n\n session: {\n id: (value: string) => ({ [SessionAttributes.id]: value }),\n previousId: (value: string) => ({ [SessionAttributes.previousId]: value }),\n\n data: (data: SessionAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[SessionAttributes.id] = data.id;\n if (data.previousId !== undefined)\n result[SessionAttributes.previousId] = data.previousId;\n return result;\n },\n },\n\n device: {\n id: (value: string) => ({ [DeviceAttributes.id]: value }),\n manufacturer: (value: string) => ({\n [DeviceAttributes.manufacturer]: value,\n }),\n modelIdentifier: (value: string) => ({\n [DeviceAttributes.modelIdentifier]: value,\n }),\n modelName: (value: string) => ({ [DeviceAttributes.modelName]: value }),\n\n data: (data: DeviceAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[DeviceAttributes.id] = data.id;\n if (data.manufacturer !== undefined)\n result[DeviceAttributes.manufacturer] = data.manufacturer;\n if (data.modelIdentifier !== undefined)\n result[DeviceAttributes.modelIdentifier] = data.modelIdentifier;\n if (data.modelName !== undefined)\n result[DeviceAttributes.modelName] = data.modelName;\n return result;\n },\n },\n\n http: {\n request: {\n method: (value: string) => ({ [HTTPAttributes.requestMethod]: value }),\n methodOriginal: (value: string) => ({\n [HTTPAttributes.requestMethodOriginal]: value,\n }),\n resendCount: (value: number) => ({\n [HTTPAttributes.requestResendCount]: value,\n }),\n size: (value: number) => ({ [HTTPAttributes.requestSize]: value }),\n bodySize: (value: number) => ({\n [HTTPAttributes.requestBodySize]: value,\n }),\n },\n\n response: {\n statusCode: (value: number) => ({\n [HTTPAttributes.responseStatusCode]: value,\n }),\n size: (value: number) => ({ [HTTPAttributes.responseSize]: value }),\n bodySize: (value: number) => ({\n [HTTPAttributes.responseBodySize]: value,\n }),\n },\n\n route: (value: string) => ({ [HTTPAttributes.route]: value }),\n connectionState: (value: string) => ({\n [HTTPAttributes.connectionState]: value,\n }),\n\n server: (data: HTTPServerAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.method !== undefined)\n result[HTTPAttributes.requestMethod] = data.method;\n if (data.route !== undefined) result[HTTPAttributes.route] = data.route;\n if (data.statusCode !== undefined)\n result[HTTPAttributes.responseStatusCode] = data.statusCode;\n if (data.bodySize !== undefined)\n result[HTTPAttributes.requestBodySize] = data.bodySize;\n if (data.requestSize !== undefined)\n result[HTTPAttributes.requestSize] = data.requestSize;\n if (data.responseSize !== undefined)\n result[HTTPAttributes.responseSize] = data.responseSize;\n if (data.resendCount !== undefined)\n result[HTTPAttributes.requestResendCount] = data.resendCount;\n return result;\n },\n\n client: (data: HTTPClientAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.method !== undefined)\n result[HTTPAttributes.requestMethod] = data.method;\n if (data.url !== undefined) result[HTTPAttributes.route] = data.url;\n if (data.statusCode !== undefined)\n result[HTTPAttributes.responseStatusCode] = data.statusCode;\n return result;\n },\n },\n\n db: {\n client: {\n system: (value: string) => ({ [DBAttributes.systemName]: value }),\n operation: (value: string) => ({ [DBAttributes.operationName]: value }),\n collectionName: (value: string) => ({\n [DBAttributes.collectionName]: value,\n }),\n namespace: (value: string) => ({ [DBAttributes.namespace]: value }),\n statement: (value: string) => ({ [DBAttributes.statement]: value }),\n querySummary: (value: string) => ({ [DBAttributes.querySummary]: value }),\n queryText: (value: string) => ({ [DBAttributes.queryText]: value }),\n responseStatus: (value: string | number) => ({\n [DBAttributes.responseStatusCode]: value,\n }),\n rowsReturned: (value: number) => ({\n [DBAttributes.responseReturnedRows]: value,\n }),\n\n data: (data: DBAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.system !== undefined)\n result[DBAttributes.systemName] = data.system;\n if (data.operation !== undefined)\n result[DBAttributes.operationName] = data.operation;\n if (data.collectionName !== undefined)\n result[DBAttributes.collectionName] = data.collectionName;\n // 'name' maps to db.namespace (db.name is deprecated per OTel semantic conventions)\n if (data.name !== undefined) result[DBAttributes.namespace] = data.name;\n // 'namespace' takes precedence over 'name' if both are provided\n if (data.namespace !== undefined)\n result[DBAttributes.namespace] = data.namespace;\n if (data.statement !== undefined)\n result[DBAttributes.statement] = data.statement;\n if (data.querySummary !== undefined)\n result[DBAttributes.querySummary] = data.querySummary;\n if (data.queryText !== undefined)\n result[DBAttributes.queryText] = data.queryText;\n if (data.responseStatus !== undefined)\n result[DBAttributes.responseStatusCode] = data.responseStatus;\n if (data.rowsReturned !== undefined)\n result[DBAttributes.responseReturnedRows] = data.rowsReturned;\n return result;\n },\n },\n },\n\n service: {\n name: (value: string) => ({ [ServiceAttributes.name]: value }),\n instance: (value: string) => ({ [ServiceAttributes.instance]: value }),\n version: (value: string) => ({ [ServiceAttributes.version]: value }),\n\n data: (data: ServiceAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.name !== undefined) result[ServiceAttributes.name] = data.name;\n if (data.instance !== undefined)\n result[ServiceAttributes.instance] = data.instance;\n if (data.version !== undefined)\n result[ServiceAttributes.version] = data.version;\n return result;\n },\n },\n\n network: {\n peerAddress: (value: string) => ({\n [NetworkAttributes.peerAddress]: value,\n }),\n peerPort: (value: number) => ({ [NetworkAttributes.peerPort]: value }),\n transport: (value: string) => ({ [NetworkAttributes.transport]: value }),\n protocolName: (value: string) => ({\n [NetworkAttributes.protocolName]: value,\n }),\n protocolVersion: (value: string) => ({\n [NetworkAttributes.protocolVersion]: value,\n }),\n\n data: (data: NetworkAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.peerAddress !== undefined)\n result[NetworkAttributes.peerAddress] = data.peerAddress;\n if (data.peerPort !== undefined)\n result[NetworkAttributes.peerPort] = data.peerPort;\n if (data.transport !== undefined)\n result[NetworkAttributes.transport] = data.transport;\n if (data.protocolName !== undefined)\n result[NetworkAttributes.protocolName] = data.protocolName;\n if (data.protocolVersion !== undefined)\n result[NetworkAttributes.protocolVersion] = data.protocolVersion;\n return result;\n },\n },\n\n server: {\n address: (value: string) => ({ [ServerAddressAttributes.address]: value }),\n port: (value: number) => ({ [ServerAddressAttributes.port]: value }),\n socketAddress: (value: string) => ({\n [ServerAddressAttributes.socketAddress]: value,\n }),\n\n data: (data: ServerAddressAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.address !== undefined)\n result[ServerAddressAttributes.address] = data.address;\n if (data.port !== undefined)\n result[ServerAddressAttributes.port] = data.port;\n if (data.socketAddress !== undefined)\n result[ServerAddressAttributes.socketAddress] = data.socketAddress;\n return result;\n },\n },\n\n url: {\n scheme: (value: string) => ({ [URLAttributes.scheme]: value }),\n full: (value: string) => ({ [URLAttributes.full]: value }),\n path: (value: string) => ({ [URLAttributes.path]: value }),\n query: (value: string) => ({ [URLAttributes.query]: value }),\n fragment: (value: string) => ({ [URLAttributes.fragment]: value }),\n\n data: (data: URLAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.scheme !== undefined) result[URLAttributes.scheme] = data.scheme;\n if (data.full !== undefined) result[URLAttributes.full] = data.full;\n if (data.path !== undefined) result[URLAttributes.path] = data.path;\n if (data.query !== undefined) result[URLAttributes.query] = data.query;\n if (data.fragment !== undefined)\n result[URLAttributes.fragment] = data.fragment;\n return result;\n },\n },\n\n error: {\n type: (value: string) => ({ [ErrorAttributes.type]: value }),\n message: (value: string) => ({ [ErrorAttributes.message]: value }),\n stackTrace: (value: string) => ({ [ErrorAttributes.stackTrace]: value }),\n code: (value: string | number) => ({ [ErrorAttributes.code]: value }),\n\n data: (data: ErrorAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.type !== undefined) result[ErrorAttributes.type] = data.type;\n if (data.message !== undefined)\n result[ErrorAttributes.message] = data.message;\n if (data.stackTrace !== undefined)\n result[ErrorAttributes.stackTrace] = data.stackTrace;\n if (data.code !== undefined) result[ErrorAttributes.code] = data.code;\n return result;\n },\n },\n\n exception: {\n escaped: (value: boolean) => ({ [ExceptionAttributes.escaped]: value }),\n message: (value: string) => ({ [ExceptionAttributes.message]: value }),\n stackTrace: (value: string) => ({\n [ExceptionAttributes.stackTrace]: value,\n }),\n type: (value: string) => ({ [ExceptionAttributes.type]: value }),\n moduleName: (value: string) => ({\n [ExceptionAttributes.moduleName]: value,\n }),\n\n data: (data: ExceptionAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.escaped !== undefined)\n result[ExceptionAttributes.escaped] = data.escaped;\n if (data.message !== undefined)\n result[ExceptionAttributes.message] = data.message;\n if (data.stackTrace !== undefined)\n result[ExceptionAttributes.stackTrace] = data.stackTrace;\n if (data.type !== undefined) result[ExceptionAttributes.type] = data.type;\n if (data.moduleName !== undefined)\n result[ExceptionAttributes.moduleName] = data.moduleName;\n return result;\n },\n },\n\n process: {\n pid: (value: number) => ({ [ProcessAttributes.pid]: value }),\n executablePath: (value: string) => ({\n [ProcessAttributes.executablePath]: value,\n }),\n command: (value: string) => ({ [ProcessAttributes.command]: value }),\n owner: (value: string) => ({ [ProcessAttributes.owner]: value }),\n\n data: (data: ProcessAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.pid !== undefined) result[ProcessAttributes.pid] = data.pid;\n if (data.executablePath !== undefined)\n result[ProcessAttributes.executablePath] = data.executablePath;\n if (data.command !== undefined)\n result[ProcessAttributes.command] = data.command;\n if (data.owner !== undefined)\n result[ProcessAttributes.owner] = data.owner;\n return result;\n },\n },\n\n thread: {\n id: (value: number) => ({ [ThreadAttributes.id]: value }),\n name: (value: string) => ({ [ThreadAttributes.name]: value }),\n },\n\n container: {\n id: (value: string) => ({ [ContainerAttributes.id]: value }),\n name: (value: string) => ({ [ContainerAttributes.name]: value }),\n image: (value: string) => ({ [ContainerAttributes.image]: value }),\n tag: (value: string) => ({ [ContainerAttributes.tag]: value }),\n\n data: (data: ContainerAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.id !== undefined) result[ContainerAttributes.id] = data.id;\n if (data.name !== undefined) result[ContainerAttributes.name] = data.name;\n if (data.image !== undefined)\n result[ContainerAttributes.image] = data.image;\n if (data.tag !== undefined) result[ContainerAttributes.tag] = data.tag;\n return result;\n },\n },\n\n k8s: {\n podName: (value: string) => ({ [K8sAttributes.podName]: value }),\n namespaceName: (value: string) => ({\n [K8sAttributes.namespaceName]: value,\n }),\n deploymentName: (value: string) => ({\n [K8sAttributes.deploymentName]: value,\n }),\n state: (value: string) => ({ [K8sAttributes.state]: value }),\n },\n\n cloud: {\n provider: (value: string) => ({ [CloudAttributes.provider]: value }),\n accountId: (value: string) => ({ [CloudAttributes.accountId]: value }),\n region: (value: string) => ({ [CloudAttributes.region]: value }),\n availabilityZone: (value: string) => ({\n [CloudAttributes.availabilityZone]: value,\n }),\n platform: (value: string) => ({ [CloudAttributes.platform]: value }),\n\n data: (data: CloudAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.provider !== undefined)\n result[CloudAttributes.provider] = data.provider;\n if (data.accountId !== undefined)\n result[CloudAttributes.accountId] = data.accountId;\n if (data.region !== undefined)\n result[CloudAttributes.region] = data.region;\n if (data.availabilityZone !== undefined)\n result[CloudAttributes.availabilityZone] = data.availabilityZone;\n if (data.platform !== undefined)\n result[CloudAttributes.platform] = data.platform;\n return result;\n },\n },\n\n faas: {\n name: (value: string) => ({ [FaaSAttributes.name]: value }),\n version: (value: string) => ({ [FaaSAttributes.version]: value }),\n instance: (value: string) => ({ [FaaSAttributes.instance]: value }),\n execution: (value: string) => ({ [FaaSAttributes.execution]: value }),\n coldstart: (value: boolean) => ({ [FaaSAttributes.coldstart]: value }),\n },\n\n featureFlag: {\n key: (value: string) => ({ [FeatureFlagAttributes.key]: value }),\n provider: (value: string) => ({ [FeatureFlagAttributes.provider]: value }),\n variant: (value: string) => ({ [FeatureFlagAttributes.variant]: value }),\n },\n\n messaging: {\n system: (value: string) => ({ [MessagingAttributes.system]: value }),\n destination: (value: string) => ({\n [MessagingAttributes.destination]: value,\n }),\n operation: (value: 'publish' | 'receive' | 'process') => ({\n [MessagingAttributes.operation]: value,\n }),\n messageId: (value: string) => ({ [MessagingAttributes.messageId]: value }),\n conversationId: (value: string) => ({\n [MessagingAttributes.conversationId]: value,\n }),\n\n data: (data: MessagingAttrs) => {\n const result: Record<string, unknown> = {};\n if (data.system !== undefined)\n result[MessagingAttributes.system] = data.system;\n if (data.destination !== undefined)\n result[MessagingAttributes.destination] = data.destination;\n if (data.operation !== undefined)\n result[MessagingAttributes.operation] = data.operation;\n if (data.messageId !== undefined)\n result[MessagingAttributes.messageId] = data.messageId;\n if (data.conversationId !== undefined)\n result[MessagingAttributes.conversationId] = data.conversationId;\n return result;\n },\n },\n\n // GenAI/LLM attribute builders moved to the `autotel-genai` package\n // (canonical `gen_ai.*` semantic conventions).\n\n rpc: {\n system: (value: string) => ({ [RPCAttributes.system]: value }),\n service: (value: string) => ({ [RPCAttributes.service]: value }),\n method: (value: string) => ({ [RPCAttributes.method]: value }),\n grpcStatusCode: (value: number) => ({\n [RPCAttributes.grpcStatusCode]: value,\n }),\n },\n\n graphql: {\n document: (value: string) => ({ [GraphQLAttributes.document]: value }),\n operationName: (value: string) => ({\n [GraphQLAttributes.operationName]: value,\n }),\n operationType: (value: 'query' | 'mutation' | 'subscription') => ({\n [GraphQLAttributes.operationType]: value,\n }),\n },\n\n otel: {\n libraryName: (value: string) => ({ [OTelAttributes.libraryName]: value }),\n libraryVersion: (value: string) => ({\n [OTelAttributes.libraryVersion]: value,\n }),\n statusCode: (value: string) => ({ [OTelAttributes.statusCode]: value }),\n },\n\n code: {\n namespace: (value: string) => ({ [CodeAttributes.namespace]: value }),\n filepath: (value: string) => ({ [CodeAttributes.filepath]: value }),\n function: (value: string) => ({ [CodeAttributes.function]: value }),\n class: (value: string) => ({ [CodeAttributes.class]: value }),\n method: (value: string) => ({ [CodeAttributes.method]: value }),\n column: (value: string) => ({ [CodeAttributes.column]: value }),\n lineNumber: (value: number) => ({ [CodeAttributes.lineNumber]: value }),\n repository: (value: string) => ({ [CodeAttributes.repository]: value }),\n revision: (value: string) => ({ [CodeAttributes.revision]: value }),\n },\n\n tls: {\n protocolVersion: (value: string) => ({\n [TLSAttributes.protocolVersion]: value,\n }),\n cipher: (value: string) => ({ [TLSAttributes.cipher]: value }),\n curveName: (value: string) => ({ [TLSAttributes.curveName]: value }),\n resumed: (value: boolean) => ({ [TLSAttributes.resumed]: value }),\n },\n} as const;\n","/**\n * Attribute validation, PII detection, and guardrails\n * Provides safe-by-default attribute handling with configurable policies\n */\n\nimport { REDACTOR_PATTERNS } from '../attribute-redacting-processor';\n\nexport interface AttributeGuardrails {\n /** How to handle PII in attributes */\n pii?: 'allow' | 'redact' | 'hash' | 'block';\n\n /** Maximum length for attribute values */\n maxLength?: number;\n\n /** Validate enum values against known values */\n validateEnum?: boolean;\n\n /** Log warnings for deprecated attributes instead of throwing */\n warnDeprecated?: boolean;\n\n /** Custom deprecation warnings */\n deprecatedWarnings?: Record<string, string>;\n}\n\nexport interface AttributePolicy {\n guardrails?: AttributeGuardrails;\n /** Custom deprecation warnings for specific attributes */\n deprecatedWarnings?: Record<string, string>;\n}\n\nconst DEPRECATED_ATTRIBUTES = {\n 'enduser.id': 'user.id',\n 'enduser.role': 'user.roles',\n 'enduser.scope': undefined,\n 'http.method': 'http.request.method',\n 'http.host': 'server.address',\n 'http.status_code': 'http.response.status_code',\n 'http.target': 'url.path',\n 'http.url': 'url.full',\n 'http.user_agent': 'user_agent.original',\n 'http.flavor': 'network.protocol.name',\n 'http.scheme': 'url.scheme',\n 'http.server_name': 'server.address',\n 'db.name': 'db.namespace',\n 'db.operation': 'db.operation.name',\n 'db.statement': 'db.query.text',\n 'db.system': 'db.system.name',\n 'db.collection': 'db.collection.name',\n 'db.instance.id': undefined,\n 'db.jdbc.driver_classname': undefined,\n 'db.mssql.instance_name': 'mssql.instance.name',\n 'db.sql.table': 'db.collection.name',\n 'http.client_ip': 'client.address',\n 'user_agent.original': 'user_agent.original',\n} as const;\n\nconst HTTP_METHODS = new Set([\n 'GET',\n 'POST',\n 'PUT',\n 'DELETE',\n 'PATCH',\n 'HEAD',\n 'OPTIONS',\n 'TRACE',\n 'QUERY',\n '_OTHER',\n]);\n\nexport function validateAttribute(\n key: string,\n value: unknown,\n policy: AttributePolicy = {},\n): unknown {\n const { guardrails = {} } = policy;\n\n if (value === undefined || value === null) {\n return undefined;\n }\n\n // For non-string values that don't need transformation, preserve the original type\n if (typeof value !== 'string') {\n // PII checks only apply to strings\n // maxLength only applies to strings\n // validateEnum only applies to strings\n return value;\n }\n\n const stringValue = value;\n\n if (guardrails.pii) {\n const piiResult = applyPIIPolicy(key, stringValue, guardrails.pii);\n if (piiResult !== stringValue) {\n return piiResult;\n }\n }\n\n if (guardrails.maxLength && stringValue.length > guardrails.maxLength) {\n return truncateValue(key, stringValue, guardrails.maxLength);\n }\n\n if (guardrails.validateEnum && HTTP_METHODS.has(stringValue)) {\n const normalizedMethod = normalizeHTTPMethod(stringValue);\n if (normalizedMethod !== stringValue) {\n return normalizedMethod;\n }\n }\n\n return stringValue;\n}\n\nfunction applyPIIPolicy(\n key: string,\n value: string,\n pii: AttributeGuardrails['pii'],\n): string {\n if (pii === 'allow') {\n return value;\n }\n\n if (pii === 'redact') {\n return redactIfPII(key, value);\n }\n\n if (pii === 'hash') {\n return hashIfPII(key, value);\n }\n\n if (pii === 'block' && isPIIKey(key)) {\n throw new Error(\n `PII attribute \"${key}\" is blocked by guardrails. Use pii: \"allow\" to enable it.`,\n );\n }\n\n return value;\n}\n\nfunction isPIIKey(key: string): boolean {\n const piiKeyPatterns = [\n 'email',\n 'phone',\n 'ssn',\n 'credit_card',\n 'password',\n 'secret',\n 'token',\n 'api_key',\n 'authorization',\n ];\n const lowerKey = key.toLowerCase();\n return piiKeyPatterns.some((pattern) => lowerKey.includes(pattern));\n}\n\nfunction redactIfPII(key: string, value: string): string {\n if (isPIIKey(key)) {\n // REDACTOR_PATTERNS values are RegExp patterns\n for (const [, pattern] of Object.entries(REDACTOR_PATTERNS)) {\n if (pattern instanceof RegExp && pattern.test(value)) {\n return '[REDACTED]';\n }\n }\n // If no pattern matched but key is PII, still redact\n return '[REDACTED]';\n }\n return value;\n}\n\nfunction hashIfPII(key: string, value: string): string {\n if (!isPIIKey(key)) {\n return value;\n }\n\n // Use a simple but consistent hash that produces 32-char hex\n // FNV-1a hash variant producing 128-bit output (32 hex chars)\n const FNV_PRIME = 0x01_00_01_93;\n const FNV_OFFSET = 0x81_1c_9d_c5;\n\n // Generate 4 32-bit hashes to produce 32 hex chars\n const hashes: number[] = [];\n for (let round = 0; round < 4; round++) {\n let hash = FNV_OFFSET;\n for (let i = 0; i < value.length; i++) {\n hash ^= (value.codePointAt(i) ?? 0) + round;\n hash = Math.imul(hash, FNV_PRIME);\n }\n hashes.push(hash >>> 0); // Convert to unsigned\n }\n\n return `hash_${hashes.map((h) => h.toString(16).padStart(8, '0')).join('')}`;\n}\n\nfunction truncateValue(key: string, value: string, maxLength: number): string {\n if (value.length <= maxLength) {\n return value;\n }\n return value.slice(0, maxLength - 3) + '...';\n}\n\nfunction normalizeHTTPMethod(method: string): string {\n const upper = method.toUpperCase();\n if (HTTP_METHODS.has(upper)) {\n return upper;\n }\n return upper;\n}\n\nexport function checkDeprecatedAttribute(\n key: string,\n policy: AttributePolicy = {},\n): string | null {\n const { guardrails = {}, deprecatedWarnings = {} } = policy;\n const { warnDeprecated = true } = guardrails;\n\n if (!warnDeprecated) {\n return null;\n }\n\n // Check if the key exists in the deprecated attributes map\n const isDeprecated = key in DEPRECATED_ATTRIBUTES;\n if (isDeprecated) {\n const replacement =\n DEPRECATED_ATTRIBUTES[key as keyof typeof DEPRECATED_ATTRIBUTES];\n if (replacement === undefined) {\n // Deprecated with no replacement (e.g., enduser.scope)\n console.warn(\n `[autotel/attributes] Attribute \"${key}\" is deprecated and has no replacement. ` +\n `Remove or find a replacement in OpenTelemetry semantic conventions.`,\n );\n } else {\n // Deprecated with a known replacement\n console.warn(\n `[autotel/attributes] Attribute \"${key}\" is deprecated. Use \"${replacement}\" instead.`,\n );\n }\n }\n\n if (deprecatedWarnings[key]) {\n console.warn(`[autotel/attributes] ${deprecatedWarnings[key]}`);\n }\n\n const replacement =\n DEPRECATED_ATTRIBUTES[key as keyof typeof DEPRECATED_ATTRIBUTES];\n return replacement ?? null;\n}\n\nexport function autoRedactPII(\n attributes: Record<string, unknown>,\n policy: AttributePolicy = {},\n): Record<string, unknown> {\n const { guardrails = { pii: 'redact' } } = policy;\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n redacted[key] = validateAttribute(key, value, { guardrails });\n }\n return redacted;\n}\n\nexport function defaultGuardrails(): AttributeGuardrails {\n return {\n pii: 'redact',\n maxLength: 255,\n validateEnum: true,\n warnDeprecated: true,\n };\n}\n","/**\n * Attribute utility functions\n */\n\nimport type { AttributeValue } from '../trace-context';\nimport {\n validateAttribute,\n autoRedactPII,\n defaultGuardrails,\n checkDeprecatedAttribute,\n type AttributePolicy,\n} from './validators';\n\n// Type for objects that have setAttributes method (spans or contexts)\n// Using a generic parameter to accommodate different AttributeValue types\ntype AttributeSetter = {\n setAttributes: (attrs: Record<string, AttributeValue>) => void;\n};\n\nexport function mergeAttrs(\n ...attrSets: Array<Record<string, unknown> | undefined>\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const attrSet of attrSets) {\n if (attrSet) {\n Object.assign(result, attrSet);\n }\n }\n return result;\n}\n\nexport function safeSetAttributes(\n span: AttributeSetter,\n attrs: Record<string, unknown>,\n policy?: AttributePolicy,\n): void {\n // Merge user-supplied guardrails with defaults so callers can tweak\n // a single option without opting out of the rest\n const mergedGuardrails = {\n ...defaultGuardrails(),\n ...policy?.guardrails,\n };\n const effectivePolicy: AttributePolicy = {\n ...policy,\n guardrails: mergedGuardrails,\n };\n\n const validated = autoRedactPII(attrs, effectivePolicy);\n\n const sanitizedAttrs: Record<string, AttributeValue> = {};\n for (const [key, value] of Object.entries(validated)) {\n if (value !== undefined) {\n // Check for deprecated attributes and log warnings\n checkDeprecatedAttribute(key, effectivePolicy);\n const validatedValue = validateAttribute(key, value, effectivePolicy);\n if (validatedValue !== undefined) {\n // Cast to AttributeValue since validateAttribute ensures valid types\n sanitizedAttrs[key] = validatedValue as AttributeValue;\n }\n }\n }\n\n span.setAttributes(sanitizedAttrs);\n}\n","/**\n * Signal attachment helpers\n * These functions know WHERE to attach attributes automatically\n * They handle span, resource, and log signals correctly\n */\n\nimport type { Span, Attributes } from '@opentelemetry/api';\nimport {\n resourceFromAttributes,\n type Resource,\n} from '@opentelemetry/resources';\nimport type { TraceContext } from '../trace-context';\nimport { attrs } from './builders';\nimport { safeSetAttributes } from './utils';\n\nexport function setUser(\n spanOrContext: Span | TraceContext,\n data: import('./types').UserAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.user.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setSession(\n spanOrContext: Span | TraceContext,\n data: import('./types').SessionAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.session.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setDevice(\n spanOrContext: Span | TraceContext,\n data: import('./types').DeviceAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.device.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function httpServer(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPServerAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.http.server(data);\n\n if ('updateName' in spanOrContext && data.method && data.route) {\n const span = spanOrContext as Span;\n span.updateName(`HTTP ${data.method} ${data.route}`);\n }\n\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function httpClient(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPClientAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.http.client(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function dbClient(\n spanOrContext: Span | TraceContext,\n data: import('./types').DBAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.db.client.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\n/**\n * Merge service attributes into a Resource and return a new Resource.\n *\n * Resource.attributes is readonly, so this function returns a new merged\n * Resource rather than mutating the input.\n *\n * @param resource - The existing resource to merge with\n * @param data - Service attributes to add\n * @returns A new Resource with the merged attributes\n *\n * @example\n * ```typescript\n * const baseResource = Resource.default();\n * const enrichedResource = mergeServiceResource(baseResource, {\n * name: 'my-service',\n * version: '1.0.0',\n * });\n * ```\n */\nexport function mergeServiceResource(\n resource: Resource,\n data: import('./types').ServiceAttrs,\n): Resource {\n const attributes = attrs.service.data(data);\n return resource.merge(resourceFromAttributes(attributes as Attributes));\n}\n\nexport function identify(\n spanOrContext: Span | TraceContext,\n data: {\n user?: import('./types').UserAttrs;\n session?: import('./types').SessionAttrs;\n device?: import('./types').DeviceAttrs;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const allAttrs = [];\n\n if (data.user) {\n allAttrs.push(attrs.user.data(data.user));\n }\n if (data.session) {\n allAttrs.push(attrs.session.data(data.session));\n }\n if (data.device) {\n allAttrs.push(attrs.device.data(data.device));\n }\n\n const merged: Record<string, unknown> = {};\n for (const attrSet of allAttrs) {\n Object.assign(merged, attrSet);\n }\n\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n\nexport function request(\n spanOrContext: Span | TraceContext,\n data: import('./types').HTTPServerAttrs & {\n clientIp?: string;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const httpAttrs = attrs.http.server(data);\n const networkAttrs = attrs.network.peerAddress(data.clientIp || '');\n const merged = { ...httpAttrs, ...networkAttrs };\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n\nexport function setError(\n spanOrContext: Span | TraceContext,\n data: import('./types').ErrorAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.error.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n\nexport function setException(\n spanOrContext: Span | TraceContext,\n data: import('./types').ExceptionAttrs,\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const attributes = attrs.exception.data(data);\n safeSetAttributes(spanOrContext, attributes, guardrails);\n}\n","/**\n * Domain helpers for common attribute patterns\n * These bundle multiple attribute groups into semantic helpers\n */\n\nimport { attrs } from './builders';\nimport { safeSetAttributes } from './utils';\n\nexport function transaction(\n spanOrContext: import('../trace-context').TraceContext,\n config: {\n user?: import('./types').UserAttrs;\n session?: import('./types').SessionAttrs;\n method?: string;\n route?: string;\n statusCode?: number;\n clientIp?: string;\n },\n guardrails?: import('./validators').AttributePolicy,\n): void {\n const userAttrs = attrs.user.data(config.user || {});\n const sessionAttrs = attrs.session.data(config.session || {});\n const httpAttrs = attrs.http.server({\n method: config.method,\n route: config.route,\n statusCode: config.statusCode,\n });\n const networkAttrs = attrs.network.peerAddress(config.clientIp || '');\n\n const merged = {\n ...userAttrs,\n ...sessionAttrs,\n ...httpAttrs,\n ...networkAttrs,\n };\n\n if (config.method && config.route && 'updateName' in spanOrContext) {\n spanOrContext.updateName(`HTTP ${config.method} ${config.route}`);\n }\n\n safeSetAttributes(spanOrContext, merged, guardrails);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAa,QAAQ;CACnB,MAAM;EACJ,KAAK,WAAmB,GAAGA,gCAAe,KAAK,MAAM;EACrD,QAAQ,WAAmB,GAAGA,gCAAe,QAAQ,MAAM;EAC3D,OAAO,WAAmB,GAAGA,gCAAe,OAAO,MAAM;EACzD,WAAW,WAAmB,GAAGA,gCAAe,WAAW,MAAM;EACjE,OAAO,WAAmB,GAAGA,gCAAe,OAAO,MAAM;EACzD,QAAQ,WAAqB,GAAGA,gCAAe,QAAQ,MAAM;EAE7D,OAAO,SAAoB;GACzB,MAAM,SAAkC,CAAC;GACzC,IAAI,KAAK,OAAO,QAAW,OAAOA,gCAAe,MAAM,KAAK;GAC5D,IAAI,KAAK,UAAU,QAAW,OAAOA,gCAAe,SAAS,KAAK;GAClE,IAAI,KAAK,SAAS,QAAW,OAAOA,gCAAe,QAAQ,KAAK;GAChE,IAAI,KAAK,aAAa,QACpB,OAAOA,gCAAe,YAAY,KAAK;GACzC,IAAI,KAAK,SAAS,QAAW,OAAOA,gCAAe,QAAQ,KAAK;GAChE,IAAI,KAAK,UAAU,QAAW,O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EAClC,QAAQ,OAAO;EACf,OAAO,OAAO;EACd,YAAY,OAAO;CACrB,CAAC;CACD,MAAM,eAAe,MAAM,QAAQ,YAAY,OAAO,YAAY,EAAE;CAEpE,MAAM,SAAS;EACb,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;CACL;CAEA,IAAI,OAAO,UAAU,OAAO,SAAS,gBAAgB,eACnD,cAAc,WAAW,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO;CAGlE,kBAAkB,eAAe,QAAQ,UAAU;AACrD"}
|
package/dist/attributes.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_attributes = require('./attributes-
|
|
2
|
+
const require_attributes = require('./attributes-aDmJYral.cjs');
|
|
3
3
|
|
|
4
4
|
exports.attrs = require_attributes.attrs;
|
|
5
5
|
exports.autoRedactPII = require_attributes.autoRedactPII;
|
package/dist/attributes.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as defaultGuardrails, a as identify, c as setDevice, d as setSession, f as setUser, g as checkDeprecatedAttribute, h as autoRedactPII, i as httpServer, l as setError, m as safeSetAttributes, n as dbClient, o as mergeServiceResource, p as mergeAttrs, r as httpClient, s as request, t as transaction, u as setException, v as validateAttribute, y as attrs } from "./attributes-
|
|
1
|
+
import { _ as defaultGuardrails, a as identify, c as setDevice, d as setSession, f as setUser, g as checkDeprecatedAttribute, h as autoRedactPII, i as httpServer, l as setError, m as safeSetAttributes, n as dbClient, o as mergeServiceResource, p as mergeAttrs, r as httpClient, s as request, t as transaction, u as setException, v as validateAttribute, y as attrs } from "./attributes-B7wix2VG.js";
|
|
2
2
|
|
|
3
3
|
export { attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute };
|
package/dist/auto.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_init = require('./init-
|
|
1
|
+
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
2
|
+
const require_init = require('./init-BxJEJ9Tn.cjs');
|
|
3
3
|
const require_yaml_config = require('./yaml-config.cjs');
|
|
4
4
|
let node_module = require("node:module");
|
|
5
|
-
node_module =
|
|
5
|
+
node_module = require_rolldown_runtime.__toESM(node_module, 1);
|
|
6
6
|
let import_in_the_middle = require("import-in-the-middle");
|
|
7
7
|
|
|
8
8
|
//#region src/auto.ts
|
package/dist/auto.js
CHANGED
package/dist/{canonical-log-line-processor--RlFDHhm.cjs → canonical-log-line-processor-CcrDi6TO.cjs}
RENAMED
|
@@ -24,7 +24,7 @@ const SKIP_PREFIXES = [
|
|
|
24
24
|
"service.",
|
|
25
25
|
"autotel."
|
|
26
26
|
];
|
|
27
|
-
const SKIP_KEYS = new Set([
|
|
27
|
+
const SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
28
28
|
"operation",
|
|
29
29
|
"traceId",
|
|
30
30
|
"spanId",
|
|
@@ -374,4 +374,4 @@ Object.defineProperty(exports, 'formatDuration', {
|
|
|
374
374
|
return formatDuration;
|
|
375
375
|
}
|
|
376
376
|
});
|
|
377
|
-
//# sourceMappingURL=canonical-log-line-processor
|
|
377
|
+
//# sourceMappingURL=canonical-log-line-processor-CcrDi6TO.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-log-line-processor--RlFDHhm.cjs","names":["logs","SeverityNumber"],"sources":["../src/pretty-log-formatter.ts","../src/processors/canonical-log-line-processor.ts"],"sourcesContent":["import type { CanonicalLogLineEvent } from './processors/canonical-log-line-processor';\n\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\nconst BOLD = '\\x1b[1m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\nconst GRAY = '\\x1b[90m';\n\nconst LEVEL_COLORS: Record<string, string> = {\n debug: GRAY,\n info: GREEN,\n warn: YELLOW,\n error: RED,\n};\n\n/** Internal OTel attributes to skip in pretty output. */\nconst SKIP_PREFIXES = [\n 'telemetry.',\n 'otel.',\n 'process.',\n 'os.',\n 'host.',\n 'service.',\n 'autotel.',\n];\n\nconst SKIP_KEYS = new Set([\n 'operation',\n 'traceId',\n 'spanId',\n 'correlationId',\n 'duration_ms',\n 'duration',\n 'status_code',\n 'status_message',\n 'timestamp',\n 'http.request.method',\n 'url.path',\n 'http.route',\n 'http.response.status_code',\n]);\n\nfunction useColor(): boolean {\n if (typeof process !== 'undefined') {\n if (process.env.NO_COLOR) return false;\n if (process.env.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n }\n return false;\n}\n\nfunction c(color: string, text: string): string {\n return useColor() ? `${color}${text}${RESET}` : text;\n}\n\n/**\n * Format milliseconds into a human-readable duration string.\n *\n * @example\n * formatDuration(45) // \"45ms\"\n * formatDuration(1234) // \"1.2s\"\n * formatDuration(65000) // \"1m 5s\"\n */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) {\n const seconds = ms / 1000;\n return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n return d.toLocaleTimeString('en-GB', { hour12: false });\n } catch {\n return iso.slice(11, 19);\n }\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n if (value == null) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Group flat dot-notation attributes into a nested tree for pretty display.\n * e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }\n */\nfunction groupAttributes(\n event: Record<string, unknown>,\n): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (SKIP_KEYS.has(key)) continue;\n if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;\n if (value == null || value === '') continue;\n\n const parts = key.split('.');\n if (parts.length === 1) {\n tree[key] = value;\n } else {\n let current = tree;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i]!;\n if (!(part in current) || typeof current[part] !== 'object') {\n current[part] = {};\n }\n current = current[part] as Record<string, unknown>;\n }\n current[parts[parts.length - 1]!] = value;\n }\n }\n\n return tree;\n}\n\nfunction renderTree(\n obj: Record<string, unknown>,\n indent: string,\n isLast: boolean[],\n): string[] {\n const lines: string[] = [];\n const entries = Object.entries(obj);\n\n entries.forEach(([key, value], idx) => {\n const last = idx === entries.length - 1;\n const connector = last ? '\\u2514\\u2500' : '\\u251c\\u2500';\n const prefix = indent + connector + ' ';\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const nested = value as Record<string, unknown>;\n const flatValues = Object.entries(nested).filter(\n ([, v]) => typeof v !== 'object' || v === null,\n );\n const nestedObjs = Object.entries(nested).filter(\n ([, v]) => typeof v === 'object' && v !== null && !Array.isArray(v),\n );\n\n if (nestedObjs.length === 0) {\n const inline = flatValues\n .map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`)\n .join(' ');\n lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);\n } else {\n lines.push(`${prefix}${c(BOLD, key)}:`);\n const nextIndent = indent + (last ? ' ' : '\\u2502 ');\n lines.push(...renderTree(nested, nextIndent, [...isLast, last]));\n }\n } else {\n lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);\n }\n });\n\n return lines;\n}\n\n/**\n * Format a canonical log line event as a pretty tree for development output.\n */\nexport function formatPrettyLogLine(ctx: CanonicalLogLineEvent): string {\n const { event, level, message } = ctx;\n\n const timestamp = formatTime(String(event.timestamp ?? ''));\n const service = event['service.name'] || event.service || '';\n const method = event['http.request.method'] || '';\n const path = event['http.route'] || event['url.path'] || '';\n const status = event['http.response.status_code'] || event.status_code || '';\n const durationMs = Number(event.duration_ms ?? 0);\n const duration = formatDuration(durationMs);\n\n const levelColor = LEVEL_COLORS[level] ?? '';\n const levelStr = c(levelColor, level.toUpperCase().padEnd(5));\n\n const parts = [c(DIM, timestamp), levelStr];\n if (service) parts.push(c(DIM, `[${service}]`));\n if (method) parts.push(c(BOLD, String(method)));\n if (path) parts.push(String(path));\n if (status) {\n const statusNum = Number(status);\n const statusColor =\n statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;\n parts.push(c(statusColor, String(status)));\n }\n parts.push(c(DIM, `in ${duration}`));\n\n const header = parts.join(' ');\n\n const tree = groupAttributes(event);\n if (Object.keys(tree).length === 0) {\n return header;\n }\n\n const treeLines = renderTree(tree, ' ', []);\n return [header, ...treeLines].join('\\n');\n}\n","/**\n * Canonical Log Line Processor\n *\n * Automatically emits spans as canonical log lines (wide events) when they end.\n * Implements canonical log line\" pattern: one comprehensive\n * event per request with all context.\n *\n * When a span ends, this processor creates a log record with ALL span attributes,\n * making the span itself the canonical log line that can be queried like structured data.\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Logger } from '../logger';\nimport { formatPrettyLogLine, formatDuration } from '../pretty-log-formatter';\n\n/**\n * Function to redact sensitive attribute values\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\nexport interface CanonicalLogLineEvent {\n span: ReadableSpan;\n level: 'debug' | 'info' | 'warn' | 'error';\n message: string;\n event: Record<string, unknown>;\n}\n\nexport interface KeepCondition {\n /** Keep events where HTTP status >= this value. */\n status?: number;\n /** Keep events where duration_ms >= this value. */\n durationMs?: number;\n /** Keep events matching this path pattern (simple prefix match). */\n path?: string;\n}\n\nexport interface CanonicalLogLineOptions {\n /** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */\n logger?: Logger;\n /** Only emit canonical log lines for root spans (default: false) */\n rootSpansOnly?: boolean;\n /** Minimum log level for canonical log lines (default: 'info') */\n minLevel?: 'debug' | 'info' | 'warn' | 'error';\n /** Custom message format (default: uses span name) */\n messageFormat?: (span: ReadableSpan) => string;\n /** Whether to include resource attributes (default: true) */\n includeResourceAttributes?: boolean;\n /**\n * Attribute redactor function to apply before logging.\n * This ensures sensitive data is redacted in canonical log lines,\n * matching the behavior of attributeRedactor in init().\n */\n attributeRedactor?: AttributeRedactorFn;\n /** Predicate to decide whether to emit (runs after event is built). */\n shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n /**\n * Declarative tail sampling conditions (OR logic). If any condition matches,\n * the event is kept. Ignored when `shouldEmit` is provided.\n *\n * @example\n * keep: [{ status: 500 }, { durationMs: 1000 }]\n */\n keep?: KeepCondition[];\n /** Callback invoked after emit for custom fan-out. */\n drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n /** Handler for drain failures. */\n onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n /**\n * Pretty-print canonical log lines to console in a tree format.\n * Defaults to true when NODE_ENV is 'development'.\n */\n pretty?: boolean;\n}\n\n/**\n * Span processor that automatically emits spans as canonical log lines\n *\n * When a span ends, this processor creates a log record with ALL span attributes.\n * This implements the \"canonical log line\" pattern: one comprehensive event\n * per request with all context, queryable as structured data.\n *\n * **Key Benefits:**\n * - One log line per request with all context (wide event)\n * - High-cardinality, high-dimensionality data for powerful queries\n * - Automatic - no manual logging needed\n * - Works with any logger or OTel Logs API\n *\n * @example Basic usage\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'checkout-api',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n *\n * @example With custom logger\n * ```typescript\n * import pino from 'pino';\n * import { init } from 'autotel';\n *\n * const logger = pino();\n * init({\n * service: 'my-app',\n * logger,\n * canonicalLogLines: {\n * enabled: true,\n * logger, // Use Pino for canonical log lines\n * rootSpansOnly: true,\n * },\n * });\n * ```\n *\n * @example Custom message format\n * ```typescript\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * messageFormat: (span) => {\n * const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';\n * return `${span.name} [${status}]`;\n * },\n * },\n * });\n * ```\n */\nexport class CanonicalLogLineProcessor implements SpanProcessor {\n private logger?: Logger;\n private rootSpansOnly: boolean;\n private minLevel: 'debug' | 'info' | 'warn' | 'error';\n private messageFormat: (span: ReadableSpan) => string;\n private includeResourceAttributes: boolean;\n private attributeRedactor?: AttributeRedactorFn;\n private shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n private drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n private onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n private pretty: boolean;\n private getOTelLogger: (() => ReturnType<typeof logs.getLogger>) | null =\n null;\n\n constructor(options: CanonicalLogLineOptions = {}) {\n this.logger = options.logger;\n this.rootSpansOnly = options.rootSpansOnly ?? false;\n this.minLevel = options.minLevel ?? 'info';\n this.messageFormat =\n options.messageFormat ?? ((span) => `[${span.name}] Request completed`);\n this.includeResourceAttributes = options.includeResourceAttributes ?? true;\n this.attributeRedactor = options.attributeRedactor;\n this.shouldEmit =\n options.shouldEmit ?? this.buildKeepPredicate(options.keep);\n this.drain = options.drain;\n this.onDrainError = options.onDrainError;\n this.pretty =\n options.pretty ??\n (typeof process !== 'undefined' &&\n process.env.NODE_ENV === 'development');\n\n if (!this.logger) {\n this.getOTelLogger = () => logs.getLogger('autotel.canonical-log-line');\n }\n }\n\n private buildKeepPredicate(\n keep?: KeepCondition[],\n ): ((ctx: CanonicalLogLineEvent) => boolean) | undefined {\n if (!keep || keep.length === 0) return undefined;\n\n return (ctx: CanonicalLogLineEvent) => {\n return keep.some((condition) => {\n if (condition.status !== undefined) {\n const httpStatus = Number(\n ctx.event['http.response.status_code'] ?? 0,\n );\n if (httpStatus >= condition.status) return true;\n }\n if (\n condition.durationMs !== undefined &&\n Number(ctx.event.duration_ms ?? 0) >= condition.durationMs\n ) {\n return true;\n }\n if (condition.path !== undefined) {\n const route = String(\n ctx.event['http.route'] ?? ctx.event['url.path'] ?? '',\n );\n if (route.startsWith(condition.path)) return true;\n }\n return false;\n });\n };\n }\n\n onStart(): void {\n // No-op\n }\n\n onEnd(span: ReadableSpan): void {\n if (\n this.rootSpansOnly &&\n span.parentSpanContext?.spanId &&\n !span.parentSpanContext.isRemote\n ) {\n return;\n }\n\n const level = this.getLogLevel(span);\n if (!this.shouldLog(level)) {\n return;\n }\n\n const canonicalLogLine = this.buildCanonicalLogLine(span);\n const message = this.messageFormat(span);\n const eventContext: CanonicalLogLineEvent = {\n span,\n level,\n message,\n event: canonicalLogLine,\n };\n\n if (this.shouldEmit && !this.shouldEmit(eventContext)) return;\n\n if (this.pretty) {\n console.log(formatPrettyLogLine(eventContext));\n }\n\n if (this.logger) {\n this.emitViaLogger(level, message, canonicalLogLine);\n } else if (this.getOTelLogger) {\n const otelLogger = this.getOTelLogger();\n this.emitViaOTel(level, message, canonicalLogLine, otelLogger);\n }\n\n if (this.drain) {\n Promise.resolve(this.drain(eventContext)).catch((error) => {\n if (this.onDrainError) {\n this.onDrainError(error, eventContext);\n return;\n }\n this.reportInternalWarning('canonicalLogLines.drain failed', error);\n });\n }\n }\n\n private buildCanonicalLogLine(span: ReadableSpan): Record<string, unknown> {\n const durationMs = span.duration[0] * 1000 + span.duration[1] / 1_000_000;\n const timestamp = new Date(\n span.startTime[0] * 1000 + span.startTime[1] / 1_000_000,\n ).toISOString();\n\n // Span attributes first so core metadata fields below take precedence\n const canonicalLogLine: Record<string, unknown> = {};\n const attributes = this.redactAttributes(span.attributes);\n Object.assign(canonicalLogLine, attributes);\n\n if (this.includeResourceAttributes) {\n const resourceAttrs = this.redactAttributes(\n span.resource.attributes as Attributes,\n );\n Object.assign(canonicalLogLine, resourceAttrs);\n }\n\n canonicalLogLine.operation = span.name;\n canonicalLogLine.traceId = span.spanContext().traceId;\n canonicalLogLine.spanId = span.spanContext().spanId;\n canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);\n canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;\n canonicalLogLine.duration = formatDuration(durationMs);\n canonicalLogLine.status_code = span.status.code;\n canonicalLogLine.status_message = span.status.message || undefined;\n canonicalLogLine.timestamp = timestamp;\n\n return canonicalLogLine;\n }\n\n private redactAttributes(attributes: Attributes): Record<string, unknown> {\n if (!this.attributeRedactor) {\n return { ...attributes };\n }\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n redacted[key] = this.attributeRedactor(key, value);\n }\n }\n return redacted;\n }\n\n private emitViaLogger(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n ): void {\n this.logger;\n }\n\n private emitViaOTel(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n otelLogger: ReturnType<typeof logs.getLogger>,\n ): void {\n const otelAttributes: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(canonicalLogLine)) {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n otelAttributes[key] = value;\n } else if (value !== null && value !== undefined) {\n otelAttributes[key] = String(value);\n }\n }\n otelLogger.emit({\n severityNumber: this.getSeverityNumber(level),\n severityText: level.toUpperCase(),\n body: message,\n attributes: otelAttributes,\n });\n }\n\n private getLogLevel(span: ReadableSpan): 'debug' | 'info' | 'warn' | 'error' {\n const explicitLevel = span.attributes['autotel.log.level'];\n if (\n explicitLevel === 'debug' ||\n explicitLevel === 'info' ||\n explicitLevel === 'warn' ||\n explicitLevel === 'error'\n ) {\n return explicitLevel;\n }\n\n if (span.status.code === 2) return 'error';\n return 'info';\n }\n\n private shouldLog(level: string): boolean {\n const levels = ['debug', 'info', 'warn', 'error'];\n return levels.indexOf(level) >= levels.indexOf(this.minLevel);\n }\n\n private getSeverityNumber(level: string): SeverityNumber {\n const mapping: Record<string, SeverityNumber> = {\n debug: SeverityNumber.DEBUG,\n info: SeverityNumber.INFO,\n warn: SeverityNumber.WARN,\n error: SeverityNumber.ERROR,\n };\n return mapping[level] ?? SeverityNumber.INFO;\n }\n\n private reportInternalWarning(message: string, error: unknown): void {\n const err =\n error instanceof Error ? error.message : String(error ?? 'unknown error');\n if (this.logger) {\n this.logger.warn({ error: err }, `[autotel] ${message}`);\n return;\n }\n console.warn(`[autotel] ${message}: ${err}`);\n }\n\n async forceFlush(): Promise<void> {\n // No-op\n }\n\n async shutdown(): Promise<void> {\n // No-op\n }\n}\n"],"mappings":";;;AAEA,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,QAAQ;AACd,MAAM,OAAO;AAGb,MAAM,eAAuC;CAC3C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;AACT;;AAGA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,YAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,WAAoB;CAC3B,IAAI,OAAO,YAAY,aAAa;EAClC,IAAI,QAAQ,IAAI,UAAU,OAAO;EACjC,IAAI,QAAQ,IAA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kB,WAClB,kBAAkB,UAClB,kBAAkB,UAClB,kBAAkB,SAElB,OAAO;EAGT,IAAI,KAAK,OAAO,SAAS,GAAG,OAAO;EACnC,OAAO;CACT;CAEA,AAAQ,UAAU,OAAwB;EACxC,MAAM,SAAS;GAAC;GAAS;GAAQ;GAAQ;EAAO;EAChD,OAAO,OAAO,QAAQ,KAAK,KAAK,OAAO,QAAQ,KAAK,QAAQ;CAC9D;CAEA,AAAQ,kBAAkB,OAA+B;EAOvD,OAAO;GALL,OAAOC,uCAAe;GACtB,MAAMA,uCAAe;GACrB,MAAMA,uCAAe;GACrB,OAAOA,uCAAe;EAEX,EAAE,UAAUA,uCAAe;CAC1C;CAEA,AAAQ,sBAAsB,SAAiB,OAAsB;EACnE,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,eAAe;EAC1E,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,aAAa,SAAS;GACvD;EACF;EACA,QAAQ,KAAK,aAAa,QAAQ,IAAI,KAAK;CAC7C;CAEA,MAAM,aAA4B,CAElC;CAEA,MAAM,WAA0B,CAEhC;AACF"}
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-CcrDi6TO.cjs","names":["logs","SeverityNumber"],"sources":["../src/pretty-log-formatter.ts","../src/processors/canonical-log-line-processor.ts"],"sourcesContent":["import type { CanonicalLogLineEvent } from './processors/canonical-log-line-processor';\n\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\nconst BOLD = '\\x1b[1m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\nconst GRAY = '\\x1b[90m';\n\nconst LEVEL_COLORS: Record<string, string> = {\n debug: GRAY,\n info: GREEN,\n warn: YELLOW,\n error: RED,\n};\n\n/** Internal OTel attributes to skip in pretty output. */\nconst SKIP_PREFIXES = [\n 'telemetry.',\n 'otel.',\n 'process.',\n 'os.',\n 'host.',\n 'service.',\n 'autotel.',\n];\n\nconst SKIP_KEYS = new Set([\n 'operation',\n 'traceId',\n 'spanId',\n 'correlationId',\n 'duration_ms',\n 'duration',\n 'status_code',\n 'status_message',\n 'timestamp',\n 'http.request.method',\n 'url.path',\n 'http.route',\n 'http.response.status_code',\n]);\n\nfunction useColor(): boolean {\n if (typeof process !== 'undefined') {\n if (process.env.NO_COLOR) return false;\n if (process.env.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n }\n return false;\n}\n\nfunction c(color: string, text: string): string {\n return useColor() ? `${color}${text}${RESET}` : text;\n}\n\n/**\n * Format milliseconds into a human-readable duration string.\n *\n * @example\n * formatDuration(45) // \"45ms\"\n * formatDuration(1234) // \"1.2s\"\n * formatDuration(65000) // \"1m 5s\"\n */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) {\n const seconds = ms / 1000;\n return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n return d.toLocaleTimeString('en-GB', { hour12: false });\n } catch {\n return iso.slice(11, 19);\n }\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n if (value == null) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Group flat dot-notation attributes into a nested tree for pretty display.\n * e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }\n */\nfunction groupAttributes(\n event: Record<string, unknown>,\n): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (SKIP_KEYS.has(key)) continue;\n if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;\n if (value == null || value === '') continue;\n\n const parts = key.split('.');\n if (parts.length === 1) {\n tree[key] = value;\n } else {\n let current = tree;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i]!;\n if (!(part in current) || typeof current[part] !== 'object') {\n current[part] = {};\n }\n current = current[part] as Record<string, unknown>;\n }\n current[parts[parts.length - 1]!] = value;\n }\n }\n\n return tree;\n}\n\nfunction renderTree(\n obj: Record<string, unknown>,\n indent: string,\n isLast: boolean[],\n): string[] {\n const lines: string[] = [];\n const entries = Object.entries(obj);\n\n entries.forEach(([key, value], idx) => {\n const last = idx === entries.length - 1;\n const connector = last ? '\\u2514\\u2500' : '\\u251c\\u2500';\n const prefix = indent + connector + ' ';\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const nested = value as Record<string, unknown>;\n const flatValues = Object.entries(nested).filter(\n ([, v]) => typeof v !== 'object' || v === null,\n );\n const nestedObjs = Object.entries(nested).filter(\n ([, v]) => typeof v === 'object' && v !== null && !Array.isArray(v),\n );\n\n if (nestedObjs.length === 0) {\n const inline = flatValues\n .map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`)\n .join(' ');\n lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);\n } else {\n lines.push(`${prefix}${c(BOLD, key)}:`);\n const nextIndent = indent + (last ? ' ' : '\\u2502 ');\n lines.push(...renderTree(nested, nextIndent, [...isLast, last]));\n }\n } else {\n lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);\n }\n });\n\n return lines;\n}\n\n/**\n * Format a canonical log line event as a pretty tree for development output.\n */\nexport function formatPrettyLogLine(ctx: CanonicalLogLineEvent): string {\n const { event, level, message } = ctx;\n\n const timestamp = formatTime(String(event.timestamp ?? ''));\n const service = event['service.name'] || event.service || '';\n const method = event['http.request.method'] || '';\n const path = event['http.route'] || event['url.path'] || '';\n const status = event['http.response.status_code'] || event.status_code || '';\n const durationMs = Number(event.duration_ms ?? 0);\n const duration = formatDuration(durationMs);\n\n const levelColor = LEVEL_COLORS[level] ?? '';\n const levelStr = c(levelColor, level.toUpperCase().padEnd(5));\n\n const parts = [c(DIM, timestamp), levelStr];\n if (service) parts.push(c(DIM, `[${service}]`));\n if (method) parts.push(c(BOLD, String(method)));\n if (path) parts.push(String(path));\n if (status) {\n const statusNum = Number(status);\n const statusColor =\n statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;\n parts.push(c(statusColor, String(status)));\n }\n parts.push(c(DIM, `in ${duration}`));\n\n const header = parts.join(' ');\n\n const tree = groupAttributes(event);\n if (Object.keys(tree).length === 0) {\n return header;\n }\n\n const treeLines = renderTree(tree, ' ', []);\n return [header, ...treeLines].join('\\n');\n}\n","/**\n * Canonical Log Line Processor\n *\n * Automatically emits spans as canonical log lines (wide events) when they end.\n * Implements canonical log line\" pattern: one comprehensive\n * event per request with all context.\n *\n * When a span ends, this processor creates a log record with ALL span attributes,\n * making the span itself the canonical log line that can be queried like structured data.\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Logger } from '../logger';\nimport { formatPrettyLogLine, formatDuration } from '../pretty-log-formatter';\n\n/**\n * Function to redact sensitive attribute values\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\nexport interface CanonicalLogLineEvent {\n span: ReadableSpan;\n level: 'debug' | 'info' | 'warn' | 'error';\n message: string;\n event: Record<string, unknown>;\n}\n\nexport interface KeepCondition {\n /** Keep events where HTTP status >= this value. */\n status?: number;\n /** Keep events where duration_ms >= this value. */\n durationMs?: number;\n /** Keep events matching this path pattern (simple prefix match). */\n path?: string;\n}\n\nexport interface CanonicalLogLineOptions {\n /** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */\n logger?: Logger;\n /** Only emit canonical log lines for root spans (default: false) */\n rootSpansOnly?: boolean;\n /** Minimum log level for canonical log lines (default: 'info') */\n minLevel?: 'debug' | 'info' | 'warn' | 'error';\n /** Custom message format (default: uses span name) */\n messageFormat?: (span: ReadableSpan) => string;\n /** Whether to include resource attributes (default: true) */\n includeResourceAttributes?: boolean;\n /**\n * Attribute redactor function to apply before logging.\n * This ensures sensitive data is redacted in canonical log lines,\n * matching the behavior of attributeRedactor in init().\n */\n attributeRedactor?: AttributeRedactorFn;\n /** Predicate to decide whether to emit (runs after event is built). */\n shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n /**\n * Declarative tail sampling conditions (OR logic). If any condition matches,\n * the event is kept. Ignored when `shouldEmit` is provided.\n *\n * @example\n * keep: [{ status: 500 }, { durationMs: 1000 }]\n */\n keep?: KeepCondition[];\n /** Callback invoked after emit for custom fan-out. */\n drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n /** Handler for drain failures. */\n onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n /**\n * Pretty-print canonical log lines to console in a tree format.\n * Defaults to true when NODE_ENV is 'development'.\n */\n pretty?: boolean;\n}\n\n/**\n * Span processor that automatically emits spans as canonical log lines\n *\n * When a span ends, this processor creates a log record with ALL span attributes.\n * This implements the \"canonical log line\" pattern: one comprehensive event\n * per request with all context, queryable as structured data.\n *\n * **Key Benefits:**\n * - One log line per request with all context (wide event)\n * - High-cardinality, high-dimensionality data for powerful queries\n * - Automatic - no manual logging needed\n * - Works with any logger or OTel Logs API\n *\n * @example Basic usage\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'checkout-api',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n *\n * @example With custom logger\n * ```typescript\n * import pino from 'pino';\n * import { init } from 'autotel';\n *\n * const logger = pino();\n * init({\n * service: 'my-app',\n * logger,\n * canonicalLogLines: {\n * enabled: true,\n * logger, // Use Pino for canonical log lines\n * rootSpansOnly: true,\n * },\n * });\n * ```\n *\n * @example Custom message format\n * ```typescript\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * messageFormat: (span) => {\n * const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';\n * return `${span.name} [${status}]`;\n * },\n * },\n * });\n * ```\n */\nexport class CanonicalLogLineProcessor implements SpanProcessor {\n private logger?: Logger;\n private rootSpansOnly: boolean;\n private minLevel: 'debug' | 'info' | 'warn' | 'error';\n private messageFormat: (span: ReadableSpan) => string;\n private includeResourceAttributes: boolean;\n private attributeRedactor?: AttributeRedactorFn;\n private shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n private drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n private onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n private pretty: boolean;\n private getOTelLogger: (() => ReturnType<typeof logs.getLogger>) | null =\n null;\n\n constructor(options: CanonicalLogLineOptions = {}) {\n this.logger = options.logger;\n this.rootSpansOnly = options.rootSpansOnly ?? false;\n this.minLevel = options.minLevel ?? 'info';\n this.messageFormat =\n options.messageFormat ?? ((span) => `[${span.name}] Request completed`);\n this.includeResourceAttributes = options.includeResourceAttributes ?? true;\n this.attributeRedactor = options.attributeRedactor;\n this.shouldEmit =\n options.shouldEmit ?? this.buildKeepPredicate(options.keep);\n this.drain = options.drain;\n this.onDrainError = options.onDrainError;\n this.pretty =\n options.pretty ??\n (typeof process !== 'undefined' &&\n process.env.NODE_ENV === 'development');\n\n if (!this.logger) {\n this.getOTelLogger = () => logs.getLogger('autotel.canonical-log-line');\n }\n }\n\n private buildKeepPredicate(\n keep?: KeepCondition[],\n ): ((ctx: CanonicalLogLineEvent) => boolean) | undefined {\n if (!keep || keep.length === 0) return undefined;\n\n return (ctx: CanonicalLogLineEvent) => {\n return keep.some((condition) => {\n if (condition.status !== undefined) {\n const httpStatus = Number(\n ctx.event['http.response.status_code'] ?? 0,\n );\n if (httpStatus >= condition.status) return true;\n }\n if (\n condition.durationMs !== undefined &&\n Number(ctx.event.duration_ms ?? 0) >= condition.durationMs\n ) {\n return true;\n }\n if (condition.path !== undefined) {\n const route = String(\n ctx.event['http.route'] ?? ctx.event['url.path'] ?? '',\n );\n if (route.startsWith(condition.path)) return true;\n }\n return false;\n });\n };\n }\n\n onStart(): void {\n // No-op\n }\n\n onEnd(span: ReadableSpan): void {\n if (\n this.rootSpansOnly &&\n span.parentSpanContext?.spanId &&\n !span.parentSpanContext.isRemote\n ) {\n return;\n }\n\n const level = this.getLogLevel(span);\n if (!this.shouldLog(level)) {\n return;\n }\n\n const canonicalLogLine = this.buildCanonicalLogLine(span);\n const message = this.messageFormat(span);\n const eventContext: CanonicalLogLineEvent = {\n span,\n level,\n message,\n event: canonicalLogLine,\n };\n\n if (this.shouldEmit && !this.shouldEmit(eventContext)) return;\n\n if (this.pretty) {\n console.log(formatPrettyLogLine(eventContext));\n }\n\n if (this.logger) {\n this.emitViaLogger(level, message, canonicalLogLine);\n } else if (this.getOTelLogger) {\n const otelLogger = this.getOTelLogger();\n this.emitViaOTel(level, message, canonicalLogLine, otelLogger);\n }\n\n if (this.drain) {\n Promise.resolve(this.drain(eventContext)).catch((error) => {\n if (this.onDrainError) {\n this.onDrainError(error, eventContext);\n return;\n }\n this.reportInternalWarning('canonicalLogLines.drain failed', error);\n });\n }\n }\n\n private buildCanonicalLogLine(span: ReadableSpan): Record<string, unknown> {\n const durationMs = span.duration[0] * 1000 + span.duration[1] / 1_000_000;\n const timestamp = new Date(\n span.startTime[0] * 1000 + span.startTime[1] / 1_000_000,\n ).toISOString();\n\n // Span attributes first so core metadata fields below take precedence\n const canonicalLogLine: Record<string, unknown> = {};\n const attributes = this.redactAttributes(span.attributes);\n Object.assign(canonicalLogLine, attributes);\n\n if (this.includeResourceAttributes) {\n const resourceAttrs = this.redactAttributes(\n span.resource.attributes as Attributes,\n );\n Object.assign(canonicalLogLine, resourceAttrs);\n }\n\n canonicalLogLine.operation = span.name;\n canonicalLogLine.traceId = span.spanContext().traceId;\n canonicalLogLine.spanId = span.spanContext().spanId;\n canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);\n canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;\n canonicalLogLine.duration = formatDuration(durationMs);\n canonicalLogLine.status_code = span.status.code;\n canonicalLogLine.status_message = span.status.message || undefined;\n canonicalLogLine.timestamp = timestamp;\n\n return canonicalLogLine;\n }\n\n private redactAttributes(attributes: Attributes): Record<string, unknown> {\n if (!this.attributeRedactor) {\n return { ...attributes };\n }\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n redacted[key] = this.attributeRedactor(key, value);\n }\n }\n return redacted;\n }\n\n private emitViaLogger(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n ): void {\n this.logger;\n }\n\n private emitViaOTel(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n otelLogger: ReturnType<typeof logs.getLogger>,\n ): void {\n const otelAttributes: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(canonicalLogLine)) {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n otelAttributes[key] = value;\n } else if (value !== null && value !== undefined) {\n otelAttributes[key] = String(value);\n }\n }\n otelLogger.emit({\n severityNumber: this.getSeverityNumber(level),\n severityText: level.toUpperCase(),\n body: message,\n attributes: otelAttributes,\n });\n }\n\n private getLogLevel(span: ReadableSpan): 'debug' | 'info' | 'warn' | 'error' {\n const explicitLevel = span.attributes['autotel.log.level'];\n if (\n explicitLevel === 'debug' ||\n explicitLevel === 'info' ||\n explicitLevel === 'warn' ||\n explicitLevel === 'error'\n ) {\n return explicitLevel;\n }\n\n if (span.status.code === 2) return 'error';\n return 'info';\n }\n\n private shouldLog(level: string): boolean {\n const levels = ['debug', 'info', 'warn', 'error'];\n return levels.indexOf(level) >= levels.indexOf(this.minLevel);\n }\n\n private getSeverityNumber(level: string): SeverityNumber {\n const mapping: Record<string, SeverityNumber> = {\n debug: SeverityNumber.DEBUG,\n info: SeverityNumber.INFO,\n warn: SeverityNumber.WARN,\n error: SeverityNumber.ERROR,\n };\n return mapping[level] ?? SeverityNumber.INFO;\n }\n\n private reportInternalWarning(message: string, error: unknown): void {\n const err =\n error instanceof Error ? error.message : String(error ?? 'unknown error');\n if (this.logger) {\n this.logger.warn({ error: err }, `[autotel] ${message}`);\n return;\n }\n console.warn(`[autotel] ${message}: ${err}`);\n }\n\n async forceFlush(): Promise<void> {\n // No-op\n }\n\n async shutdown(): Promise<void> {\n // No-op\n }\n}\n"],"mappings":";;;AAEA,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,QAAQ;AACd,MAAM,OAAO;AAGb,MAAM,eAAuC;CAC3C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;AACT;;AAGA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,WAAoB;CAC3B,IAAI,OAAO,YAAY,aAAa;EAClC,IAAI,QAAQ,IAAI,UAAU,OAAO;EACjC,IAAI,QAAQ,IAAI,aAAa,OAAO;EACpC,IAAI,QAAQ,QAAQ,OAAO,OAAO;CACpC;CACA,OAAO;AACT;AAEA,SAAS,EAAE,OAAe,MAAsB;CAC9C,OAAO,SAAS,IAAI,GAAG,QAAQ,OAAO,UAAU;AAClD;;;;;;;;;AAUA,SAAgB,eAAe,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AO;EAChD,OAAO,OAAO,QAAQ,KAAK,KAAK,OAAO,QAAQ,KAAK,QAAQ;CAC9D;CAEA,AAAQ,kBAAkB,OAA+B;EAOvD,OAAO;GALL,OAAOC,uCAAe;GACtB,MAAMA,uCAAe;GACrB,MAAMA,uCAAe;GACrB,OAAOA,uCAAe;EAEX,EAAE,UAAUA,uCAAe;CAC1C;CAEA,AAAQ,sBAAsB,SAAiB,OAAsB;EACnE,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,eAAe;EAC1E,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,aAAa,SAAS;GACvD;EACF;EACA,QAAQ,KAAK,aAAa,QAAQ,IAAI,KAAK;CAC7C;CAEA,MAAM,aAA4B,CAElC;CAEA,MAAM,WAA0B,CAEhC;AACF"}
|
package/dist/{canonical-log-line-processor-DbBQT5vY.js → canonical-log-line-processor-FLezvFCB.js}
RENAMED
|
@@ -24,7 +24,7 @@ const SKIP_PREFIXES = [
|
|
|
24
24
|
"service.",
|
|
25
25
|
"autotel."
|
|
26
26
|
];
|
|
27
|
-
const SKIP_KEYS = new Set([
|
|
27
|
+
const SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
28
28
|
"operation",
|
|
29
29
|
"traceId",
|
|
30
30
|
"spanId",
|
|
@@ -363,4 +363,4 @@ var CanonicalLogLineProcessor = class {
|
|
|
363
363
|
|
|
364
364
|
//#endregion
|
|
365
365
|
export { formatDuration as n, CanonicalLogLineProcessor as t };
|
|
366
|
-
//# sourceMappingURL=canonical-log-line-processor-
|
|
366
|
+
//# sourceMappingURL=canonical-log-line-processor-FLezvFCB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-log-line-processor-DbBQT5vY.js","names":[],"sources":["../src/pretty-log-formatter.ts","../src/processors/canonical-log-line-processor.ts"],"sourcesContent":["import type { CanonicalLogLineEvent } from './processors/canonical-log-line-processor';\n\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\nconst BOLD = '\\x1b[1m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\nconst GRAY = '\\x1b[90m';\n\nconst LEVEL_COLORS: Record<string, string> = {\n debug: GRAY,\n info: GREEN,\n warn: YELLOW,\n error: RED,\n};\n\n/** Internal OTel attributes to skip in pretty output. */\nconst SKIP_PREFIXES = [\n 'telemetry.',\n 'otel.',\n 'process.',\n 'os.',\n 'host.',\n 'service.',\n 'autotel.',\n];\n\nconst SKIP_KEYS = new Set([\n 'operation',\n 'traceId',\n 'spanId',\n 'correlationId',\n 'duration_ms',\n 'duration',\n 'status_code',\n 'status_message',\n 'timestamp',\n 'http.request.method',\n 'url.path',\n 'http.route',\n 'http.response.status_code',\n]);\n\nfunction useColor(): boolean {\n if (typeof process !== 'undefined') {\n if (process.env.NO_COLOR) return false;\n if (process.env.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n }\n return false;\n}\n\nfunction c(color: string, text: string): string {\n return useColor() ? `${color}${text}${RESET}` : text;\n}\n\n/**\n * Format milliseconds into a human-readable duration string.\n *\n * @example\n * formatDuration(45) // \"45ms\"\n * formatDuration(1234) // \"1.2s\"\n * formatDuration(65000) // \"1m 5s\"\n */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) {\n const seconds = ms / 1000;\n return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n return d.toLocaleTimeString('en-GB', { hour12: false });\n } catch {\n return iso.slice(11, 19);\n }\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n if (value == null) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Group flat dot-notation attributes into a nested tree for pretty display.\n * e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }\n */\nfunction groupAttributes(\n event: Record<string, unknown>,\n): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (SKIP_KEYS.has(key)) continue;\n if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;\n if (value == null || value === '') continue;\n\n const parts = key.split('.');\n if (parts.length === 1) {\n tree[key] = value;\n } else {\n let current = tree;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i]!;\n if (!(part in current) || typeof current[part] !== 'object') {\n current[part] = {};\n }\n current = current[part] as Record<string, unknown>;\n }\n current[parts[parts.length - 1]!] = value;\n }\n }\n\n return tree;\n}\n\nfunction renderTree(\n obj: Record<string, unknown>,\n indent: string,\n isLast: boolean[],\n): string[] {\n const lines: string[] = [];\n const entries = Object.entries(obj);\n\n entries.forEach(([key, value], idx) => {\n const last = idx === entries.length - 1;\n const connector = last ? '\\u2514\\u2500' : '\\u251c\\u2500';\n const prefix = indent + connector + ' ';\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const nested = value as Record<string, unknown>;\n const flatValues = Object.entries(nested).filter(\n ([, v]) => typeof v !== 'object' || v === null,\n );\n const nestedObjs = Object.entries(nested).filter(\n ([, v]) => typeof v === 'object' && v !== null && !Array.isArray(v),\n );\n\n if (nestedObjs.length === 0) {\n const inline = flatValues\n .map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`)\n .join(' ');\n lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);\n } else {\n lines.push(`${prefix}${c(BOLD, key)}:`);\n const nextIndent = indent + (last ? ' ' : '\\u2502 ');\n lines.push(...renderTree(nested, nextIndent, [...isLast, last]));\n }\n } else {\n lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);\n }\n });\n\n return lines;\n}\n\n/**\n * Format a canonical log line event as a pretty tree for development output.\n */\nexport function formatPrettyLogLine(ctx: CanonicalLogLineEvent): string {\n const { event, level, message } = ctx;\n\n const timestamp = formatTime(String(event.timestamp ?? ''));\n const service = event['service.name'] || event.service || '';\n const method = event['http.request.method'] || '';\n const path = event['http.route'] || event['url.path'] || '';\n const status = event['http.response.status_code'] || event.status_code || '';\n const durationMs = Number(event.duration_ms ?? 0);\n const duration = formatDuration(durationMs);\n\n const levelColor = LEVEL_COLORS[level] ?? '';\n const levelStr = c(levelColor, level.toUpperCase().padEnd(5));\n\n const parts = [c(DIM, timestamp), levelStr];\n if (service) parts.push(c(DIM, `[${service}]`));\n if (method) parts.push(c(BOLD, String(method)));\n if (path) parts.push(String(path));\n if (status) {\n const statusNum = Number(status);\n const statusColor =\n statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;\n parts.push(c(statusColor, String(status)));\n }\n parts.push(c(DIM, `in ${duration}`));\n\n const header = parts.join(' ');\n\n const tree = groupAttributes(event);\n if (Object.keys(tree).length === 0) {\n return header;\n }\n\n const treeLines = renderTree(tree, ' ', []);\n return [header, ...treeLines].join('\\n');\n}\n","/**\n * Canonical Log Line Processor\n *\n * Automatically emits spans as canonical log lines (wide events) when they end.\n * Implements canonical log line\" pattern: one comprehensive\n * event per request with all context.\n *\n * When a span ends, this processor creates a log record with ALL span attributes,\n * making the span itself the canonical log line that can be queried like structured data.\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Logger } from '../logger';\nimport { formatPrettyLogLine, formatDuration } from '../pretty-log-formatter';\n\n/**\n * Function to redact sensitive attribute values\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\nexport interface CanonicalLogLineEvent {\n span: ReadableSpan;\n level: 'debug' | 'info' | 'warn' | 'error';\n message: string;\n event: Record<string, unknown>;\n}\n\nexport interface KeepCondition {\n /** Keep events where HTTP status >= this value. */\n status?: number;\n /** Keep events where duration_ms >= this value. */\n durationMs?: number;\n /** Keep events matching this path pattern (simple prefix match). */\n path?: string;\n}\n\nexport interface CanonicalLogLineOptions {\n /** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */\n logger?: Logger;\n /** Only emit canonical log lines for root spans (default: false) */\n rootSpansOnly?: boolean;\n /** Minimum log level for canonical log lines (default: 'info') */\n minLevel?: 'debug' | 'info' | 'warn' | 'error';\n /** Custom message format (default: uses span name) */\n messageFormat?: (span: ReadableSpan) => string;\n /** Whether to include resource attributes (default: true) */\n includeResourceAttributes?: boolean;\n /**\n * Attribute redactor function to apply before logging.\n * This ensures sensitive data is redacted in canonical log lines,\n * matching the behavior of attributeRedactor in init().\n */\n attributeRedactor?: AttributeRedactorFn;\n /** Predicate to decide whether to emit (runs after event is built). */\n shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n /**\n * Declarative tail sampling conditions (OR logic). If any condition matches,\n * the event is kept. Ignored when `shouldEmit` is provided.\n *\n * @example\n * keep: [{ status: 500 }, { durationMs: 1000 }]\n */\n keep?: KeepCondition[];\n /** Callback invoked after emit for custom fan-out. */\n drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n /** Handler for drain failures. */\n onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n /**\n * Pretty-print canonical log lines to console in a tree format.\n * Defaults to true when NODE_ENV is 'development'.\n */\n pretty?: boolean;\n}\n\n/**\n * Span processor that automatically emits spans as canonical log lines\n *\n * When a span ends, this processor creates a log record with ALL span attributes.\n * This implements the \"canonical log line\" pattern: one comprehensive event\n * per request with all context, queryable as structured data.\n *\n * **Key Benefits:**\n * - One log line per request with all context (wide event)\n * - High-cardinality, high-dimensionality data for powerful queries\n * - Automatic - no manual logging needed\n * - Works with any logger or OTel Logs API\n *\n * @example Basic usage\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'checkout-api',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n *\n * @example With custom logger\n * ```typescript\n * import pino from 'pino';\n * import { init } from 'autotel';\n *\n * const logger = pino();\n * init({\n * service: 'my-app',\n * logger,\n * canonicalLogLines: {\n * enabled: true,\n * logger, // Use Pino for canonical log lines\n * rootSpansOnly: true,\n * },\n * });\n * ```\n *\n * @example Custom message format\n * ```typescript\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * messageFormat: (span) => {\n * const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';\n * return `${span.name} [${status}]`;\n * },\n * },\n * });\n * ```\n */\nexport class CanonicalLogLineProcessor implements SpanProcessor {\n private logger?: Logger;\n private rootSpansOnly: boolean;\n private minLevel: 'debug' | 'info' | 'warn' | 'error';\n private messageFormat: (span: ReadableSpan) => string;\n private includeResourceAttributes: boolean;\n private attributeRedactor?: AttributeRedactorFn;\n private shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n private drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n private onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n private pretty: boolean;\n private getOTelLogger: (() => ReturnType<typeof logs.getLogger>) | null =\n null;\n\n constructor(options: CanonicalLogLineOptions = {}) {\n this.logger = options.logger;\n this.rootSpansOnly = options.rootSpansOnly ?? false;\n this.minLevel = options.minLevel ?? 'info';\n this.messageFormat =\n options.messageFormat ?? ((span) => `[${span.name}] Request completed`);\n this.includeResourceAttributes = options.includeResourceAttributes ?? true;\n this.attributeRedactor = options.attributeRedactor;\n this.shouldEmit =\n options.shouldEmit ?? this.buildKeepPredicate(options.keep);\n this.drain = options.drain;\n this.onDrainError = options.onDrainError;\n this.pretty =\n options.pretty ??\n (typeof process !== 'undefined' &&\n process.env.NODE_ENV === 'development');\n\n if (!this.logger) {\n this.getOTelLogger = () => logs.getLogger('autotel.canonical-log-line');\n }\n }\n\n private buildKeepPredicate(\n keep?: KeepCondition[],\n ): ((ctx: CanonicalLogLineEvent) => boolean) | undefined {\n if (!keep || keep.length === 0) return undefined;\n\n return (ctx: CanonicalLogLineEvent) => {\n return keep.some((condition) => {\n if (condition.status !== undefined) {\n const httpStatus = Number(\n ctx.event['http.response.status_code'] ?? 0,\n );\n if (httpStatus >= condition.status) return true;\n }\n if (\n condition.durationMs !== undefined &&\n Number(ctx.event.duration_ms ?? 0) >= condition.durationMs\n ) {\n return true;\n }\n if (condition.path !== undefined) {\n const route = String(\n ctx.event['http.route'] ?? ctx.event['url.path'] ?? '',\n );\n if (route.startsWith(condition.path)) return true;\n }\n return false;\n });\n };\n }\n\n onStart(): void {\n // No-op\n }\n\n onEnd(span: ReadableSpan): void {\n if (\n this.rootSpansOnly &&\n span.parentSpanContext?.spanId &&\n !span.parentSpanContext.isRemote\n ) {\n return;\n }\n\n const level = this.getLogLevel(span);\n if (!this.shouldLog(level)) {\n return;\n }\n\n const canonicalLogLine = this.buildCanonicalLogLine(span);\n const message = this.messageFormat(span);\n const eventContext: CanonicalLogLineEvent = {\n span,\n level,\n message,\n event: canonicalLogLine,\n };\n\n if (this.shouldEmit && !this.shouldEmit(eventContext)) return;\n\n if (this.pretty) {\n console.log(formatPrettyLogLine(eventContext));\n }\n\n if (this.logger) {\n this.emitViaLogger(level, message, canonicalLogLine);\n } else if (this.getOTelLogger) {\n const otelLogger = this.getOTelLogger();\n this.emitViaOTel(level, message, canonicalLogLine, otelLogger);\n }\n\n if (this.drain) {\n Promise.resolve(this.drain(eventContext)).catch((error) => {\n if (this.onDrainError) {\n this.onDrainError(error, eventContext);\n return;\n }\n this.reportInternalWarning('canonicalLogLines.drain failed', error);\n });\n }\n }\n\n private buildCanonicalLogLine(span: ReadableSpan): Record<string, unknown> {\n const durationMs = span.duration[0] * 1000 + span.duration[1] / 1_000_000;\n const timestamp = new Date(\n span.startTime[0] * 1000 + span.startTime[1] / 1_000_000,\n ).toISOString();\n\n // Span attributes first so core metadata fields below take precedence\n const canonicalLogLine: Record<string, unknown> = {};\n const attributes = this.redactAttributes(span.attributes);\n Object.assign(canonicalLogLine, attributes);\n\n if (this.includeResourceAttributes) {\n const resourceAttrs = this.redactAttributes(\n span.resource.attributes as Attributes,\n );\n Object.assign(canonicalLogLine, resourceAttrs);\n }\n\n canonicalLogLine.operation = span.name;\n canonicalLogLine.traceId = span.spanContext().traceId;\n canonicalLogLine.spanId = span.spanContext().spanId;\n canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);\n canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;\n canonicalLogLine.duration = formatDuration(durationMs);\n canonicalLogLine.status_code = span.status.code;\n canonicalLogLine.status_message = span.status.message || undefined;\n canonicalLogLine.timestamp = timestamp;\n\n return canonicalLogLine;\n }\n\n private redactAttributes(attributes: Attributes): Record<string, unknown> {\n if (!this.attributeRedactor) {\n return { ...attributes };\n }\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n redacted[key] = this.attributeRedactor(key, value);\n }\n }\n return redacted;\n }\n\n private emitViaLogger(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n ): void {\n this.logger;\n }\n\n private emitViaOTel(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n otelLogger: ReturnType<typeof logs.getLogger>,\n ): void {\n const otelAttributes: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(canonicalLogLine)) {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n otelAttributes[key] = value;\n } else if (value !== null && value !== undefined) {\n otelAttributes[key] = String(value);\n }\n }\n otelLogger.emit({\n severityNumber: this.getSeverityNumber(level),\n severityText: level.toUpperCase(),\n body: message,\n attributes: otelAttributes,\n });\n }\n\n private getLogLevel(span: ReadableSpan): 'debug' | 'info' | 'warn' | 'error' {\n const explicitLevel = span.attributes['autotel.log.level'];\n if (\n explicitLevel === 'debug' ||\n explicitLevel === 'info' ||\n explicitLevel === 'warn' ||\n explicitLevel === 'error'\n ) {\n return explicitLevel;\n }\n\n if (span.status.code === 2) return 'error';\n return 'info';\n }\n\n private shouldLog(level: string): boolean {\n const levels = ['debug', 'info', 'warn', 'error'];\n return levels.indexOf(level) >= levels.indexOf(this.minLevel);\n }\n\n private getSeverityNumber(level: string): SeverityNumber {\n const mapping: Record<string, SeverityNumber> = {\n debug: SeverityNumber.DEBUG,\n info: SeverityNumber.INFO,\n warn: SeverityNumber.WARN,\n error: SeverityNumber.ERROR,\n };\n return mapping[level] ?? SeverityNumber.INFO;\n }\n\n private reportInternalWarning(message: string, error: unknown): void {\n const err =\n error instanceof Error ? error.message : String(error ?? 'unknown error');\n if (this.logger) {\n this.logger.warn({ error: err }, `[autotel] ${message}`);\n return;\n }\n console.warn(`[autotel] ${message}: ${err}`);\n }\n\n async forceFlush(): Promise<void> {\n // No-op\n }\n\n async shutdown(): Promise<void> {\n // No-op\n }\n}\n"],"mappings":";;;AAEA,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,QAAQ;AACd,MAAM,OAAO;AAGb,MAAM,eAAuC;CAC3C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;AACT;;AAGA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,YAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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cAAc,MAAM,YAAY;GAChC,MAAM;GACN,YAAY;EACd,CAAC;CACH;CAEA,AAAQ,YAAY,MAAyD;EAC3E,MAAM,gBAAgB,KAAK,WAAW;EACtC,IACE,kBAAkB,WAClB,kBAAkB,UAClB,kBAAkB,UAClB,kBAAkB,SAElB,OAAO;EAGT,IAAI,KAAK,OAAO,SAAS,GAAG,OAAO;EACnC,OAAO;CACT;CAEA,AAAQ,UAAU,OAAwB;EACxC,MAAM,SAAS;GAAC;GAAS;GAAQ;GAAQ;EAAO;EAChD,OAAO,OAAO,QAAQ,KAAK,KAAK,OAAO,QAAQ,KAAK,QAAQ;CAC9D;CAEA,AAAQ,kBAAkB,OAA+B;EAOvD,OAAO;GALL,OAAO,eAAe;GACtB,MAAM,eAAe;GACrB,MAAM,eAAe;GACrB,OAAO,eAAe;EAEX,EAAE,UAAU,eAAe;CAC1C;CAEA,AAAQ,sBAAsB,SAAiB,OAAsB;EACnE,MAAM,MACJ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,SAAS,eAAe;EAC1E,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,aAAa,SAAS;GACvD;EACF;EACA,QAAQ,KAAK,aAAa,QAAQ,IAAI,KAAK;CAC7C;CAEA,MAAM,aAA4B,CAElC;CAEA,MAAM,WAA0B,CAEhC;AACF"}
|
|
1
|
+
{"version":3,"file":"canonical-log-line-processor-FLezvFCB.js","names":[],"sources":["../src/pretty-log-formatter.ts","../src/processors/canonical-log-line-processor.ts"],"sourcesContent":["import type { CanonicalLogLineEvent } from './processors/canonical-log-line-processor';\n\nconst RESET = '\\x1b[0m';\nconst DIM = '\\x1b[2m';\nconst BOLD = '\\x1b[1m';\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst GREEN = '\\x1b[32m';\nconst CYAN = '\\x1b[36m';\nconst GRAY = '\\x1b[90m';\n\nconst LEVEL_COLORS: Record<string, string> = {\n debug: GRAY,\n info: GREEN,\n warn: YELLOW,\n error: RED,\n};\n\n/** Internal OTel attributes to skip in pretty output. */\nconst SKIP_PREFIXES = [\n 'telemetry.',\n 'otel.',\n 'process.',\n 'os.',\n 'host.',\n 'service.',\n 'autotel.',\n];\n\nconst SKIP_KEYS = new Set([\n 'operation',\n 'traceId',\n 'spanId',\n 'correlationId',\n 'duration_ms',\n 'duration',\n 'status_code',\n 'status_message',\n 'timestamp',\n 'http.request.method',\n 'url.path',\n 'http.route',\n 'http.response.status_code',\n]);\n\nfunction useColor(): boolean {\n if (typeof process !== 'undefined') {\n if (process.env.NO_COLOR) return false;\n if (process.env.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n }\n return false;\n}\n\nfunction c(color: string, text: string): string {\n return useColor() ? `${color}${text}${RESET}` : text;\n}\n\n/**\n * Format milliseconds into a human-readable duration string.\n *\n * @example\n * formatDuration(45) // \"45ms\"\n * formatDuration(1234) // \"1.2s\"\n * formatDuration(65000) // \"1m 5s\"\n */\nexport function formatDuration(ms: number): string {\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) {\n const seconds = ms / 1000;\n return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;\n }\n const minutes = Math.floor(ms / 60_000);\n const seconds = Math.round((ms % 60_000) / 1000);\n return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;\n}\n\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n return d.toLocaleTimeString('en-GB', { hour12: false });\n } catch {\n return iso.slice(11, 19);\n }\n}\n\nfunction formatValue(value: unknown): string {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n if (value == null) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Group flat dot-notation attributes into a nested tree for pretty display.\n * e.g. { 'user.id': '1', 'user.plan': 'pro' } → { user: { id: '1', plan: 'pro' } }\n */\nfunction groupAttributes(\n event: Record<string, unknown>,\n): Record<string, unknown> {\n const tree: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(event)) {\n if (SKIP_KEYS.has(key)) continue;\n if (SKIP_PREFIXES.some((p) => key.startsWith(p))) continue;\n if (value == null || value === '') continue;\n\n const parts = key.split('.');\n if (parts.length === 1) {\n tree[key] = value;\n } else {\n let current = tree;\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i]!;\n if (!(part in current) || typeof current[part] !== 'object') {\n current[part] = {};\n }\n current = current[part] as Record<string, unknown>;\n }\n current[parts[parts.length - 1]!] = value;\n }\n }\n\n return tree;\n}\n\nfunction renderTree(\n obj: Record<string, unknown>,\n indent: string,\n isLast: boolean[],\n): string[] {\n const lines: string[] = [];\n const entries = Object.entries(obj);\n\n entries.forEach(([key, value], idx) => {\n const last = idx === entries.length - 1;\n const connector = last ? '\\u2514\\u2500' : '\\u251c\\u2500';\n const prefix = indent + connector + ' ';\n\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const nested = value as Record<string, unknown>;\n const flatValues = Object.entries(nested).filter(\n ([, v]) => typeof v !== 'object' || v === null,\n );\n const nestedObjs = Object.entries(nested).filter(\n ([, v]) => typeof v === 'object' && v !== null && !Array.isArray(v),\n );\n\n if (nestedObjs.length === 0) {\n const inline = flatValues\n .map(([k, v]) => `${c(CYAN, k)}=${formatValue(v)}`)\n .join(' ');\n lines.push(`${prefix}${c(BOLD, key)}: ${inline}`);\n } else {\n lines.push(`${prefix}${c(BOLD, key)}:`);\n const nextIndent = indent + (last ? ' ' : '\\u2502 ');\n lines.push(...renderTree(nested, nextIndent, [...isLast, last]));\n }\n } else {\n lines.push(`${prefix}${c(CYAN, key)}: ${c(DIM, formatValue(value))}`);\n }\n });\n\n return lines;\n}\n\n/**\n * Format a canonical log line event as a pretty tree for development output.\n */\nexport function formatPrettyLogLine(ctx: CanonicalLogLineEvent): string {\n const { event, level, message } = ctx;\n\n const timestamp = formatTime(String(event.timestamp ?? ''));\n const service = event['service.name'] || event.service || '';\n const method = event['http.request.method'] || '';\n const path = event['http.route'] || event['url.path'] || '';\n const status = event['http.response.status_code'] || event.status_code || '';\n const durationMs = Number(event.duration_ms ?? 0);\n const duration = formatDuration(durationMs);\n\n const levelColor = LEVEL_COLORS[level] ?? '';\n const levelStr = c(levelColor, level.toUpperCase().padEnd(5));\n\n const parts = [c(DIM, timestamp), levelStr];\n if (service) parts.push(c(DIM, `[${service}]`));\n if (method) parts.push(c(BOLD, String(method)));\n if (path) parts.push(String(path));\n if (status) {\n const statusNum = Number(status);\n const statusColor =\n statusNum >= 500 ? RED : statusNum >= 400 ? YELLOW : GREEN;\n parts.push(c(statusColor, String(status)));\n }\n parts.push(c(DIM, `in ${duration}`));\n\n const header = parts.join(' ');\n\n const tree = groupAttributes(event);\n if (Object.keys(tree).length === 0) {\n return header;\n }\n\n const treeLines = renderTree(tree, ' ', []);\n return [header, ...treeLines].join('\\n');\n}\n","/**\n * Canonical Log Line Processor\n *\n * Automatically emits spans as canonical log lines (wide events) when they end.\n * Implements canonical log line\" pattern: one comprehensive\n * event per request with all context.\n *\n * When a span ends, this processor creates a log record with ALL span attributes,\n * making the span itself the canonical log line that can be queried like structured data.\n *\n * @example\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n */\n\nimport type {\n SpanProcessor,\n ReadableSpan,\n} from '@opentelemetry/sdk-trace-base';\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport type { Logger } from '../logger';\nimport { formatPrettyLogLine, formatDuration } from '../pretty-log-formatter';\n\n/**\n * Function to redact sensitive attribute values\n */\nexport type AttributeRedactorFn = (\n key: string,\n value: AttributeValue,\n) => AttributeValue;\n\nexport interface CanonicalLogLineEvent {\n span: ReadableSpan;\n level: 'debug' | 'info' | 'warn' | 'error';\n message: string;\n event: Record<string, unknown>;\n}\n\nexport interface KeepCondition {\n /** Keep events where HTTP status >= this value. */\n status?: number;\n /** Keep events where duration_ms >= this value. */\n durationMs?: number;\n /** Keep events matching this path pattern (simple prefix match). */\n path?: string;\n}\n\nexport interface CanonicalLogLineOptions {\n /** Logger to use for emitting canonical log lines (defaults to OTel Logs API) */\n logger?: Logger;\n /** Only emit canonical log lines for root spans (default: false) */\n rootSpansOnly?: boolean;\n /** Minimum log level for canonical log lines (default: 'info') */\n minLevel?: 'debug' | 'info' | 'warn' | 'error';\n /** Custom message format (default: uses span name) */\n messageFormat?: (span: ReadableSpan) => string;\n /** Whether to include resource attributes (default: true) */\n includeResourceAttributes?: boolean;\n /**\n * Attribute redactor function to apply before logging.\n * This ensures sensitive data is redacted in canonical log lines,\n * matching the behavior of attributeRedactor in init().\n */\n attributeRedactor?: AttributeRedactorFn;\n /** Predicate to decide whether to emit (runs after event is built). */\n shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n /**\n * Declarative tail sampling conditions (OR logic). If any condition matches,\n * the event is kept. Ignored when `shouldEmit` is provided.\n *\n * @example\n * keep: [{ status: 500 }, { durationMs: 1000 }]\n */\n keep?: KeepCondition[];\n /** Callback invoked after emit for custom fan-out. */\n drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n /** Handler for drain failures. */\n onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n /**\n * Pretty-print canonical log lines to console in a tree format.\n * Defaults to true when NODE_ENV is 'development'.\n */\n pretty?: boolean;\n}\n\n/**\n * Span processor that automatically emits spans as canonical log lines\n *\n * When a span ends, this processor creates a log record with ALL span attributes.\n * This implements the \"canonical log line\" pattern: one comprehensive event\n * per request with all context, queryable as structured data.\n *\n * **Key Benefits:**\n * - One log line per request with all context (wide event)\n * - High-cardinality, high-dimensionality data for powerful queries\n * - Automatic - no manual logging needed\n * - Works with any logger or OTel Logs API\n *\n * @example Basic usage\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({\n * service: 'checkout-api',\n * canonicalLogLines: {\n * enabled: true,\n * rootSpansOnly: true, // One canonical log line per request\n * },\n * });\n * ```\n *\n * @example With custom logger\n * ```typescript\n * import pino from 'pino';\n * import { init } from 'autotel';\n *\n * const logger = pino();\n * init({\n * service: 'my-app',\n * logger,\n * canonicalLogLines: {\n * enabled: true,\n * logger, // Use Pino for canonical log lines\n * rootSpansOnly: true,\n * },\n * });\n * ```\n *\n * @example Custom message format\n * ```typescript\n * init({\n * service: 'my-app',\n * canonicalLogLines: {\n * enabled: true,\n * messageFormat: (span) => {\n * const status = span.status.code === 2 ? 'ERROR' : 'SUCCESS';\n * return `${span.name} [${status}]`;\n * },\n * },\n * });\n * ```\n */\nexport class CanonicalLogLineProcessor implements SpanProcessor {\n private logger?: Logger;\n private rootSpansOnly: boolean;\n private minLevel: 'debug' | 'info' | 'warn' | 'error';\n private messageFormat: (span: ReadableSpan) => string;\n private includeResourceAttributes: boolean;\n private attributeRedactor?: AttributeRedactorFn;\n private shouldEmit?: (ctx: CanonicalLogLineEvent) => boolean;\n private drain?: (ctx: CanonicalLogLineEvent) => void | Promise<void>;\n private onDrainError?: (error: unknown, ctx: CanonicalLogLineEvent) => void;\n private pretty: boolean;\n private getOTelLogger: (() => ReturnType<typeof logs.getLogger>) | null =\n null;\n\n constructor(options: CanonicalLogLineOptions = {}) {\n this.logger = options.logger;\n this.rootSpansOnly = options.rootSpansOnly ?? false;\n this.minLevel = options.minLevel ?? 'info';\n this.messageFormat =\n options.messageFormat ?? ((span) => `[${span.name}] Request completed`);\n this.includeResourceAttributes = options.includeResourceAttributes ?? true;\n this.attributeRedactor = options.attributeRedactor;\n this.shouldEmit =\n options.shouldEmit ?? this.buildKeepPredicate(options.keep);\n this.drain = options.drain;\n this.onDrainError = options.onDrainError;\n this.pretty =\n options.pretty ??\n (typeof process !== 'undefined' &&\n process.env.NODE_ENV === 'development');\n\n if (!this.logger) {\n this.getOTelLogger = () => logs.getLogger('autotel.canonical-log-line');\n }\n }\n\n private buildKeepPredicate(\n keep?: KeepCondition[],\n ): ((ctx: CanonicalLogLineEvent) => boolean) | undefined {\n if (!keep || keep.length === 0) return undefined;\n\n return (ctx: CanonicalLogLineEvent) => {\n return keep.some((condition) => {\n if (condition.status !== undefined) {\n const httpStatus = Number(\n ctx.event['http.response.status_code'] ?? 0,\n );\n if (httpStatus >= condition.status) return true;\n }\n if (\n condition.durationMs !== undefined &&\n Number(ctx.event.duration_ms ?? 0) >= condition.durationMs\n ) {\n return true;\n }\n if (condition.path !== undefined) {\n const route = String(\n ctx.event['http.route'] ?? ctx.event['url.path'] ?? '',\n );\n if (route.startsWith(condition.path)) return true;\n }\n return false;\n });\n };\n }\n\n onStart(): void {\n // No-op\n }\n\n onEnd(span: ReadableSpan): void {\n if (\n this.rootSpansOnly &&\n span.parentSpanContext?.spanId &&\n !span.parentSpanContext.isRemote\n ) {\n return;\n }\n\n const level = this.getLogLevel(span);\n if (!this.shouldLog(level)) {\n return;\n }\n\n const canonicalLogLine = this.buildCanonicalLogLine(span);\n const message = this.messageFormat(span);\n const eventContext: CanonicalLogLineEvent = {\n span,\n level,\n message,\n event: canonicalLogLine,\n };\n\n if (this.shouldEmit && !this.shouldEmit(eventContext)) return;\n\n if (this.pretty) {\n console.log(formatPrettyLogLine(eventContext));\n }\n\n if (this.logger) {\n this.emitViaLogger(level, message, canonicalLogLine);\n } else if (this.getOTelLogger) {\n const otelLogger = this.getOTelLogger();\n this.emitViaOTel(level, message, canonicalLogLine, otelLogger);\n }\n\n if (this.drain) {\n Promise.resolve(this.drain(eventContext)).catch((error) => {\n if (this.onDrainError) {\n this.onDrainError(error, eventContext);\n return;\n }\n this.reportInternalWarning('canonicalLogLines.drain failed', error);\n });\n }\n }\n\n private buildCanonicalLogLine(span: ReadableSpan): Record<string, unknown> {\n const durationMs = span.duration[0] * 1000 + span.duration[1] / 1_000_000;\n const timestamp = new Date(\n span.startTime[0] * 1000 + span.startTime[1] / 1_000_000,\n ).toISOString();\n\n // Span attributes first so core metadata fields below take precedence\n const canonicalLogLine: Record<string, unknown> = {};\n const attributes = this.redactAttributes(span.attributes);\n Object.assign(canonicalLogLine, attributes);\n\n if (this.includeResourceAttributes) {\n const resourceAttrs = this.redactAttributes(\n span.resource.attributes as Attributes,\n );\n Object.assign(canonicalLogLine, resourceAttrs);\n }\n\n canonicalLogLine.operation = span.name;\n canonicalLogLine.traceId = span.spanContext().traceId;\n canonicalLogLine.spanId = span.spanContext().spanId;\n canonicalLogLine.correlationId = span.spanContext().traceId.slice(0, 16);\n canonicalLogLine.duration_ms = Math.round(durationMs * 100) / 100;\n canonicalLogLine.duration = formatDuration(durationMs);\n canonicalLogLine.status_code = span.status.code;\n canonicalLogLine.status_message = span.status.message || undefined;\n canonicalLogLine.timestamp = timestamp;\n\n return canonicalLogLine;\n }\n\n private redactAttributes(attributes: Attributes): Record<string, unknown> {\n if (!this.attributeRedactor) {\n return { ...attributes };\n }\n\n const redacted: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attributes)) {\n if (value !== undefined) {\n redacted[key] = this.attributeRedactor(key, value);\n }\n }\n return redacted;\n }\n\n private emitViaLogger(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n ): void {\n this.logger;\n }\n\n private emitViaOTel(\n level: 'debug' | 'info' | 'warn' | 'error',\n message: string,\n canonicalLogLine: Record<string, unknown>,\n otelLogger: ReturnType<typeof logs.getLogger>,\n ): void {\n const otelAttributes: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(canonicalLogLine)) {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n otelAttributes[key] = value;\n } else if (value !== null && value !== undefined) {\n otelAttributes[key] = String(value);\n }\n }\n otelLogger.emit({\n severityNumber: this.getSeverityNumber(level),\n severityText: level.toUpperCase(),\n body: message,\n attributes: otelAttributes,\n });\n }\n\n private getLogLevel(span: ReadableSpan): 'debug' | 'info' | 'warn' | 'error' {\n const explicitLevel = span.attributes['autotel.log.level'];\n if (\n explicitLevel === 'debug' ||\n explicitLevel === 'info' ||\n explicitLevel === 'warn' ||\n explicitLevel === 'error'\n ) {\n return explicitLevel;\n }\n\n if (span.status.code === 2) return 'error';\n return 'info';\n }\n\n private shouldLog(level: string): boolean {\n const levels = ['debug', 'info', 'warn', 'error'];\n return levels.indexOf(level) >= levels.indexOf(this.minLevel);\n }\n\n private getSeverityNumber(level: string): SeverityNumber {\n const mapping: Record<string, SeverityNumber> = {\n debug: SeverityNumber.DEBUG,\n info: SeverityNumber.INFO,\n warn: SeverityNumber.WARN,\n error: SeverityNumber.ERROR,\n };\n return mapping[level] ?? SeverityNumber.INFO;\n }\n\n private reportInternalWarning(message: string, error: unknown): void {\n const err =\n error instanceof Error ? error.message : String(error ?? 'unknown error');\n if (this.logger) {\n this.logger.warn({ error: err }, `[autotel] ${message}`);\n return;\n }\n console.warn(`[autotel] ${message}: ${err}`);\n }\n\n async forceFlush(): Promise<void> {\n // No-op\n }\n\n async shutdown(): Promise<void> {\n // No-op\n }\n}\n"],"mappings":";;;AAEA,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,SAAS;AACf,MAAM,QAAQ;AACd,MAAM,OAAO;AAGb,MAAM,eAAuC;CAC3C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;AACT;;AAGA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,WAAoB;CAC3B,IAAI,OAAO,YAAY,aAAa;EAClC,IAAI,QAAQ,IAAI,UAAU,OAAO;EACjC,IAAI,QAAQ,IAAI,aAAa,OAAO;EACpC,IAAI,QAAQ,QAAQ,OAAO,OAAO;CACpC;CACA,OAAO;AACT;AAEA,SAAS,E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