autotel 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +223 -0
  2. package/dist/attribute-redacting-processor.cjs +25 -0
  3. package/dist/attribute-redacting-processor.cjs.map +1 -0
  4. package/dist/attribute-redacting-processor.d.cts +122 -0
  5. package/dist/attribute-redacting-processor.d.ts +122 -0
  6. package/dist/attribute-redacting-processor.js +4 -0
  7. package/dist/attribute-redacting-processor.js.map +1 -0
  8. package/dist/attributes.cjs +86 -0
  9. package/dist/attributes.cjs.map +1 -0
  10. package/dist/attributes.d.cts +20 -0
  11. package/dist/attributes.d.ts +20 -0
  12. package/dist/attributes.js +5 -0
  13. package/dist/attributes.js.map +1 -0
  14. package/dist/auto.cjs +6 -2
  15. package/dist/auto.cjs.map +1 -1
  16. package/dist/auto.js +5 -1
  17. package/dist/auto.js.map +1 -1
  18. package/dist/business-baggage.d.cts +1 -1
  19. package/dist/business-baggage.d.ts +1 -1
  20. package/dist/chunk-4XNNRSJU.cjs +169 -0
  21. package/dist/chunk-4XNNRSJU.cjs.map +1 -0
  22. package/dist/{chunk-RYSHUBDH.js → chunk-4ZKPAVWV.js} +32 -4
  23. package/dist/chunk-4ZKPAVWV.js.map +1 -0
  24. package/dist/chunk-5JDGZS4U.js +164 -0
  25. package/dist/chunk-5JDGZS4U.js.map +1 -0
  26. package/dist/{chunk-JHIDFQNG.cjs → chunk-6C22XWDY.cjs} +22 -22
  27. package/dist/{chunk-JHIDFQNG.cjs.map → chunk-6C22XWDY.cjs.map} +1 -1
  28. package/dist/chunk-6UQRVUN3.js +222 -0
  29. package/dist/chunk-6UQRVUN3.js.map +1 -0
  30. package/dist/{chunk-N5AACOMU.js → chunk-7OZ75X3P.js} +3 -3
  31. package/dist/{chunk-N5AACOMU.js.map → chunk-7OZ75X3P.js.map} +1 -1
  32. package/dist/chunk-7V4VPLG6.js +911 -0
  33. package/dist/chunk-7V4VPLG6.js.map +1 -0
  34. package/dist/chunk-CU6IDACR.cjs +224 -0
  35. package/dist/chunk-CU6IDACR.cjs.map +1 -0
  36. package/dist/chunk-GYR5K654.js +91 -0
  37. package/dist/chunk-GYR5K654.js.map +1 -0
  38. package/dist/{chunk-DWHIOTHR.cjs → chunk-HPPYIHMT.cjs} +32 -4
  39. package/dist/chunk-HPPYIHMT.cjs.map +1 -0
  40. package/dist/chunk-IOYFAFHJ.cjs +95 -0
  41. package/dist/chunk-IOYFAFHJ.cjs.map +1 -0
  42. package/dist/{chunk-6VHLKKC5.cjs → chunk-JH3CJNKB.cjs} +5 -5
  43. package/dist/{chunk-6VHLKKC5.cjs.map → chunk-JH3CJNKB.cjs.map} +1 -1
  44. package/dist/chunk-LLKKDI2O.cjs +931 -0
  45. package/dist/chunk-LLKKDI2O.cjs.map +1 -0
  46. package/dist/{chunk-7B5EOO4T.cjs → chunk-LUDUT7FJ.cjs} +5 -5
  47. package/dist/{chunk-7B5EOO4T.cjs.map → chunk-LUDUT7FJ.cjs.map} +1 -1
  48. package/dist/{chunk-5UE3BJV5.js → chunk-NAHASU2T.js} +3 -3
  49. package/dist/{chunk-5UE3BJV5.js.map → chunk-NAHASU2T.js.map} +1 -1
  50. package/dist/{chunk-OLKULYTW.js → chunk-RCQG7T5I.js} +3 -3
  51. package/dist/{chunk-OLKULYTW.js.map → chunk-RCQG7T5I.js.map} +1 -1
  52. package/dist/{chunk-U3S2KGLC.cjs → chunk-RERUPK5P.cjs} +10 -10
  53. package/dist/{chunk-U3S2KGLC.cjs.map → chunk-RERUPK5P.cjs.map} +1 -1
  54. package/dist/{chunk-J5K2LVBP.js → chunk-UGAEDL44.js} +3 -3
  55. package/dist/{chunk-J5K2LVBP.js.map → chunk-UGAEDL44.js.map} +1 -1
  56. package/dist/chunk-WGWSHJ2N.js +38 -0
  57. package/dist/chunk-WGWSHJ2N.js.map +1 -0
  58. package/dist/{chunk-2CKSU2QA.cjs → chunk-XDOGXQB5.cjs} +7 -7
  59. package/dist/{chunk-2CKSU2QA.cjs.map → chunk-XDOGXQB5.cjs.map} +1 -1
  60. package/dist/{chunk-RVLZSQJB.js → chunk-XLBPPAIG.js} +3 -3
  61. package/dist/{chunk-RVLZSQJB.js.map → chunk-XLBPPAIG.js.map} +1 -1
  62. package/dist/chunk-ZNMBW67B.cjs +40 -0
  63. package/dist/chunk-ZNMBW67B.cjs.map +1 -0
  64. package/dist/decorators.cjs +6 -2
  65. package/dist/decorators.cjs.map +1 -1
  66. package/dist/decorators.d.cts +1 -1
  67. package/dist/decorators.d.ts +1 -1
  68. package/dist/decorators.js +6 -2
  69. package/dist/decorators.js.map +1 -1
  70. package/dist/event.cjs +9 -5
  71. package/dist/event.js +6 -2
  72. package/dist/exporters.cjs +5 -0
  73. package/dist/exporters.d.cts +133 -0
  74. package/dist/exporters.d.ts +133 -0
  75. package/dist/exporters.js +1 -0
  76. package/dist/filtering-span-processor.cjs +13 -0
  77. package/dist/filtering-span-processor.cjs.map +1 -0
  78. package/dist/filtering-span-processor.d.cts +80 -0
  79. package/dist/filtering-span-processor.d.ts +80 -0
  80. package/dist/filtering-span-processor.js +4 -0
  81. package/dist/filtering-span-processor.js.map +1 -0
  82. package/dist/functional.cjs +13 -9
  83. package/dist/functional.d.cts +1 -1
  84. package/dist/functional.d.ts +1 -1
  85. package/dist/functional.js +6 -2
  86. package/dist/index.cjs +145 -44
  87. package/dist/index.cjs.map +1 -1
  88. package/dist/index.d.cts +6 -2
  89. package/dist/index.d.ts +6 -2
  90. package/dist/index.js +14 -9
  91. package/dist/index.js.map +1 -1
  92. package/dist/{init-IEEV523Q.d.cts → init-6xLfGnM6.d.cts} +154 -15
  93. package/dist/{init-BXgupjSd.d.ts → init-CyZUkI9G.d.ts} +154 -15
  94. package/dist/instrumentation.cjs +12 -8
  95. package/dist/instrumentation.cjs.map +1 -1
  96. package/dist/instrumentation.js +5 -1
  97. package/dist/instrumentation.js.map +1 -1
  98. package/dist/messaging-adapters.d.cts +1 -1
  99. package/dist/messaging-adapters.d.ts +1 -1
  100. package/dist/messaging-testing.d.cts +1 -1
  101. package/dist/messaging-testing.d.ts +1 -1
  102. package/dist/messaging.cjs +10 -6
  103. package/dist/messaging.d.cts +1 -1
  104. package/dist/messaging.d.ts +1 -1
  105. package/dist/messaging.js +7 -3
  106. package/dist/semantic-helpers.cjs +11 -7
  107. package/dist/semantic-helpers.d.cts +1 -1
  108. package/dist/semantic-helpers.d.ts +1 -1
  109. package/dist/semantic-helpers.js +7 -3
  110. package/dist/span-name-normalizer.cjs +21 -0
  111. package/dist/span-name-normalizer.cjs.map +1 -0
  112. package/dist/span-name-normalizer.d.cts +94 -0
  113. package/dist/span-name-normalizer.d.ts +94 -0
  114. package/dist/span-name-normalizer.js +4 -0
  115. package/dist/span-name-normalizer.js.map +1 -0
  116. package/dist/{trace-context-gTjI7ZDb.d.cts → trace-context-t5X1AP-e.d.cts} +1 -1
  117. package/dist/{trace-context-gTjI7ZDb.d.ts → trace-context-t5X1AP-e.d.ts} +1 -1
  118. package/dist/utils-D1trOLNm.d.ts +712 -0
  119. package/dist/utils-DuNJfXSH.d.cts +712 -0
  120. package/dist/webhook.cjs +7 -3
  121. package/dist/webhook.cjs.map +1 -1
  122. package/dist/webhook.d.cts +1 -1
  123. package/dist/webhook.d.ts +1 -1
  124. package/dist/webhook.js +6 -2
  125. package/dist/webhook.js.map +1 -1
  126. package/dist/workflow-distributed.cjs +8 -4
  127. package/dist/workflow-distributed.cjs.map +1 -1
  128. package/dist/workflow-distributed.d.cts +1 -1
  129. package/dist/workflow-distributed.d.ts +1 -1
  130. package/dist/workflow-distributed.js +6 -2
  131. package/dist/workflow-distributed.js.map +1 -1
  132. package/dist/workflow.cjs +11 -7
  133. package/dist/workflow.d.cts +1 -1
  134. package/dist/workflow.d.ts +1 -1
  135. package/dist/workflow.js +7 -3
  136. package/dist/yaml-config.d.cts +4 -1
  137. package/dist/yaml-config.d.ts +4 -1
  138. package/package.json +38 -18
  139. package/src/attribute-redacting-processor.test.ts +696 -0
  140. package/src/attribute-redacting-processor.ts +336 -0
  141. package/src/attributes/attachers.ts +161 -0
  142. package/src/attributes/builders.ts +547 -0
  143. package/src/attributes/domains.ts +42 -0
  144. package/src/attributes/index.ts +82 -0
  145. package/src/attributes/registry.ts +330 -0
  146. package/src/attributes/types.ts +219 -0
  147. package/src/attributes/utils.ts +64 -0
  148. package/src/attributes/validators.ts +266 -0
  149. package/src/attributes.test.ts +292 -0
  150. package/src/exporters.ts +75 -6
  151. package/src/filtering-span-processor.test.ts +281 -0
  152. package/src/filtering-span-processor.ts +111 -0
  153. package/src/index.ts +87 -0
  154. package/src/init.ts +219 -19
  155. package/src/pretty-console-exporter.test.ts +545 -0
  156. package/src/pretty-console-exporter.ts +413 -0
  157. package/src/span-name-normalizer.test.ts +377 -0
  158. package/src/span-name-normalizer.ts +213 -0
  159. package/dist/chunk-DWHIOTHR.cjs.map +0 -1
  160. package/dist/chunk-RYSHUBDH.js.map +0 -1
