@superblocksteam/telemetry 2.0.83-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE.txt +87 -0
  2. package/README.md +155 -0
  3. package/dist/browser/index.d.ts +8 -0
  4. package/dist/browser/index.d.ts.map +1 -0
  5. package/dist/browser/index.js +19 -0
  6. package/dist/browser/index.js.map +1 -0
  7. package/dist/browser/init.d.ts +75 -0
  8. package/dist/browser/init.d.ts.map +1 -0
  9. package/dist/browser/init.js +169 -0
  10. package/dist/browser/init.js.map +1 -0
  11. package/dist/browser/resilient-exporter.d.ts +43 -0
  12. package/dist/browser/resilient-exporter.d.ts.map +1 -0
  13. package/dist/browser/resilient-exporter.js +88 -0
  14. package/dist/browser/resilient-exporter.js.map +1 -0
  15. package/dist/common/contracts/tier2-traces.d.ts +75 -0
  16. package/dist/common/contracts/tier2-traces.d.ts.map +1 -0
  17. package/dist/common/contracts/tier2-traces.js +186 -0
  18. package/dist/common/contracts/tier2-traces.js.map +1 -0
  19. package/dist/common/deployment-type.d.ts +18 -0
  20. package/dist/common/deployment-type.d.ts.map +1 -0
  21. package/dist/common/deployment-type.js +30 -0
  22. package/dist/common/deployment-type.js.map +1 -0
  23. package/dist/common/guardrails.d.ts +116 -0
  24. package/dist/common/guardrails.d.ts.map +1 -0
  25. package/dist/common/guardrails.js +189 -0
  26. package/dist/common/guardrails.js.map +1 -0
  27. package/dist/common/index.d.ts +16 -0
  28. package/dist/common/index.d.ts.map +1 -0
  29. package/dist/common/index.js +32 -0
  30. package/dist/common/index.js.map +1 -0
  31. package/dist/common/log-sanitizer.d.ts +78 -0
  32. package/dist/common/log-sanitizer.d.ts.map +1 -0
  33. package/dist/common/log-sanitizer.js +340 -0
  34. package/dist/common/log-sanitizer.js.map +1 -0
  35. package/dist/common/policy-evaluator.d.ts +103 -0
  36. package/dist/common/policy-evaluator.d.ts.map +1 -0
  37. package/dist/common/policy-evaluator.js +200 -0
  38. package/dist/common/policy-evaluator.js.map +1 -0
  39. package/dist/common/resource.d.ts +62 -0
  40. package/dist/common/resource.d.ts.map +1 -0
  41. package/dist/common/resource.js +106 -0
  42. package/dist/common/resource.js.map +1 -0
  43. package/dist/common/tier-hints.d.ts +182 -0
  44. package/dist/common/tier-hints.d.ts.map +1 -0
  45. package/dist/common/tier-hints.js +209 -0
  46. package/dist/common/tier-hints.js.map +1 -0
  47. package/dist/index.d.ts +43 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +76 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/lint/forbidden-attributes.d.ts +149 -0
  52. package/dist/lint/forbidden-attributes.d.ts.map +1 -0
  53. package/dist/lint/forbidden-attributes.js +214 -0
  54. package/dist/lint/forbidden-attributes.js.map +1 -0
  55. package/dist/lint/index.d.ts +9 -0
  56. package/dist/lint/index.d.ts.map +1 -0
  57. package/dist/lint/index.js +16 -0
  58. package/dist/lint/index.js.map +1 -0
  59. package/dist/llmobs/index.d.ts +22 -0
  60. package/dist/llmobs/index.d.ts.map +1 -0
  61. package/dist/llmobs/index.js +29 -0
  62. package/dist/llmobs/index.js.map +1 -0
  63. package/dist/llmobs/tier1-exporter.d.ts +146 -0
  64. package/dist/llmobs/tier1-exporter.d.ts.map +1 -0
  65. package/dist/llmobs/tier1-exporter.js +196 -0
  66. package/dist/llmobs/tier1-exporter.js.map +1 -0
  67. package/dist/llmobs/tier2-summarizer.d.ts +268 -0
  68. package/dist/llmobs/tier2-summarizer.d.ts.map +1 -0
  69. package/dist/llmobs/tier2-summarizer.js +650 -0
  70. package/dist/llmobs/tier2-summarizer.js.map +1 -0
  71. package/dist/node/exporters/resilient-exporter.d.ts +77 -0
  72. package/dist/node/exporters/resilient-exporter.d.ts.map +1 -0
  73. package/dist/node/exporters/resilient-exporter.js +129 -0
  74. package/dist/node/exporters/resilient-exporter.js.map +1 -0
  75. package/dist/node/index.d.ts +11 -0
  76. package/dist/node/index.d.ts.map +1 -0
  77. package/dist/node/index.js +24 -0
  78. package/dist/node/index.js.map +1 -0
  79. package/dist/node/init.d.ts +75 -0
  80. package/dist/node/init.d.ts.map +1 -0
  81. package/dist/node/init.js +245 -0
  82. package/dist/node/init.js.map +1 -0
  83. package/dist/node/log-processor.d.ts +83 -0
  84. package/dist/node/log-processor.d.ts.map +1 -0
  85. package/dist/node/log-processor.js +266 -0
  86. package/dist/node/log-processor.js.map +1 -0
  87. package/dist/node/metrics-client.d.ts +66 -0
  88. package/dist/node/metrics-client.d.ts.map +1 -0
  89. package/dist/node/metrics-client.js +193 -0
  90. package/dist/node/metrics-client.js.map +1 -0
  91. package/dist/node/traced-socket.d.ts +76 -0
  92. package/dist/node/traced-socket.d.ts.map +1 -0
  93. package/dist/node/traced-socket.js +261 -0
  94. package/dist/node/traced-socket.js.map +1 -0
  95. package/dist/testing/in-memory-exporter.d.ts +179 -0
  96. package/dist/testing/in-memory-exporter.d.ts.map +1 -0
  97. package/dist/testing/in-memory-exporter.js +254 -0
  98. package/dist/testing/in-memory-exporter.js.map +1 -0
  99. package/dist/testing/index.d.ts +8 -0
  100. package/dist/testing/index.d.ts.map +1 -0
  101. package/dist/testing/index.js +19 -0
  102. package/dist/testing/index.js.map +1 -0
  103. package/dist/testing/test-init.d.ts +80 -0
  104. package/dist/testing/test-init.d.ts.map +1 -0
  105. package/dist/testing/test-init.js +144 -0
  106. package/dist/testing/test-init.js.map +1 -0
  107. package/dist/types/index.d.ts +40 -0
  108. package/dist/types/index.d.ts.map +1 -0
  109. package/dist/types/index.js +23 -0
  110. package/dist/types/index.js.map +1 -0
  111. package/dist/types/policy.d.ts +92 -0
  112. package/dist/types/policy.d.ts.map +1 -0
  113. package/dist/types/policy.js +125 -0
  114. package/dist/types/policy.js.map +1 -0
  115. package/dist-esm/browser/index.d.ts +8 -0
  116. package/dist-esm/browser/index.d.ts.map +1 -0
  117. package/dist-esm/browser/index.js +9 -0
  118. package/dist-esm/browser/index.js.map +1 -0
  119. package/dist-esm/browser/init.d.ts +75 -0
  120. package/dist-esm/browser/init.d.ts.map +1 -0
  121. package/dist-esm/browser/init.js +162 -0
  122. package/dist-esm/browser/init.js.map +1 -0
  123. package/dist-esm/browser/resilient-exporter.d.ts +43 -0
  124. package/dist-esm/browser/resilient-exporter.d.ts.map +1 -0
  125. package/dist-esm/browser/resilient-exporter.js +84 -0
  126. package/dist-esm/browser/resilient-exporter.js.map +1 -0
  127. package/dist-esm/common/contracts/tier2-traces.d.ts +75 -0
  128. package/dist-esm/common/contracts/tier2-traces.d.ts.map +1 -0
  129. package/dist-esm/common/contracts/tier2-traces.js +178 -0
  130. package/dist-esm/common/contracts/tier2-traces.js.map +1 -0
  131. package/dist-esm/common/deployment-type.d.ts +18 -0
  132. package/dist-esm/common/deployment-type.d.ts.map +1 -0
  133. package/dist-esm/common/deployment-type.js +27 -0
  134. package/dist-esm/common/deployment-type.js.map +1 -0
  135. package/dist-esm/common/guardrails.d.ts +116 -0
  136. package/dist-esm/common/guardrails.d.ts.map +1 -0
  137. package/dist-esm/common/guardrails.js +179 -0
  138. package/dist-esm/common/guardrails.js.map +1 -0
  139. package/dist-esm/common/index.d.ts +16 -0
  140. package/dist-esm/common/index.d.ts.map +1 -0
  141. package/dist-esm/common/index.js +16 -0
  142. package/dist-esm/common/index.js.map +1 -0
  143. package/dist-esm/common/log-sanitizer.d.ts +78 -0
  144. package/dist-esm/common/log-sanitizer.d.ts.map +1 -0
  145. package/dist-esm/common/log-sanitizer.js +331 -0
  146. package/dist-esm/common/log-sanitizer.js.map +1 -0
  147. package/dist-esm/common/policy-evaluator.d.ts +103 -0
  148. package/dist-esm/common/policy-evaluator.d.ts.map +1 -0
  149. package/dist-esm/common/policy-evaluator.js +196 -0
  150. package/dist-esm/common/policy-evaluator.js.map +1 -0
  151. package/dist-esm/common/resource.d.ts +62 -0
  152. package/dist-esm/common/resource.d.ts.map +1 -0
  153. package/dist-esm/common/resource.js +100 -0
  154. package/dist-esm/common/resource.js.map +1 -0
  155. package/dist-esm/common/tier-hints.d.ts +182 -0
  156. package/dist-esm/common/tier-hints.d.ts.map +1 -0
  157. package/dist-esm/common/tier-hints.js +199 -0
  158. package/dist-esm/common/tier-hints.js.map +1 -0
  159. package/dist-esm/index.d.ts +43 -0
  160. package/dist-esm/index.d.ts.map +1 -0
  161. package/dist-esm/index.js +53 -0
  162. package/dist-esm/index.js.map +1 -0
  163. package/dist-esm/lint/forbidden-attributes.d.ts +149 -0
  164. package/dist-esm/lint/forbidden-attributes.d.ts.map +1 -0
  165. package/dist-esm/lint/forbidden-attributes.js +209 -0
  166. package/dist-esm/lint/forbidden-attributes.js.map +1 -0
  167. package/dist-esm/lint/index.d.ts +9 -0
  168. package/dist-esm/lint/index.d.ts.map +1 -0
  169. package/dist-esm/lint/index.js +9 -0
  170. package/dist-esm/lint/index.js.map +1 -0
  171. package/dist-esm/llmobs/index.d.ts +22 -0
  172. package/dist-esm/llmobs/index.d.ts.map +1 -0
  173. package/dist-esm/llmobs/index.js +22 -0
  174. package/dist-esm/llmobs/index.js.map +1 -0
  175. package/dist-esm/llmobs/tier1-exporter.d.ts +146 -0
  176. package/dist-esm/llmobs/tier1-exporter.d.ts.map +1 -0
  177. package/dist-esm/llmobs/tier1-exporter.js +190 -0
  178. package/dist-esm/llmobs/tier1-exporter.js.map +1 -0
  179. package/dist-esm/llmobs/tier2-summarizer.d.ts +268 -0
  180. package/dist-esm/llmobs/tier2-summarizer.d.ts.map +1 -0
  181. package/dist-esm/llmobs/tier2-summarizer.js +646 -0
  182. package/dist-esm/llmobs/tier2-summarizer.js.map +1 -0
  183. package/dist-esm/node/exporters/resilient-exporter.d.ts +77 -0
  184. package/dist-esm/node/exporters/resilient-exporter.d.ts.map +1 -0
  185. package/dist-esm/node/exporters/resilient-exporter.js +125 -0
  186. package/dist-esm/node/exporters/resilient-exporter.js.map +1 -0
  187. package/dist-esm/node/index.d.ts +11 -0
  188. package/dist-esm/node/index.d.ts.map +1 -0
  189. package/dist-esm/node/index.js +11 -0
  190. package/dist-esm/node/index.js.map +1 -0
  191. package/dist-esm/node/init.d.ts +75 -0
  192. package/dist-esm/node/init.d.ts.map +1 -0
  193. package/dist-esm/node/init.js +239 -0
  194. package/dist-esm/node/init.js.map +1 -0
  195. package/dist-esm/node/log-processor.d.ts +83 -0
  196. package/dist-esm/node/log-processor.d.ts.map +1 -0
  197. package/dist-esm/node/log-processor.js +261 -0
  198. package/dist-esm/node/log-processor.js.map +1 -0
  199. package/dist-esm/node/metrics-client.d.ts +66 -0
  200. package/dist-esm/node/metrics-client.d.ts.map +1 -0
  201. package/dist-esm/node/metrics-client.js +189 -0
  202. package/dist-esm/node/metrics-client.js.map +1 -0
  203. package/dist-esm/node/traced-socket.d.ts +76 -0
  204. package/dist-esm/node/traced-socket.d.ts.map +1 -0
  205. package/dist-esm/node/traced-socket.js +257 -0
  206. package/dist-esm/node/traced-socket.js.map +1 -0
  207. package/dist-esm/testing/in-memory-exporter.d.ts +179 -0
  208. package/dist-esm/testing/in-memory-exporter.d.ts.map +1 -0
  209. package/dist-esm/testing/in-memory-exporter.js +248 -0
  210. package/dist-esm/testing/in-memory-exporter.js.map +1 -0
  211. package/dist-esm/testing/index.d.ts +8 -0
  212. package/dist-esm/testing/index.d.ts.map +1 -0
  213. package/dist-esm/testing/index.js +8 -0
  214. package/dist-esm/testing/index.js.map +1 -0
  215. package/dist-esm/testing/test-init.d.ts +80 -0
  216. package/dist-esm/testing/test-init.d.ts.map +1 -0
  217. package/dist-esm/testing/test-init.js +137 -0
  218. package/dist-esm/testing/test-init.js.map +1 -0
  219. package/dist-esm/types/index.d.ts +40 -0
  220. package/dist-esm/types/index.d.ts.map +1 -0
  221. package/dist-esm/types/index.js +7 -0
  222. package/dist-esm/types/index.js.map +1 -0
  223. package/dist-esm/types/policy.d.ts +92 -0
  224. package/dist-esm/types/policy.d.ts.map +1 -0
  225. package/dist-esm/types/policy.js +122 -0
  226. package/dist-esm/types/policy.js.map +1 -0
  227. package/package.json +101 -0
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Tier Policy Hints
4
+ *
5
+ * SDK-level hints that inform the OTEL Collector how to route spans.
6
+ * These are HINTS, not guarantees — the Collector makes final routing decisions.
7
+ *
8
+ * NOTE: This is different from tier TAGS (which indicate which pipeline processed
9
+ * a span). Hints are prescriptive ("please route this way"), tags are descriptive
10
+ * ("this was processed by Tier X"). The Collector adds tier tags; the SDK adds hints.
11
+ *
12
+ * See: engineering/projects/o11y-refactor/proposals/sdk-tier-policy-hints.md
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TierPolicyHint = exports.TIER_HINT_ATTRIBUTE = void 0;
16
+ exports.setTierHint = setTierHint;
17
+ exports.markSensitive = markSensitive;
18
+ exports.markForAIAnalysis = markForAIAnalysis;
19
+ exports.markDebugOnly = markDebugOnly;
20
+ exports.getTierHint = getTierHint;
21
+ exports.shouldSkipTier2 = shouldSkipTier2;
22
+ exports.shouldIncludeTier3 = shouldIncludeTier3;
23
+ /**
24
+ * The attribute key used for tier policy hints.
25
+ * Collector filters on this attribute to make routing decisions.
26
+ */
27
+ exports.TIER_HINT_ATTRIBUTE = "superblocks.tier_hint";
28
+ /**
29
+ * Tier policy hints that inform the Collector how to route spans.
30
+ *
31
+ * These are HINTS, not guarantees — the Collector makes final routing decisions
32
+ * based on its configuration. In cloud-prem deployments, the Collector respects
33
+ * these hints to control which tiers receive the span.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { trace } from '@opentelemetry/api';
38
+ * import { TierPolicyHint, TIER_HINT_ATTRIBUTE } from '@superblocksteam/telemetry';
39
+ *
40
+ * const span = tracer.startSpan('sensitive_operation');
41
+ * span.setAttribute(TIER_HINT_ATTRIBUTE, TierPolicyHint.TIER1_ONLY);
42
+ * ```
43
+ */
44
+ var TierPolicyHint;
45
+ (function (TierPolicyHint) {
46
+ /**
47
+ * Route to Tier 1 only. Do not export to Tier 2 or Tier 3.
48
+ *
49
+ * Use for:
50
+ * - Spans containing customer secrets or credentials
51
+ * - Highly sensitive customer data that must not leave their environment
52
+ * - Debug/diagnostic spans that should remain local
53
+ *
54
+ * The span will be stored in the customer's Tier 1 backend (e.g., Tempo)
55
+ * but will NOT be exported to Superblocks (Tier 2) or AI analytics (Tier 3).
56
+ */
57
+ TierPolicyHint["TIER1_ONLY"] = "tier1_only";
58
+ /**
59
+ * Include in Tier 3 (AI quality analysis) in addition to Tier 1 and Tier 2.
60
+ *
61
+ * Use for:
62
+ * - GenAI spans that should be analyzed for quality metrics
63
+ * - AI/LLM operations where prompts and responses are valuable for analysis
64
+ * - Spans with AI quality signals (latency, token usage, etc.)
65
+ *
66
+ * The span will go to all tiers: Tier 1 (full fidelity), Tier 2 (sanitized),
67
+ * and Tier 3 (AI analytics with identity stripped).
68
+ */
69
+ TierPolicyHint["INCLUDE_TIER3"] = "include_tier3";
70
+ /**
71
+ * Skip all external export. Tier 1 (local) only, no Tier 2/3.
72
+ * Alias for TIER1_ONLY, kept for semantic clarity.
73
+ *
74
+ * Use for:
75
+ * - High-cardinality diagnostic spans (cost control)
76
+ * - Temporary debug spans that shouldn't persist
77
+ * - Spans that are only useful for local debugging
78
+ *
79
+ * This is functionally equivalent to TIER1_ONLY but communicates
80
+ * a different intent: "this is for cost/noise control" rather than
81
+ * "this contains sensitive data."
82
+ */
83
+ TierPolicyHint["SKIP_EXPORT"] = "skip_export";
84
+ })(TierPolicyHint || (exports.TierPolicyHint = TierPolicyHint = {}));
85
+ /**
86
+ * Set a tier policy hint on a span.
87
+ *
88
+ * This is a convenience function that sets the `superblocks.tier_hint` attribute.
89
+ * You can also set the attribute directly if preferred.
90
+ *
91
+ * @param span - The span to set the hint on
92
+ * @param hint - The tier policy hint
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import { setTierHint, TierPolicyHint } from '@superblocksteam/telemetry';
97
+ *
98
+ * tracer.startActiveSpan('decrypt_secret', (span) => {
99
+ * setTierHint(span, TierPolicyHint.TIER1_ONLY);
100
+ * // ... perform operation
101
+ * span.end();
102
+ * });
103
+ * ```
104
+ */
105
+ function setTierHint(span, hint) {
106
+ span.setAttribute(exports.TIER_HINT_ATTRIBUTE, hint);
107
+ }
108
+ /**
109
+ * Mark a span as containing sensitive data that should not leave Tier 1.
110
+ *
111
+ * Use this for spans that handle customer secrets, credentials, or other
112
+ * highly sensitive data that must remain in the customer's environment.
113
+ *
114
+ * @param span - The span to mark as sensitive
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * import { markSensitive } from '@superblocksteam/telemetry';
119
+ *
120
+ * tracer.startActiveSpan('decrypt_customer_secret', (span) => {
121
+ * markSensitive(span);
122
+ * // ... decrypt operation
123
+ * span.end();
124
+ * });
125
+ * ```
126
+ */
127
+ function markSensitive(span) {
128
+ setTierHint(span, TierPolicyHint.TIER1_ONLY);
129
+ }
130
+ /**
131
+ * Mark a span for AI quality analysis (Tier 3).
132
+ *
133
+ * Use this for GenAI spans that should be analyzed for quality metrics.
134
+ * The span will go to all tiers, with Tier 3 receiving the content
135
+ * (prompts/responses) for AI quality analysis.
136
+ *
137
+ * @param span - The span to mark for AI analysis
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * import { markForAIAnalysis } from '@superblocksteam/telemetry';
142
+ *
143
+ * tracer.startActiveSpan('gen_ai.chat', (span) => {
144
+ * markForAIAnalysis(span);
145
+ * span.setAttribute('gen_ai.system', 'anthropic');
146
+ * // ... LLM call
147
+ * span.end();
148
+ * });
149
+ * ```
150
+ */
151
+ function markForAIAnalysis(span) {
152
+ setTierHint(span, TierPolicyHint.INCLUDE_TIER3);
153
+ }
154
+ /**
155
+ * Mark a span as debug-only (no export to Tier 2/3).
156
+ *
157
+ * Use this for high-cardinality diagnostic spans where you want to
158
+ * control costs by preventing export to paid backends.
159
+ *
160
+ * @param span - The span to mark as debug-only
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * import { markDebugOnly } from '@superblocksteam/telemetry';
165
+ *
166
+ * tracer.startActiveSpan('debug.cache_lookup', (span) => {
167
+ * markDebugOnly(span);
168
+ * span.setAttribute('cache.key', cacheKey); // High cardinality OK
169
+ * // ... lookup
170
+ * span.end();
171
+ * });
172
+ * ```
173
+ */
174
+ function markDebugOnly(span) {
175
+ setTierHint(span, TierPolicyHint.SKIP_EXPORT);
176
+ }
177
+ /**
178
+ * Check if a span has a tier hint set.
179
+ *
180
+ * @param span - The span to check (must be a ReadableSpan with attributes)
181
+ * @returns The tier hint if set, undefined otherwise
182
+ */
183
+ function getTierHint(span) {
184
+ const hint = span.attributes?.[exports.TIER_HINT_ATTRIBUTE];
185
+ if (typeof hint === "string" &&
186
+ Object.values(TierPolicyHint).includes(hint)) {
187
+ return hint;
188
+ }
189
+ return undefined;
190
+ }
191
+ /**
192
+ * Check if a tier hint indicates the span should skip Tier 2 export.
193
+ *
194
+ * @param hint - The tier hint to check
195
+ * @returns true if Tier 2 should be skipped
196
+ */
197
+ function shouldSkipTier2(hint) {
198
+ return (hint === TierPolicyHint.TIER1_ONLY || hint === TierPolicyHint.SKIP_EXPORT);
199
+ }
200
+ /**
201
+ * Check if a tier hint indicates the span should be included in Tier 3.
202
+ *
203
+ * @param hint - The tier hint to check
204
+ * @returns true if Tier 3 should be included
205
+ */
206
+ function shouldIncludeTier3(hint) {
207
+ return hint === TierPolicyHint.INCLUDE_TIER3;
208
+ }
209
+ //# sourceMappingURL=tier-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier-hints.js","sourceRoot":"","sources":["../../src/common/tier-hints.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAyFH,kCAEC;AAqBD,sCAEC;AAuBD,8CAEC;AAsBD,sCAEC;AAQD,kCAWC;AAQD,0CAIC;AAQD,gDAEC;AAxMD;;;GAGG;AACU,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,IAAY,cAyCX;AAzCD,WAAY,cAAc;IACxB;;;;;;;;;;OAUG;IACH,2CAAyB,CAAA;IAEzB;;;;;;;;;;OAUG;IACH,iDAA+B,CAAA;IAE/B;;;;;;;;;;;;OAYG;IACH,6CAA2B,CAAA;AAC7B,CAAC,EAzCW,cAAc,8BAAd,cAAc,QAyCzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,WAAW,CAAC,IAAU,EAAE,IAAoB;IAC1D,IAAI,CAAC,YAAY,CAAC,2BAAmB,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa,CAAC,IAAU;IACtC,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,iBAAiB,CAAC,IAAU;IAC1C,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,aAAa,CAAC,IAAU;IACtC,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,IAE3B;IACC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,2BAAmB,CAAC,CAAC;IACpD,IACE,OAAO,IAAI,KAAK,QAAQ;QACxB,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAsB,CAAC,EAC9D,CAAC;QACD,OAAO,IAAsB,CAAC;IAChC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,IAAgC;IAC9D,OAAO,CACL,IAAI,KAAK,cAAc,CAAC,UAAU,IAAI,IAAI,KAAK,cAAc,CAAC,WAAW,CAC1E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,IAAgC;IACjE,OAAO,IAAI,KAAK,cAAc,CAAC,aAAa,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @superblocksteam/telemetry
3
+ *
4
+ * Canonical telemetry bootstrap package for all Superblocks services.
5
+ * Provides policy-aware OpenTelemetry initialization with tier-based routing.
6
+ *
7
+ * This package is the ONLY approved way to initialize telemetry.
8
+ * Direct usage of NodeSDK or WebTracerProvider is prohibited.
9
+ *
10
+ * ## Usage
11
+ *
12
+ * ### Node.js Services
13
+ *
14
+ * ```typescript
15
+ * import { initNodeTelemetry } from '@superblocksteam/telemetry/node';
16
+ * import { getDefaultPolicy, DeploymentType } from '@superblocksteam/shared';
17
+ *
18
+ * const policy = getDefaultPolicy(DeploymentType.CLOUD_PREM);
19
+ * const telemetry = initNodeTelemetry({
20
+ * serviceName: 'my-service',
21
+ * serviceVersion: '1.0.0',
22
+ * environment: 'production',
23
+ * otlpUrl: 'http://localhost:4318',
24
+ * }, policy);
25
+ * ```
26
+ *
27
+ * ### Browser
28
+ *
29
+ * ```typescript
30
+ * import { initBrowserTelemetry } from '@superblocksteam/telemetry/browser';
31
+ * ```
32
+ *
33
+ * ### Testing
34
+ *
35
+ * ```typescript
36
+ * import { initTestTelemetry } from '@superblocksteam/telemetry/testing';
37
+ * ```
38
+ */
39
+ export * from "./types/index.js";
40
+ export * from "./common/index.js";
41
+ export * from "./llmobs/index.js";
42
+ export { initNodeTelemetry, getTelemetryInstance, isTelemetryInitialized, resetTelemetry, type NodeTelemetryInstance, MetricsClient, type Labels, type CounterHandle, type GaugeHandle, type HistogramHandle, TracedSocket, type TracedSocketConfig, type TracedSocketOptions, } from './node/index.js';
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAIlC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,KAAK,qBAAqB,EAC1B,aAAa,EACb,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /**
3
+ * @superblocksteam/telemetry
4
+ *
5
+ * Canonical telemetry bootstrap package for all Superblocks services.
6
+ * Provides policy-aware OpenTelemetry initialization with tier-based routing.
7
+ *
8
+ * This package is the ONLY approved way to initialize telemetry.
9
+ * Direct usage of NodeSDK or WebTracerProvider is prohibited.
10
+ *
11
+ * ## Usage
12
+ *
13
+ * ### Node.js Services
14
+ *
15
+ * ```typescript
16
+ * import { initNodeTelemetry } from '@superblocksteam/telemetry/node';
17
+ * import { getDefaultPolicy, DeploymentType } from '@superblocksteam/shared';
18
+ *
19
+ * const policy = getDefaultPolicy(DeploymentType.CLOUD_PREM);
20
+ * const telemetry = initNodeTelemetry({
21
+ * serviceName: 'my-service',
22
+ * serviceVersion: '1.0.0',
23
+ * environment: 'production',
24
+ * otlpUrl: 'http://localhost:4318',
25
+ * }, policy);
26
+ * ```
27
+ *
28
+ * ### Browser
29
+ *
30
+ * ```typescript
31
+ * import { initBrowserTelemetry } from '@superblocksteam/telemetry/browser';
32
+ * ```
33
+ *
34
+ * ### Testing
35
+ *
36
+ * ```typescript
37
+ * import { initTestTelemetry } from '@superblocksteam/telemetry/testing';
38
+ * ```
39
+ */
40
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
41
+ if (k2 === undefined) k2 = k;
42
+ var desc = Object.getOwnPropertyDescriptor(m, k);
43
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
44
+ desc = { enumerable: true, get: function() { return m[k]; } };
45
+ }
46
+ Object.defineProperty(o, k2, desc);
47
+ }) : (function(o, m, k, k2) {
48
+ if (k2 === undefined) k2 = k;
49
+ o[k2] = m[k];
50
+ }));
51
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
52
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.TracedSocket = exports.MetricsClient = exports.resetTelemetry = exports.isTelemetryInitialized = exports.getTelemetryInstance = exports.initNodeTelemetry = void 0;
56
+ // Re-export types
57
+ __exportStar(require("./types/index.js"), exports);
58
+ // Re-export common utilities
59
+ __exportStar(require("./common/index.js"), exports);
60
+ // Re-export LLMObs tiered telemetry
61
+ __exportStar(require("./llmobs/index.js"), exports);
62
+ // Re-export Node.js telemetry functions for convenience
63
+ // This allows imports like: import { initNodeTelemetry } from '@superblocksteam/telemetry'
64
+ var index_js_1 = require("./node/index.js");
65
+ Object.defineProperty(exports, "initNodeTelemetry", { enumerable: true, get: function () { return index_js_1.initNodeTelemetry; } });
66
+ Object.defineProperty(exports, "getTelemetryInstance", { enumerable: true, get: function () { return index_js_1.getTelemetryInstance; } });
67
+ Object.defineProperty(exports, "isTelemetryInitialized", { enumerable: true, get: function () { return index_js_1.isTelemetryInitialized; } });
68
+ Object.defineProperty(exports, "resetTelemetry", { enumerable: true, get: function () { return index_js_1.resetTelemetry; } });
69
+ Object.defineProperty(exports, "MetricsClient", { enumerable: true, get: function () { return index_js_1.MetricsClient; } });
70
+ Object.defineProperty(exports, "TracedSocket", { enumerable: true, get: function () { return index_js_1.TracedSocket; } });
71
+ // Note: Browser and Testing modules are still exported via package.json subpath exports
72
+ // Import them as:
73
+ // - @superblocksteam/telemetry/browser
74
+ // - @superblocksteam/telemetry/testing
75
+ // - @superblocksteam/telemetry/llmobs
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;;;;;;;;;;;;;;;AAEH,kBAAkB;AAClB,mDAAiC;AAEjC,6BAA6B;AAC7B,oDAAkC;AAElC,oCAAoC;AACpC,oDAAkC;AAElC,wDAAwD;AACxD,2FAA2F;AAC3F,4CAcyB;AAbvB,6GAAA,iBAAiB,OAAA;AACjB,gHAAA,oBAAoB,OAAA;AACpB,kHAAA,sBAAsB,OAAA;AACtB,0GAAA,cAAc,OAAA;AAEd,yGAAA,aAAa,OAAA;AAKb,wGAAA,YAAY,OAAA;AAKd,wFAAwF;AACxF,kBAAkB;AAClB,yCAAyC;AACzC,yCAAyC;AACzC,wCAAwC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * ESLint Rule: No Forbidden Telemetry Attributes
3
+ *
4
+ * This rule detects usage of forbidden attributes in span/metric instrumentation.
5
+ * It catches common leak paths before code is merged.
6
+ *
7
+ * Usage in eslint.config.js:
8
+ * ```
9
+ * import { noForbiddenTelemetryAttributes } from '@superblocksteam/telemetry/lint';
10
+ *
11
+ * export default [
12
+ * {
13
+ * plugins: {
14
+ * telemetry: { rules: { 'no-forbidden-attributes': noForbiddenTelemetryAttributes } }
15
+ * },
16
+ * rules: {
17
+ * 'telemetry/no-forbidden-attributes': 'error'
18
+ * }
19
+ * }
20
+ * ];
21
+ * ```
22
+ */
23
+ /**
24
+ * Forbidden attribute patterns for static analysis.
25
+ */
26
+ export declare const FORBIDDEN_ATTRIBUTE_PATTERNS: string[];
27
+ /**
28
+ * ESLint rule metadata.
29
+ */
30
+ export declare const noForbiddenTelemetryAttributesMeta: {
31
+ type: string;
32
+ docs: {
33
+ description: string;
34
+ category: string;
35
+ recommended: boolean;
36
+ };
37
+ messages: {
38
+ forbiddenAttribute: string;
39
+ resourceOnlyAttribute: string;
40
+ };
41
+ schema: never[];
42
+ };
43
+ /**
44
+ * ESLint rule implementation.
45
+ *
46
+ * Detects patterns like:
47
+ * - span.setAttribute('prompt', value)
48
+ * - span.setAttributes({ prompt: value })
49
+ * - { 'prompt': value }
50
+ */
51
+ export declare function noForbiddenTelemetryAttributesCreate(context: any): {
52
+ CallExpression(node: any): void;
53
+ Property(node: any): void;
54
+ };
55
+ /**
56
+ * Complete ESLint rule export.
57
+ */
58
+ export declare const noForbiddenTelemetryAttributes: {
59
+ meta: {
60
+ type: string;
61
+ docs: {
62
+ description: string;
63
+ category: string;
64
+ recommended: boolean;
65
+ };
66
+ messages: {
67
+ forbiddenAttribute: string;
68
+ resourceOnlyAttribute: string;
69
+ };
70
+ schema: never[];
71
+ };
72
+ create: typeof noForbiddenTelemetryAttributesCreate;
73
+ };
74
+ /**
75
+ * ESLint rule: No Direct OTEL SDK Usage
76
+ *
77
+ * Detects direct usage of NodeSDK or WebTracerProvider outside the telemetry package.
78
+ */
79
+ export declare const noDirectOtelSdkMeta: {
80
+ type: string;
81
+ docs: {
82
+ description: string;
83
+ category: string;
84
+ recommended: boolean;
85
+ };
86
+ messages: {
87
+ directSdkUsage: string;
88
+ };
89
+ schema: never[];
90
+ };
91
+ export declare function noDirectOtelSdkCreate(context: any): {
92
+ ImportSpecifier?: undefined;
93
+ CallExpression?: undefined;
94
+ } | {
95
+ ImportSpecifier(node: any): void;
96
+ CallExpression(node: any): void;
97
+ };
98
+ export declare const noDirectOtelSdk: {
99
+ meta: {
100
+ type: string;
101
+ docs: {
102
+ description: string;
103
+ category: string;
104
+ recommended: boolean;
105
+ };
106
+ messages: {
107
+ directSdkUsage: string;
108
+ };
109
+ schema: never[];
110
+ };
111
+ create: typeof noDirectOtelSdkCreate;
112
+ };
113
+ /**
114
+ * All telemetry ESLint rules.
115
+ */
116
+ export declare const telemetryRules: {
117
+ 'no-forbidden-attributes': {
118
+ meta: {
119
+ type: string;
120
+ docs: {
121
+ description: string;
122
+ category: string;
123
+ recommended: boolean;
124
+ };
125
+ messages: {
126
+ forbiddenAttribute: string;
127
+ resourceOnlyAttribute: string;
128
+ };
129
+ schema: never[];
130
+ };
131
+ create: typeof noForbiddenTelemetryAttributesCreate;
132
+ };
133
+ 'no-direct-otel-sdk': {
134
+ meta: {
135
+ type: string;
136
+ docs: {
137
+ description: string;
138
+ category: string;
139
+ recommended: boolean;
140
+ };
141
+ messages: {
142
+ directSdkUsage: string;
143
+ };
144
+ schema: never[];
145
+ };
146
+ create: typeof noDirectOtelSdkCreate;
147
+ };
148
+ };
149
+ //# sourceMappingURL=forbidden-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden-attributes.d.ts","sourceRoot":"","sources":["../../src/lint/forbidden-attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH;;GAEG;AACH,eAAO,MAAM,4BAA4B,UAKxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;CAgB9C,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,GAAG;yBAsBxC,GAAG;mBA6BT,GAAG;EAuBrB;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;CAG1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;CAa/B,CAAC;AAYF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG;;;;0BASxB,GAAG;yBAYJ,GAAG;EAsB3B;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;CAG3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG1B,CAAC"}