package/README.md CHANGED
@@ -589,6 +589,229 @@ instrumentDatabase(db, {
589
589
  await db.select().from(users); // queries emit spans automatically
590
590
  ```
591
591
 
592
+ ## Type-Safe Attributes
593
+
594
+ Autotel provides type-safe attribute builders following OpenTelemetry semantic conventions. These helpers give you autocomplete, compile-time validation, and automatic PII redaction.
595
+
596
+ ### Pattern A: Key Builders
597
+
598
+ Build individual attributes with full autocomplete:
599
+
600
+ ```typescript
601
+ import { attrs, mergeAttrs } from 'autotel/attributes';
602
+
603
+ // Single attribute
604
+ ctx.setAttributes(attrs.user.id('user-123'));
605
+ // → { 'user.id': 'user-123' }
606
+
607
+ ctx.setAttributes(attrs.http.request.method('GET'));
608
+ // → { 'http.request.method': 'GET' }
609
+
610
+ ctx.setAttributes(attrs.db.client.system('postgresql'));
611
+ // → { 'db.system.name': 'postgresql' }
612
+
613
+ // Combine multiple attributes
614
+ ctx.setAttributes(
615
+ mergeAttrs(
616
+ attrs.user.id('user-123'),
617
+ attrs.session.id('sess-456'),
618
+ attrs.http.response.statusCode(200),
619
+ ),
620
+ );
621
+ ```
622
+
623
+ ### Pattern B: Object Builders
624
+
625
+ Pass an object to set multiple related attributes at once:
626
+
627
+ ```typescript
628
+ import { attrs } from 'autotel/attributes';
629
+
630
+ // User attributes
631
+ ctx.setAttributes(
632
+ attrs.user.data({
633
+ id: 'user-123',
634
+ email: 'user@example.com',
635
+ roles: ['admin', 'editor'],
636
+ }),
637
+ );
638
+ // → { 'user.id': 'user-123', 'user.email': 'user@example.com', 'user.roles': ['admin', 'editor'] }
639
+
640
+ // HTTP server attributes
641
+ ctx.setAttributes(
642
+ attrs.http.server({
643
+ method: 'POST',
644
+ route: '/api/users/:id',
645
+ statusCode: 201,
646
+ }),
647
+ );
648
+ // → { 'http.request.method': 'POST', 'http.route': '/api/users/:id', 'http.response.status_code': 201 }
649
+
650
+ // Database attributes
651
+ ctx.setAttributes(
652
+ attrs.db.client.data({
653
+ system: 'postgresql',
654
+ name: 'myapp_db', // Maps to db.namespace
655
+ operation: 'SELECT',
656
+ collectionName: 'users',
657
+ }),
658
+ );
659
+ ```
660
+
661
+ ### Attachers (Signal Helpers)
662
+
663
+ Attachers know WHERE to attach attributes - they handle spans, resources, and apply guardrails automatically:
664
+
665
+ ```typescript
666
+ import { setUser, httpServer, identify, dbClient } from 'autotel/attributes';
667
+
668
+ // Set user attributes with automatic PII redaction
669
+ export const handleRequest = trace((ctx) => async (req) => {
670
+ setUser(ctx, {
671
+ id: req.userId,
672
+ email: req.userEmail, // Automatically redacted by default
673
+ });
674
+
675
+ // HTTP attributes + automatic span name update
676
+ httpServer(ctx, {
677
+ method: req.method,
678
+ route: req.route,
679
+ statusCode: 200,
680
+ });
681
+ // Span name becomes: "HTTP GET /api/users"
682
+ });
683
+
684
+ // Bundle user, session, and device attributes together
685
+ export const identifyUser = trace((ctx) => async (data) => {
686
+ identify(ctx, {
687
+ user: { id: data.userId, name: data.userName },
688
+ session: { id: data.sessionId },
689
+ device: { id: data.deviceId, manufacturer: 'Apple' },
690
+ });
691
+ });
692
+
693
+ // Database client attributes
694
+ export const queryUsers = trace((ctx) => async () => {
695
+ dbClient(ctx, {
696
+ system: 'postgresql',
697
+ operation: 'SELECT',
698
+ collectionName: 'users',
699
+ });
700
+ return await db.query('SELECT * FROM users');
701
+ });
702
+ ```
703
+
704
+ ### PII Guardrails
705
+
706
+ `safeSetAttributes()` applies automatic PII detection and configurable guardrails:
707
+
708
+ ```typescript
709
+ import { safeSetAttributes, attrs } from 'autotel/attributes';
710
+
711
+ export const processUser = trace((ctx) => async (user) => {
712
+ // Default: PII is redacted automatically
713
+ safeSetAttributes(ctx, attrs.user.data({ email: 'user@example.com' }));
714
+ // → { 'user.email': '[REDACTED]' }
715
+
716
+ // Allow PII (use with caution)
717
+ safeSetAttributes(ctx, attrs.user.data({ email: 'user@example.com' }), {
718
+ guardrails: { pii: 'allow' },
719
+ });
720
+ // → { 'user.email': 'user@example.com' }
721
+
722
+ // Hash PII for correlation without exposing raw values
723
+ safeSetAttributes(ctx, attrs.user.data({ email: 'user@example.com' }), {
724
+ guardrails: { pii: 'hash' },
725
+ });
726
+ // → { 'user.email': 'hash_a1b2c3d4...' }
727
+
728
+ // Truncate long values
729
+ safeSetAttributes(ctx, attrs.user.data({ id: 'a'.repeat(500) }), {
730
+ guardrails: { maxLength: 255 },
731
+ });
732
+ // → { 'user.id': 'aaaa...aaa...' } (truncated with ellipsis)
733
+
734
+ // Warn on deprecated attributes
735
+ safeSetAttributes(
736
+ ctx,
737
+ { 'http.method': 'GET' }, // Deprecated!
738
+ { guardrails: { warnDeprecated: true } },
739
+ );
740
+ // Console: [autotel/attributes] Attribute "http.method" is deprecated. Use "http.request.method" instead.
741
+ });
742
+ ```
743
+
744
+ **Guardrail Options:**
745
+
746
+ | Option | Values | Default | Description |
747
+ | ---------------- | ------------------------------------------ | ---------- | ------------------------------------------ |
748
+ | `pii` | `'allow'`, `'redact'`, `'hash'`, `'block'` | `'redact'` | How to handle PII in attribute values |
749
+ | `maxLength` | number | `255` | Maximum string length before truncation |
750
+ | `validateEnum` | boolean | `true` | Normalize enum values (e.g., HTTP methods) |
751
+ | `warnDeprecated` | boolean | `true` | Log warnings for deprecated attributes |
752
+
753
+ ### Domain Helpers
754
+
755
+ Domain helpers bundle multiple attribute groups for common scenarios:
756
+
757
+ ```typescript
758
+ import { transaction } from 'autotel/attributes';
759
+
760
+ // Bundle HTTP request with user context
761
+ export const handleRequest = trace((ctx) => async (req) => {
762
+ transaction(ctx, {
763
+ user: { id: req.userId },
764
+ session: { id: req.sessionId },
765
+ method: req.method,
766
+ route: req.route,
767
+ statusCode: 200,
768
+ clientIp: req.ip,
769
+ });
770
+ // Sets: user.id, session.id, http.request.method, http.route,
771
+ // http.response.status_code, network.peer.address
772
+ // Also updates span name to "HTTP GET /api/users"
773
+ });
774
+ ```
775
+
776
+ ### Available Attribute Domains
777
+
778
+ | Domain | Key Builders | Object Builder |
779
+ | ----------- | ---------------------------------------------------- | -------------------------------------------- |
780
+ | `user` | `id`, `email`, `name`, `fullName`, `hash`, `roles` | `attrs.user.data()` |
781
+ | `session` | `id`, `previousId` | `attrs.session.data()` |
782
+ | `device` | `id`, `manufacturer`, `modelIdentifier`, `modelName` | `attrs.device.data()` |
783
+ | `http` | `request.*`, `response.*`, `route` | `attrs.http.server()`, `attrs.http.client()` |
784
+ | `db` | `client.system`, `client.operation`, etc. | `attrs.db.client.data()` |
785
+ | `service` | `name`, `instance`, `version` | `attrs.service.data()` |
786
+ | `network` | `peerAddress`, `peerPort`, `transport`, etc. | `attrs.network.data()` |
787
+ | `error` | `type`, `message`, `stackTrace`, `code` | `attrs.error.data()` |
788
+ | `exception` | `escaped`, `message`, `stackTrace`, `type` | `attrs.exception.data()` |
789
+ | `cloud` | `provider`, `accountId`, `region`, etc. | `attrs.cloud.data()` |
790
+ | `messaging` | `system`, `destination`, `operation`, etc. | `attrs.messaging.data()` |
791
+ | `genAI` | `system`, `requestModel`, `responseModel`, etc. | - |
792
+ | `rpc` | `system`, `service`, `method` | - |
793
+ | `graphql` | `document`, `operationName`, `operationType` | - |
794
+
795
+ ### Resource Merging
796
+
797
+ For enriching OpenTelemetry Resources with service attributes (Resource.attributes is readonly), use `mergeServiceResource`:
798
+
799
+ ```typescript
800
+ import { mergeServiceResource } from 'autotel/attributes';
801
+ import { Resource } from '@opentelemetry/resources';
802
+
803
+ // Create enriched resource for custom SDK configurations
804
+ const baseResource = Resource.default();
805
+ const enrichedResource = mergeServiceResource(baseResource, {
806
+ name: 'my-service',
807
+ version: '1.0.0',
808
+ instance: 'instance-1',
809
+ });
810
+
811
+ // Use with custom TracerProvider
812
+ const provider = new NodeTracerProvider({ resource: enrichedResource });
813
+ ```
814
+
592
815
  ## Event-Driven Architectures
593
816
 
594
817
  Autotel provides first-class support for tracing message-based systems like Kafka, SQS, and RabbitMQ. The `traceProducer` and `traceConsumer` helpers automatically set semantic attributes, handle context propagation, and create proper span links.
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var chunk4XNNRSJU_cjs = require('./chunk-4XNNRSJU.cjs');
4
+ require('./chunk-JEQ2X3Z6.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "AttributeRedactingProcessor", {
9
+ enumerable: true,
10
+ get: function () { return chunk4XNNRSJU_cjs.AttributeRedactingProcessor; }
11
+ });
12
+ Object.defineProperty(exports, "REDACTOR_PATTERNS", {
13
+ enumerable: true,
14
+ get: function () { return chunk4XNNRSJU_cjs.REDACTOR_PATTERNS; }
15
+ });
16
+ Object.defineProperty(exports, "REDACTOR_PRESETS", {
17
+ enumerable: true,
18
+ get: function () { return chunk4XNNRSJU_cjs.REDACTOR_PRESETS; }
19
+ });
20
+ Object.defineProperty(exports, "createRedactedSpan", {
21
+ enumerable: true,
22
+ get: function () { return chunk4XNNRSJU_cjs.createRedactedSpan; }
23
+ });
24
+ //# sourceMappingURL=attribute-redacting-processor.cjs.map
25
+ //# sourceMappingURL=attribute-redacting-processor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"attribute-redacting-processor.cjs"}
@@ -0,0 +1,122 @@
1
+ import { SpanProcessor, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';
2
+ import { AttributeValue, Context } from '@opentelemetry/api';
3
+
4
+ /**
5
+ * Attribute Redacting Processor
6
+ *
7
+ * Automatically redacts PII and sensitive data from span attributes before export.
8
+ * This is critical for compliance (GDPR, PCI-DSS, HIPAA) and data security.
9
+ *
10
+ * @example Basic usage with preset
11
+ * ```typescript
12
+ * init({
13
+ * service: 'my-app',
14
+ * attributeRedactor: 'default'
15
+ * })
16
+ * ```
17
+ *
18
+ * @example Custom patterns
19
+ * ```typescript
20
+ * init({
21
+ * service: 'my-app',
22
+ * attributeRedactor: {
23
+ * keyPatterns: [/password/i, /secret/i],
24
+ * valuePatterns: [
25
+ * { name: 'customerId', pattern: /CUST-\d{8}/g, replacement: 'CUST-***' }
26
+ * ]
27
+ * }
28
+ * })
29
+ * ```
30
+ */
31
+
32
+ /**
33
+ * Custom redactor function type
34
+ */
35
+ type AttributeRedactorFn = (key: string, value: AttributeValue) => AttributeValue;
36
+ /**
37
+ * Built-in redactor preset names
38
+ */
39
+ type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';
40
+ /**
41
+ * Value pattern configuration
42
+ */
43
+ interface ValuePatternConfig {
44
+ /** Name for debugging/logging */
45
+ name: string;
46
+ /** Regex pattern to match in values */
47
+ pattern: RegExp;
48
+ /** Custom replacement (default: uses global replacement) */
49
+ replacement?: string;
50
+ }
51
+ /**
52
+ * Attribute redactor configuration
53
+ */
54
+ interface AttributeRedactorConfig {
55
+ /** Patterns to match against attribute keys (redacts entire value if key matches) */
56
+ keyPatterns?: RegExp[];
57
+ /** Patterns to match against attribute values (redacts matched portion) */
58
+ valuePatterns?: ValuePatternConfig[];
59
+ /** Default replacement string (default: '[REDACTED]') */
60
+ replacement?: string;
61
+ /** Custom redactor function for full control */
62
+ redactor?: AttributeRedactorFn;
63
+ }
64
+ /**
65
+ * Processor options
66
+ */
67
+ interface AttributeRedactingProcessorOptions {
68
+ redactor: AttributeRedactorConfig | AttributeRedactorPreset;
69
+ }
70
+ /**
71
+ * Built-in patterns for detecting sensitive data
72
+ */
73
+ declare const REDACTOR_PATTERNS: {
74
+ readonly email: RegExp;
75
+ readonly phone: RegExp;
76
+ readonly ssn: RegExp;
77
+ readonly creditCard: RegExp;
78
+ readonly bearerToken: RegExp;
79
+ readonly apiKeyInValue: RegExp;
80
+ readonly jwt: RegExp;
81
+ readonly sensitiveKey: RegExp;
82
+ };
83
+ /**
84
+ * Built-in redactor presets
85
+ */
86
+ declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
87
+ /**
88
+ * Create a proxy wrapper around ReadableSpan with redacted attributes
89
+ *
90
+ * Since ReadableSpan.attributes is readonly, we use a Proxy to intercept
91
+ * attribute access and return the redacted version.
92
+ */
93
+ declare function createRedactedSpan(span: ReadableSpan, redactor: AttributeRedactorFn): ReadableSpan;
94
+ /**
95
+ * Span processor that redacts sensitive data from span attributes.
96
+ *
97
+ * Redaction happens in onEnd() when all attributes are finalized.
98
+ * Uses a Proxy wrapper to intercept attribute access since ReadableSpan
99
+ * attributes are readonly.
100
+ *
101
+ * Common use cases:
102
+ * - PII compliance (GDPR, CCPA)
103
+ * - PCI-DSS compliance for payment data
104
+ * - Preventing secrets from leaking to observability backends
105
+ */
106
+ declare class AttributeRedactingProcessor implements SpanProcessor {
107
+ private readonly wrappedProcessor;
108
+ private readonly redactor;
109
+ constructor(wrappedProcessor: SpanProcessor, options: AttributeRedactingProcessorOptions);
110
+ /**
111
+ * Pass through onStart unchanged - attributes aren't finalized yet
112
+ */
113
+ onStart(span: Span, parentContext: Context): void;
114
+ /**
115
+ * Redact attributes and forward to wrapped processor
116
+ */
117
+ onEnd(span: ReadableSpan): void;
118
+ forceFlush(): Promise<void>;
119
+ shutdown(): Promise<void>;
120
+ }
121
+
122
+ export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, createRedactedSpan };
@@ -0,0 +1,122 @@
1
+ import { SpanProcessor, Span, ReadableSpan } from '@opentelemetry/sdk-trace-base';
2
+ import { AttributeValue, Context } from '@opentelemetry/api';
3
+
4
+ /**
5
+ * Attribute Redacting Processor
6
+ *
7
+ * Automatically redacts PII and sensitive data from span attributes before export.
8
+ * This is critical for compliance (GDPR, PCI-DSS, HIPAA) and data security.
9
+ *
10
+ * @example Basic usage with preset
11
+ * ```typescript
12
+ * init({
13
+ * service: 'my-app',
14
+ * attributeRedactor: 'default'
15
+ * })
16
+ * ```
17
+ *
18
+ * @example Custom patterns
19
+ * ```typescript
20
+ * init({
21
+ * service: 'my-app',
22
+ * attributeRedactor: {
23
+ * keyPatterns: [/password/i, /secret/i],
24
+ * valuePatterns: [
25
+ * { name: 'customerId', pattern: /CUST-\d{8}/g, replacement: 'CUST-***' }
26
+ * ]
27
+ * }
28
+ * })
29
+ * ```
30
+ */
31
+
32
+ /**
33
+ * Custom redactor function type
34
+ */
35
+ type AttributeRedactorFn = (key: string, value: AttributeValue) => AttributeValue;
36
+ /**
37
+ * Built-in redactor preset names
38
+ */
39
+ type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';
40
+ /**
41
+ * Value pattern configuration
42
+ */
43
+ interface ValuePatternConfig {
44
+ /** Name for debugging/logging */
45
+ name: string;
46
+ /** Regex pattern to match in values */
47
+ pattern: RegExp;
48
+ /** Custom replacement (default: uses global replacement) */
49
+ replacement?: string;
50
+ }
51
+ /**
52
+ * Attribute redactor configuration
53
+ */
54
+ interface AttributeRedactorConfig {
55
+ /** Patterns to match against attribute keys (redacts entire value if key matches) */
56
+ keyPatterns?: RegExp[];
57
+ /** Patterns to match against attribute values (redacts matched portion) */
58
+ valuePatterns?: ValuePatternConfig[];
59
+ /** Default replacement string (default: '[REDACTED]') */
60
+ replacement?: string;
61
+ /** Custom redactor function for full control */
62
+ redactor?: AttributeRedactorFn;
63
+ }
64
+ /**
65
+ * Processor options
66
+ */
67
+ interface AttributeRedactingProcessorOptions {
68
+ redactor: AttributeRedactorConfig | AttributeRedactorPreset;
69
+ }
70
+ /**
71
+ * Built-in patterns for detecting sensitive data
72
+ */
73
+ declare const REDACTOR_PATTERNS: {
74
+ readonly email: RegExp;
75
+ readonly phone: RegExp;
76
+ readonly ssn: RegExp;
77
+ readonly creditCard: RegExp;
78
+ readonly bearerToken: RegExp;
79
+ readonly apiKeyInValue: RegExp;
80
+ readonly jwt: RegExp;
81
+ readonly sensitiveKey: RegExp;
82
+ };
83
+ /**
84
+ * Built-in redactor presets
85
+ */
86
+ declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
87
+ /**
88
+ * Create a proxy wrapper around ReadableSpan with redacted attributes
89
+ *
90
+ * Since ReadableSpan.attributes is readonly, we use a Proxy to intercept
91
+ * attribute access and return the redacted version.
92
+ */
93
+ declare function createRedactedSpan(span: ReadableSpan, redactor: AttributeRedactorFn): ReadableSpan;
94
+ /**
95
+ * Span processor that redacts sensitive data from span attributes.
96
+ *
97
+ * Redaction happens in onEnd() when all attributes are finalized.
98
+ * Uses a Proxy wrapper to intercept attribute access since ReadableSpan
99
+ * attributes are readonly.
100
+ *
101
+ * Common use cases:
102
+ * - PII compliance (GDPR, CCPA)
103
+ * - PCI-DSS compliance for payment data
104
+ * - Preventing secrets from leaking to observability backends
105
+ */
106
+ declare class AttributeRedactingProcessor implements SpanProcessor {
107
+ private readonly wrappedProcessor;
108
+ private readonly redactor;
109
+ constructor(wrappedProcessor: SpanProcessor, options: AttributeRedactingProcessorOptions);
110
+ /**
111
+ * Pass through onStart unchanged - attributes aren't finalized yet
112
+ */
113
+ onStart(span: Span, parentContext: Context): void;
114
+ /**
115
+ * Redact attributes and forward to wrapped processor
116
+ */
117
+ onEnd(span: ReadableSpan): void;
118
+ forceFlush(): Promise<void>;
119
+ shutdown(): Promise<void>;
120
+ }
121
+
122
+ export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, createRedactedSpan };
@@ -0,0 +1,4 @@
1
+ export { AttributeRedactingProcessor, REDACTOR_PATTERNS, REDACTOR_PRESETS, createRedactedSpan } from './chunk-5JDGZS4U.js';
2
+ import './chunk-DGUM43GV.js';
3
+ //# sourceMappingURL=attribute-redacting-processor.js.map
4
+ //# sourceMappingURL=attribute-redacting-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"attribute-redacting-processor.js"}
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var chunkLLKKDI2O_cjs = require('./chunk-LLKKDI2O.cjs');
4
+ require('./chunk-4XNNRSJU.cjs');
5
+ require('./chunk-JEQ2X3Z6.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "attrs", {
10
+ enumerable: true,
11
+ get: function () { return chunkLLKKDI2O_cjs.attrs; }
12
+ });
13
+ Object.defineProperty(exports, "autoRedactPII", {
14
+ enumerable: true,
15
+ get: function () { return chunkLLKKDI2O_cjs.autoRedactPII; }
16
+ });
17
+ Object.defineProperty(exports, "checkDeprecatedAttribute", {
18
+ enumerable: true,
19
+ get: function () { return chunkLLKKDI2O_cjs.checkDeprecatedAttribute; }
20
+ });
21
+ Object.defineProperty(exports, "dbClient", {
22
+ enumerable: true,
23
+ get: function () { return chunkLLKKDI2O_cjs.dbClient; }
24
+ });
25
+ Object.defineProperty(exports, "defaultGuardrails", {
26
+ enumerable: true,
27
+ get: function () { return chunkLLKKDI2O_cjs.defaultGuardrails; }
28
+ });
29
+ Object.defineProperty(exports, "httpClient", {
30
+ enumerable: true,
31
+ get: function () { return chunkLLKKDI2O_cjs.httpClient; }
32
+ });
33
+ Object.defineProperty(exports, "httpServer", {
34
+ enumerable: true,
35
+ get: function () { return chunkLLKKDI2O_cjs.httpServer; }
36
+ });
37
+ Object.defineProperty(exports, "identify", {
38
+ enumerable: true,
39
+ get: function () { return chunkLLKKDI2O_cjs.identify; }
40
+ });
41
+ Object.defineProperty(exports, "mergeAttrs", {
42
+ enumerable: true,
43
+ get: function () { return chunkLLKKDI2O_cjs.mergeAttrs; }
44
+ });
45
+ Object.defineProperty(exports, "mergeServiceResource", {
46
+ enumerable: true,
47
+ get: function () { return chunkLLKKDI2O_cjs.mergeServiceResource; }
48
+ });
49
+ Object.defineProperty(exports, "request", {
50
+ enumerable: true,
51
+ get: function () { return chunkLLKKDI2O_cjs.request; }
52
+ });
53
+ Object.defineProperty(exports, "safeSetAttributes", {
54
+ enumerable: true,
55
+ get: function () { return chunkLLKKDI2O_cjs.safeSetAttributes; }
56
+ });
57
+ Object.defineProperty(exports, "setDevice", {
58
+ enumerable: true,
59
+ get: function () { return chunkLLKKDI2O_cjs.setDevice; }
60
+ });
61
+ Object.defineProperty(exports, "setError", {
62
+ enumerable: true,
63
+ get: function () { return chunkLLKKDI2O_cjs.setError; }
64
+ });
65
+ Object.defineProperty(exports, "setException", {
66
+ enumerable: true,
67
+ get: function () { return chunkLLKKDI2O_cjs.setException; }
68
+ });
69
+ Object.defineProperty(exports, "setSession", {
70
+ enumerable: true,
71
+ get: function () { return chunkLLKKDI2O_cjs.setSession; }
72
+ });
73
+ Object.defineProperty(exports, "setUser", {
74
+ enumerable: true,
75
+ get: function () { return chunkLLKKDI2O_cjs.setUser; }
76
+ });
77
+ Object.defineProperty(exports, "transaction", {
78
+ enumerable: true,
79
+ get: function () { return chunkLLKKDI2O_cjs.transaction; }
80
+ });
81
+ Object.defineProperty(exports, "validateAttribute", {
82
+ enumerable: true,
83
+ get: function () { return chunkLLKKDI2O_cjs.validateAttribute; }
84
+ });
85
+ //# sourceMappingURL=attributes.cjs.map
86
+ //# sourceMappingURL=attributes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"attributes.cjs"}
@@ -0,0 +1,20 @@
1
+ import { U as UserAttrs, S as SessionAttrs, A as AttributePolicy } from './utils-DuNJfXSH.cjs';
2
+ export { p as AttributeGuardrails, J as ClientAttrs, C as CloudAttrs, Q as CodeAttrs, z as ContainerAttrs, t as DBAttrs, L as DeploymentAttrs, D as DeviceAttrs, E as ErrorAttrs, V as ExceptionAttrs, B as FaaSAttrs, F as FeatureFlagAttrs, G as GenAIAttrs, I as GraphQLAttrs, q as HTTPClientAttrs, H as HTTPServerAttrs, K as K8sAttrs, M as MessagingAttrs, N as NetworkAttrs, O as OTelAttrs, P as PeerAttrs, y as ProcessAttrs, R as RPCAttrs, w as ServerAddressAttrs, u as ServiceAttrs, W as TLSAttrs, T as ThreadAttrs, x as URLAttrs, a as attrs, n as autoRedactPII, l as checkDeprecatedAttribute, e as dbClient, o as defaultGuardrails, d as httpClient, h as httpServer, i as identify, j as mergeAttrs, m as mergeServiceResource, r as request, k as safeSetAttributes, c as setDevice, f as setError, g as setException, b as setSession, s as setUser, v as validateAttribute } from './utils-DuNJfXSH.cjs';
3
+ import { T as TraceContext } from './trace-context-t5X1AP-e.cjs';
4
+ import '@opentelemetry/api';
5
+ import '@opentelemetry/resources';
6
+
7
+ /**
8
+ * Domain helpers for common attribute patterns
9
+ * These bundle multiple attribute groups into semantic helpers
10
+ */
11
+ declare function transaction(spanOrContext: TraceContext, config: {
12
+ user?: UserAttrs;
13
+ session?: SessionAttrs;
14
+ method?: string;
15
+ route?: string;
16
+ statusCode?: number;
17
+ clientIp?: string;
18
+ }, guardrails?: AttributePolicy): void;
19
+
20
+ export { AttributePolicy, SessionAttrs, UserAttrs, transaction };
@@ -0,0 +1,20 @@
1
+ import { U as UserAttrs, S as SessionAttrs, A as AttributePolicy } from './utils-D1trOLNm.js';
2
+ export { p as AttributeGuardrails, J as ClientAttrs, C as CloudAttrs, Q as CodeAttrs, z as ContainerAttrs, t as DBAttrs, L as DeploymentAttrs, D as DeviceAttrs, E as ErrorAttrs, V as ExceptionAttrs, B as FaaSAttrs, F as FeatureFlagAttrs, G as GenAIAttrs, I as GraphQLAttrs, q as HTTPClientAttrs, H as HTTPServerAttrs, K as K8sAttrs, M as MessagingAttrs, N as NetworkAttrs, O as OTelAttrs, P as PeerAttrs, y as ProcessAttrs, R as RPCAttrs, w as ServerAddressAttrs, u as ServiceAttrs, W as TLSAttrs, T as ThreadAttrs, x as URLAttrs, a as attrs, n as autoRedactPII, l as checkDeprecatedAttribute, e as dbClient, o as defaultGuardrails, d as httpClient, h as httpServer, i as identify, j as mergeAttrs, m as mergeServiceResource, r as request, k as safeSetAttributes, c as setDevice, f as setError, g as setException, b as setSession, s as setUser, v as validateAttribute } from './utils-D1trOLNm.js';
3
+ import { T as TraceContext } from './trace-context-t5X1AP-e.js';
4
+ import '@opentelemetry/api';
5
+ import '@opentelemetry/resources';
6
+
7
+ /**
8
+ * Domain helpers for common attribute patterns
9
+ * These bundle multiple attribute groups into semantic helpers
10
+ */
11
+ declare function transaction(spanOrContext: TraceContext, config: {
12
+ user?: UserAttrs;
13
+ session?: SessionAttrs;
14
+ method?: string;
15
+ route?: string;
16
+ statusCode?: number;
17
+ clientIp?: string;
18
+ }, guardrails?: AttributePolicy): void;
19
+
20
+ export { AttributePolicy, SessionAttrs, UserAttrs, transaction };
@@ -0,0 +1,5 @@
1
+ export { attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute } from './chunk-7V4VPLG6.js';
2
+ import './chunk-5JDGZS4U.js';
3
+ import './chunk-DGUM43GV.js';
4
+ //# sourceMappingURL=attributes.js.map
5
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"attributes.js"}
package/dist/auto.cjs CHANGED
@@ -1,8 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkDWHIOTHR_cjs = require('./chunk-DWHIOTHR.cjs');
3
+ var chunkHPPYIHMT_cjs = require('./chunk-HPPYIHMT.cjs');
4
4
  var chunkJQTQ5IAY_cjs = require('./chunk-JQTQ5IAY.cjs');
5
5
  require('./chunk-GVLK7YUU.cjs');
6
+ require('./chunk-ZNMBW67B.cjs');
7
+ require('./chunk-IOYFAFHJ.cjs');
8
+ require('./chunk-4XNNRSJU.cjs');
9
+ require('./chunk-CU6IDACR.cjs');
6
10
  require('./chunk-YS6C2YJE.cjs');
7
11
  require('./chunk-INB6PRMW.cjs');
8
12
  require('./chunk-DJNOZI7B.cjs');
@@ -18,7 +22,7 @@ module$1.register("import-in-the-middle/hook.mjs", (typeof document === 'undefin
18
22
  var yamlConfig = chunkJQTQ5IAY_cjs.loadYamlConfig();
19
23
  var autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;
20
24
  var autoInstrumentations = autoInstrumentationsEnv === "true" ? true : autoInstrumentationsEnv ? autoInstrumentationsEnv.split(",").map((s) => s.trim()) : yamlConfig?.autoInstrumentations ?? ["http", "express"];
21
- chunkDWHIOTHR_cjs.init({
25
+ chunkHPPYIHMT_cjs.init({
22
26
  service: yamlConfig?.service ?? process.env.OTEL_SERVICE_NAME ?? "unknown-service",
23
27
  debug: yamlConfig?.debug ?? process.env.AUTOTEL_DEBUG === "true",
24
28
  autoInstrumentations