weflayr 0.24.0 → 0.26.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 (234) hide show
  1. package/README.md +2 -2
  2. package/dist/{api → src/api}/generated/facade.gen.d.ts +86 -12
  3. package/dist/{api → src/api}/generated/facade.gen.js +4 -2
  4. package/dist/src/api/generated/index.d.ts +2 -0
  5. package/dist/{api → src/api}/generated/index.js +3 -1
  6. package/dist/{api → src/api}/generated/sdk.gen.d.ts +11 -3
  7. package/dist/{api → src/api}/generated/sdk.gen.js +34 -4
  8. package/{src/api/generated/types.gen.ts → dist/src/api/generated/types.gen.d.ts} +436 -153
  9. package/dist/{api → src/api}/makeEndpoint.js +1 -3
  10. package/dist/src/auto-instrument.d.ts +42 -0
  11. package/dist/src/auto-instrument.js +156 -0
  12. package/dist/src/index.d.ts +9 -0
  13. package/dist/src/index.js +49 -0
  14. package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.d.ts +20 -0
  15. package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +114 -0
  16. package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.d.ts +28 -0
  17. package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.js +92 -0
  18. package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.d.ts +25 -0
  19. package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.js +141 -0
  20. package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.d.ts +9 -0
  21. package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.js +17 -0
  22. package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.d.ts +15 -0
  23. package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +50 -0
  24. package/dist/src/instrumentation/anthropic/set_telemetry_attributes.d.ts +15 -0
  25. package/dist/src/instrumentation/anthropic/set_telemetry_attributes.js +39 -0
  26. package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.d.ts +22 -0
  27. package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.js +97 -0
  28. package/dist/src/instrumentation/bedrock/get_cache_telemetry.d.ts +22 -0
  29. package/dist/src/instrumentation/bedrock/get_cache_telemetry.js +102 -0
  30. package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.d.ts +15 -0
  31. package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.js +91 -0
  32. package/dist/src/instrumentation/bedrock/get_model_id_telemetry.d.ts +21 -0
  33. package/dist/src/instrumentation/bedrock/get_model_id_telemetry.js +54 -0
  34. package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.d.ts +19 -0
  35. package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.js +81 -0
  36. package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.d.ts +27 -0
  37. package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +126 -0
  38. package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.d.ts +17 -0
  39. package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.js +85 -0
  40. package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.d.ts +15 -0
  41. package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.js +68 -0
  42. package/dist/src/instrumentation/bedrock/set_telemetry_attributes.d.ts +18 -0
  43. package/dist/src/instrumentation/bedrock/set_telemetry_attributes.js +47 -0
  44. package/dist/src/instrumentation/cohere/get_chat_telemetry.d.ts +23 -0
  45. package/dist/src/instrumentation/cohere/get_chat_telemetry.js +77 -0
  46. package/dist/src/instrumentation/cohere/get_embeddings_telemetry.d.ts +18 -0
  47. package/dist/src/instrumentation/cohere/get_embeddings_telemetry.js +88 -0
  48. package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.d.ts +12 -0
  49. package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.js +18 -0
  50. package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.d.ts +31 -0
  51. package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.js +106 -0
  52. package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.d.ts +27 -0
  53. package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.js +75 -0
  54. package/dist/src/instrumentation/cohere/set_telemetry_attributes.d.ts +17 -0
  55. package/dist/src/instrumentation/cohere/set_telemetry_attributes.js +44 -0
  56. package/dist/src/instrumentation/elevenlabs/full_instrumentation.d.ts +28 -0
  57. package/dist/src/instrumentation/elevenlabs/full_instrumentation.js +209 -0
  58. package/dist/src/instrumentation/google/get_audio_telemetry.d.ts +9 -0
  59. package/dist/src/instrumentation/google/get_audio_telemetry.js +28 -0
  60. package/dist/src/instrumentation/google/get_cache_operations_telemetry.d.ts +23 -0
  61. package/dist/src/instrumentation/google/get_cache_operations_telemetry.js +154 -0
  62. package/dist/src/instrumentation/google/get_cache_telemetry.d.ts +16 -0
  63. package/{src → dist/src}/instrumentation/google/get_cache_telemetry.js +18 -19
  64. package/dist/src/instrumentation/google/get_embeddings_telemetry.d.ts +12 -0
  65. package/dist/src/instrumentation/google/get_embeddings_telemetry.js +85 -0
  66. package/dist/src/instrumentation/google/get_provider_name.d.ts +11 -0
  67. package/{src → dist/src}/instrumentation/google/get_provider_name.js +11 -12
  68. package/{src/instrumentation/google/get_reasoning_telemetry.js → dist/src/instrumentation/google/get_reasoning_telemetry.d.ts} +1 -11
  69. package/dist/src/instrumentation/google/get_reasoning_telemetry.js +21 -0
  70. package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.d.ts +12 -0
  71. package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.js +19 -0
  72. package/dist/src/instrumentation/google/set_telemetry_attributes.d.ts +18 -0
  73. package/dist/src/instrumentation/google/set_telemetry_attributes.js +98 -0
  74. package/dist/src/instrumentation/openai/get_audio_telemetry.d.ts +25 -0
  75. package/dist/src/instrumentation/openai/get_audio_telemetry.js +123 -0
  76. package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.d.ts +35 -0
  77. package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.js +148 -0
  78. package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.d.ts +27 -0
  79. package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +72 -0
  80. package/dist/src/instrumentation/openai/get_cache_config_telemetry.d.ts +28 -0
  81. package/dist/src/instrumentation/openai/get_cache_config_telemetry.js +91 -0
  82. package/dist/src/instrumentation/openai/get_embeddings_telemetry.d.ts +18 -0
  83. package/dist/src/instrumentation/openai/get_embeddings_telemetry.js +86 -0
  84. package/dist/src/instrumentation/openai/get_streaming_usage.d.ts +21 -0
  85. package/dist/src/instrumentation/openai/get_streaming_usage.js +74 -0
  86. package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.d.ts +12 -0
  87. package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.js +20 -0
  88. package/dist/src/instrumentation/openai/set_telemetry_attributes.d.ts +17 -0
  89. package/dist/src/instrumentation/openai/set_telemetry_attributes.js +47 -0
  90. package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.d.ts +35 -0
  91. package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.js +76 -0
  92. package/dist/src/instrumentation/vercel/full_instrumentation.d.ts +3 -0
  93. package/dist/src/instrumentation/vercel/full_instrumentation.js +54 -0
  94. package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.d.ts +22 -0
  95. package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.js +66 -0
  96. package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.d.ts +24 -0
  97. package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.js +84 -0
  98. package/dist/src/logger.d.ts +1 -0
  99. package/dist/src/logger.js +6 -0
  100. package/dist/src/otel/exporter.d.ts +19 -0
  101. package/dist/src/otel/exporter.js +94 -0
  102. package/dist/src/otel/propagation.d.ts +46 -0
  103. package/dist/src/otel/propagation.js +110 -0
  104. package/dist/src/otel/span-filter.d.ts +3 -0
  105. package/dist/src/otel/span-filter.js +61 -0
  106. package/dist/src/otel/span-processor.d.ts +55 -0
  107. package/dist/src/otel/span-processor.js +169 -0
  108. package/dist/src/otel/vercel-ai-sdk-span-filter.d.ts +12 -0
  109. package/dist/src/otel/vercel-ai-sdk-span-filter.js +88 -0
  110. package/dist/src/setup.d.ts +50 -0
  111. package/dist/src/setup.js +155 -0
  112. package/package.json +11 -5
  113. package/.prettierignore +0 -2
  114. package/.prettierrc.json +0 -7
  115. package/LICENSE-MIT +0 -21
  116. package/NOTICE +0 -12
  117. package/dist/api/generated/index.d.ts +0 -2
  118. package/dist/api/generated/types.gen.d.ts +0 -1005
  119. package/eslint.config.mjs +0 -36
  120. package/index.d.ts +0 -170
  121. package/openapi-ts.config.mjs +0 -9
  122. package/scripts/generate_facade.mjs +0 -86
  123. package/src/api/caseConversion.ts +0 -58
  124. package/src/api/generated/client/client.gen.ts +0 -277
  125. package/src/api/generated/client/index.ts +0 -27
  126. package/src/api/generated/client/types.gen.ts +0 -218
  127. package/src/api/generated/client/utils.gen.ts +0 -316
  128. package/src/api/generated/client.gen.ts +0 -16
  129. package/src/api/generated/core/auth.gen.ts +0 -48
  130. package/src/api/generated/core/bodySerializer.gen.ts +0 -82
  131. package/src/api/generated/core/params.gen.ts +0 -178
  132. package/src/api/generated/core/pathSerializer.gen.ts +0 -171
  133. package/src/api/generated/core/queryKeySerializer.gen.ts +0 -117
  134. package/src/api/generated/core/serverSentEvents.gen.ts +0 -242
  135. package/src/api/generated/core/types.gen.ts +0 -110
  136. package/src/api/generated/core/utils.gen.ts +0 -140
  137. package/src/api/generated/facade.gen.ts +0 -104
  138. package/src/api/generated/index.ts +0 -4
  139. package/src/api/generated/sdk.gen.ts +0 -175
  140. package/src/api/index.ts +0 -45
  141. package/src/api/makeEndpoint.ts +0 -54
  142. package/src/auto-instrument.js +0 -172
  143. package/src/index.js +0 -19
  144. package/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +0 -118
  145. package/src/instrumentation/anthropic/get_cache_config_telemetry.js +0 -90
  146. package/src/instrumentation/anthropic/get_streaming_stop_reason_telemetry.js +0 -121
  147. package/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +0 -55
  148. package/src/instrumentation/anthropic/set_telemetry_attributes.js +0 -39
  149. package/src/instrumentation/bedrock/get_cache_config_telemetry.js +0 -106
  150. package/src/instrumentation/bedrock/get_cache_telemetry.js +0 -109
  151. package/src/instrumentation/bedrock/get_input_message_content_telemetry.js +0 -94
  152. package/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +0 -87
  153. package/src/instrumentation/bedrock/set_telemetry_attributes.js +0 -40
  154. package/src/instrumentation/cohere/get_chat_telemetry.js +0 -88
  155. package/src/instrumentation/cohere/get_embeddings_telemetry.js +0 -107
  156. package/src/instrumentation/cohere/set_telemetry_attributes.js +0 -32
  157. package/src/instrumentation/elevenlabs/full_instrumentation.js +0 -236
  158. package/src/instrumentation/google/get_audio_telemetry.js +0 -30
  159. package/src/instrumentation/google/get_cache_operations_telemetry.js +0 -171
  160. package/src/instrumentation/google/get_embeddings_telemetry.js +0 -99
  161. package/src/instrumentation/google/set_telemetry_attributes.js +0 -104
  162. package/src/instrumentation/openai/get_audio_telemetry.js +0 -149
  163. package/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +0 -71
  164. package/src/instrumentation/openai/get_cache_config_telemetry.js +0 -63
  165. package/src/instrumentation/openai/get_embeddings_telemetry.js +0 -107
  166. package/src/instrumentation/openai/get_streaming_usage.js +0 -81
  167. package/src/instrumentation/openai/set_telemetry_attributes.js +0 -41
  168. package/src/instrumentation/vercel/full_instrumentation.js +0 -52
  169. package/src/instrumentation/vercel/get_cache_creation_telemetry.js +0 -70
  170. package/src/logger.js +0 -8
  171. package/src/otel/exporter.js +0 -108
  172. package/src/otel/propagation.js +0 -146
  173. package/src/otel/span-filter.js +0 -69
  174. package/src/otel/span-processor.js +0 -170
  175. package/src/otel/vercel-ai-sdk-span-filter.js +0 -79
  176. package/src/setup.js +0 -167
  177. package/tests/api/index.test.js +0 -437
  178. package/tests/index.test.js +0 -884
  179. package/tests/instrumentation/anthropic/get_cache_and_reasoning_telemetry.test.js +0 -181
  180. package/tests/instrumentation/anthropic/get_cache_config_telemetry.test.js +0 -92
  181. package/tests/instrumentation/anthropic/get_streaming_stop_reason_telemetry.test.js +0 -117
  182. package/tests/instrumentation/anthropic/get_tool_definitions_telemetry.test.js +0 -97
  183. package/tests/instrumentation/bedrock/get_cache_config_telemetry.test.js +0 -107
  184. package/tests/instrumentation/bedrock/get_cache_telemetry.test.js +0 -118
  185. package/tests/instrumentation/bedrock/get_input_message_content_telemetry.test.js +0 -89
  186. package/tests/instrumentation/bedrock/get_streaming_output_message_telemetry.test.js +0 -87
  187. package/tests/instrumentation/cohere/get_chat_telemetry.test.js +0 -148
  188. package/tests/instrumentation/cohere/get_embeddings_telemetry.test.js +0 -132
  189. package/tests/instrumentation/elevenlabs/full_instrumentation.test.js +0 -258
  190. package/tests/instrumentation/google/get_cache_operations_telemetry.test.js +0 -130
  191. package/tests/instrumentation/google/get_embeddings_telemetry.test.js +0 -128
  192. package/tests/instrumentation/google/get_reasoning_telemetry.test.js +0 -41
  193. package/tests/instrumentation/google/set_telemetry_attributes.test.js +0 -219
  194. package/tests/instrumentation/openai/get_audio_telemetry.test.js +0 -170
  195. package/tests/instrumentation/openai/get_cache_and_reasoning_telemetry.test.js +0 -83
  196. package/tests/instrumentation/openai/get_cache_config_telemetry.test.js +0 -83
  197. package/tests/instrumentation/openai/get_embeddings_telemetry.test.js +0 -145
  198. package/tests/instrumentation/openai/get_streaming_usage.test.js +0 -105
  199. package/tests/instrumentation/vercel/full_instrumentation.test.js +0 -16
  200. package/tests/instrumentation/vercel/get_cache_creation_telemetry.test.js +0 -96
  201. package/tests/otel/vercel-ai-sdk-span-filter.test.js +0 -159
  202. package/tsconfig.json +0 -18
  203. /package/dist/{api → src/api}/caseConversion.d.ts +0 -0
  204. /package/dist/{api → src/api}/caseConversion.js +0 -0
  205. /package/dist/{api → src/api}/generated/client/client.gen.d.ts +0 -0
  206. /package/dist/{api → src/api}/generated/client/client.gen.js +0 -0
  207. /package/dist/{api → src/api}/generated/client/index.d.ts +0 -0
  208. /package/dist/{api → src/api}/generated/client/index.js +0 -0
  209. /package/dist/{api → src/api}/generated/client/types.gen.d.ts +0 -0
  210. /package/dist/{api → src/api}/generated/client/types.gen.js +0 -0
  211. /package/dist/{api → src/api}/generated/client/utils.gen.d.ts +0 -0
  212. /package/dist/{api → src/api}/generated/client/utils.gen.js +0 -0
  213. /package/dist/{api → src/api}/generated/client.gen.d.ts +0 -0
  214. /package/dist/{api → src/api}/generated/client.gen.js +0 -0
  215. /package/dist/{api → src/api}/generated/core/auth.gen.d.ts +0 -0
  216. /package/dist/{api → src/api}/generated/core/auth.gen.js +0 -0
  217. /package/dist/{api → src/api}/generated/core/bodySerializer.gen.d.ts +0 -0
  218. /package/dist/{api → src/api}/generated/core/bodySerializer.gen.js +0 -0
  219. /package/dist/{api → src/api}/generated/core/params.gen.d.ts +0 -0
  220. /package/dist/{api → src/api}/generated/core/params.gen.js +0 -0
  221. /package/dist/{api → src/api}/generated/core/pathSerializer.gen.d.ts +0 -0
  222. /package/dist/{api → src/api}/generated/core/pathSerializer.gen.js +0 -0
  223. /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.d.ts +0 -0
  224. /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.js +0 -0
  225. /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.d.ts +0 -0
  226. /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.js +0 -0
  227. /package/dist/{api → src/api}/generated/core/types.gen.d.ts +0 -0
  228. /package/dist/{api → src/api}/generated/core/types.gen.js +0 -0
  229. /package/dist/{api → src/api}/generated/core/utils.gen.d.ts +0 -0
  230. /package/dist/{api → src/api}/generated/core/utils.gen.js +0 -0
  231. /package/dist/{api → src/api}/generated/types.gen.js +0 -0
  232. /package/dist/{api → src/api}/index.d.ts +0 -0
  233. /package/dist/{api → src/api}/index.js +0 -0
  234. /package/dist/{api → src/api}/makeEndpoint.d.ts +0 -0
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Hand-written OTel instrumentor for the ElevenLabs audio clients.
4
+ *
5
+ * No official OpenTelemetry instrumentor exists for the ElevenLabs SDK (it's
6
+ * audio, not an LLM), so this ships inside weflayr. It wraps the Text-to-Speech
7
+ * and Speech-to-Text entrypoints to emit one `gen_ai.*` span per call, which
8
+ * flows through the standard span processor -> exporter with no new transport code.
9
+ *
10
+ * The billable unit differs by API, so each span records the one ElevenLabs bills:
11
+ * - Text-to-Speech is billed per input character -> `gen_ai.usage.input_characters`.
12
+ * - Speech-to-Text is billed per second of audio -> `gen_ai.usage.input_seconds`.
13
+ *
14
+ * Entrypoints come in three result shapes, independent of which API they belong to:
15
+ * - *byte stream* methods resolve to a `ReadableStream` of audio chunks;
16
+ * - *object stream* methods resolve to an async-iterable of chunk objects;
17
+ * - *unary* methods resolve to the full response.
18
+ * The HTTP request -- plus any error -- only happens while a stream is awaited
19
+ * and consumed, so the span is started eagerly (to capture the
20
+ * `propagateMetadata` context active at the call site) and ended once the result
21
+ * is exhausted (streams) or returned (unary), giving an `elapsed_ms` that covers
22
+ * the whole call. The per-second billable unit is read off the STT response.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.ElevenLabsInstrumentor = void 0;
26
+ const api_1 = require("@opentelemetry/api");
27
+ const TRACER_NAME = 'weflayr.instrumentation.elevenlabs';
28
+ const SYSTEM = 'elevenlabs';
29
+ const TTS_OPERATION = 'text_to_speech';
30
+ const STT_OPERATION = 'speech_to_text';
31
+ function _startSpan(operation, request) {
32
+ const span = api_1.trace.getTracer(TRACER_NAME).startSpan(operation);
33
+ span.setAttribute('gen_ai.system', SYSTEM);
34
+ span.setAttribute('gen_ai.operation.name', operation);
35
+ // `modelId` lives on the request body passed to every audio entrypoint.
36
+ const modelId = request && request.modelId;
37
+ if (modelId) {
38
+ span.setAttribute('gen_ai.request.model', modelId);
39
+ }
40
+ return span;
41
+ }
42
+ function _setInputCharacters(span, request) {
43
+ // `text` lives on the request body of every TTS entrypoint; the billable unit
44
+ // is its length.
45
+ span.setAttribute('gen_ai.usage.input_characters', ((request && request.text) || '').length);
46
+ }
47
+ function _setAudioDuration(span, response) {
48
+ // The transcription response exposes the transcribed audio length in seconds.
49
+ const durationSecs = response && response.audioDurationSecs;
50
+ if (durationSecs != null) {
51
+ span.setAttribute('gen_ai.usage.input_seconds', durationSecs);
52
+ }
53
+ }
54
+ function _recordError(span, error) {
55
+ span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error?.message ?? String(error) });
56
+ span.recordException(error);
57
+ }
58
+ // Proxy a `ReadableStream` of audio bytes so the span ends -- and any error is
59
+ // recorded -- once the whole stream has been consumed (or the consumer cancels).
60
+ // The span ends exactly once across every exit path.
61
+ function _consumeByteStream(span, responsePromise) {
62
+ let ended = false;
63
+ const end = () => {
64
+ if (ended)
65
+ return;
66
+ ended = true;
67
+ span.end();
68
+ };
69
+ return responsePromise.then((audioStream) => {
70
+ const reader = audioStream.getReader();
71
+ return new ReadableStream({
72
+ async pull(controller) {
73
+ try {
74
+ const { done, value } = await reader.read();
75
+ if (done) {
76
+ end();
77
+ controller.close();
78
+ return;
79
+ }
80
+ controller.enqueue(value);
81
+ }
82
+ catch (error) {
83
+ _recordError(span, error);
84
+ end();
85
+ controller.error(error);
86
+ }
87
+ },
88
+ cancel(reason) {
89
+ end();
90
+ return reader.cancel(reason);
91
+ },
92
+ });
93
+ }, (error) => {
94
+ _recordError(span, error);
95
+ end();
96
+ throw error;
97
+ });
98
+ }
99
+ // Proxy an async-iterable of chunk objects (the streaming "with timestamps"
100
+ // variant) so the span ends once iteration completes.
101
+ function _consumeObjectStream(span, responsePromise) {
102
+ async function* iterate(stream) {
103
+ try {
104
+ for await (const chunk of stream) {
105
+ yield chunk;
106
+ }
107
+ }
108
+ catch (error) {
109
+ _recordError(span, error);
110
+ throw error;
111
+ }
112
+ finally {
113
+ span.end();
114
+ }
115
+ }
116
+ return responsePromise.then((stream) => iterate(stream), (error) => {
117
+ _recordError(span, error);
118
+ span.end();
119
+ throw error;
120
+ });
121
+ }
122
+ // Wrap a request/response entrypoint: the span spans the single call, and any
123
+ // response-derived billable unit is read off the result.
124
+ function _consumeUnary(span, responsePromise, setResponseAttributes) {
125
+ return responsePromise.then((response) => {
126
+ if (setResponseAttributes) {
127
+ setResponseAttributes(span, response);
128
+ }
129
+ span.end();
130
+ return response;
131
+ }, (error) => {
132
+ _recordError(span, error);
133
+ span.end();
134
+ throw error;
135
+ });
136
+ }
137
+ class ElevenLabsInstrumentor {
138
+ // [ownerPrototype, methodName, originalFunction] for uninstrument().
139
+ _patched = [];
140
+ instrument() {
141
+ let TextToSpeechClient;
142
+ let SpeechToTextClient;
143
+ try {
144
+ ({
145
+ TextToSpeechClient,
146
+ } = require('@elevenlabs/elevenlabs-js/api/resources/textToSpeech/client/Client'));
147
+ ({
148
+ SpeechToTextClient,
149
+ } = require('@elevenlabs/elevenlabs-js/api/resources/speechToText/client/Client'));
150
+ }
151
+ catch (err) {
152
+ throw new Error('weflayr.autoInstrument(ELEVENLABS): the @elevenlabs/elevenlabs-js client is not ' +
153
+ 'installed. Install it with: npm install @elevenlabs/elevenlabs-js\n' +
154
+ `Underlying error: ${err.message}`);
155
+ }
156
+ // TTS — request body is the 2nd arg (after voice_id); billed per character.
157
+ this._wrap(TextToSpeechClient.prototype, 'convert', {
158
+ operation: TTS_OPERATION,
159
+ requestArgIndex: 1,
160
+ setRequestAttributes: _setInputCharacters,
161
+ consume: _consumeByteStream,
162
+ });
163
+ this._wrap(TextToSpeechClient.prototype, 'stream', {
164
+ operation: TTS_OPERATION,
165
+ requestArgIndex: 1,
166
+ setRequestAttributes: _setInputCharacters,
167
+ consume: _consumeByteStream,
168
+ });
169
+ this._wrap(TextToSpeechClient.prototype, 'streamWithTimestamps', {
170
+ operation: TTS_OPERATION,
171
+ requestArgIndex: 1,
172
+ setRequestAttributes: _setInputCharacters,
173
+ consume: _consumeObjectStream,
174
+ });
175
+ this._wrap(TextToSpeechClient.prototype, 'convertWithTimestamps', {
176
+ operation: TTS_OPERATION,
177
+ requestArgIndex: 1,
178
+ setRequestAttributes: _setInputCharacters,
179
+ consume: (span, responsePromise) => _consumeUnary(span, responsePromise, null),
180
+ });
181
+ // STT — request body is the 1st arg; billed per second of audio.
182
+ this._wrap(SpeechToTextClient.prototype, 'convert', {
183
+ operation: STT_OPERATION,
184
+ requestArgIndex: 0,
185
+ setRequestAttributes: null,
186
+ consume: (span, responsePromise) => _consumeUnary(span, responsePromise, _setAudioDuration),
187
+ });
188
+ }
189
+ uninstrument() {
190
+ for (const [owner, methodName, original] of this._patched) {
191
+ owner[methodName] = original;
192
+ }
193
+ this._patched = [];
194
+ }
195
+ _wrap(owner, methodName, { operation, requestArgIndex, setRequestAttributes, consume, }) {
196
+ const original = owner[methodName];
197
+ function wrapper(...args) {
198
+ const request = args[requestArgIndex];
199
+ const span = _startSpan(operation, request);
200
+ if (setRequestAttributes) {
201
+ setRequestAttributes(span, request);
202
+ }
203
+ return consume(span, original.apply(this, args));
204
+ }
205
+ owner[methodName] = wrapper;
206
+ this._patched.push([owner, methodName, original]);
207
+ }
208
+ }
209
+ exports.ElevenLabsInstrumentor = ElevenLabsInstrumentor;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Per-modality audio token enrichment for the Google GenAI (Gemini) chat span.
3
+ *
4
+ * Neither instrumentor breaks usage down by modality, so for audio in/out (e.g.
5
+ * Gemini TTS) we read the response's per-modality token details and set
6
+ * `gen_ai.usage.{input,output}_tokens_details.audio_tokens`.
7
+ */
8
+ export declare function _audioTokens(details: any): number;
9
+ export declare function setAudioTelemetry(span: any, response: any): void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Per-modality audio token enrichment for the Google GenAI (Gemini) chat span.
4
+ *
5
+ * Neither instrumentor breaks usage down by modality, so for audio in/out (e.g.
6
+ * Gemini TTS) we read the response's per-modality token details and set
7
+ * `gen_ai.usage.{input,output}_tokens_details.audio_tokens`.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports._audioTokens = _audioTokens;
11
+ exports.setAudioTelemetry = setAudioTelemetry;
12
+ // Sum the token counts whose modality is AUDIO across a *TokensDetails array.
13
+ function _audioTokens(details) {
14
+ if (!Array.isArray(details))
15
+ return 0;
16
+ return details.reduce((total, detail) => total + (detail && detail.modality === 'AUDIO' ? detail.tokenCount || 0 : 0), 0);
17
+ }
18
+ function setAudioTelemetry(span, response) {
19
+ const usage = response && response.usageMetadata;
20
+ if (!usage)
21
+ return;
22
+ const inputAudio = _audioTokens(usage.promptTokensDetails);
23
+ const outputAudio = _audioTokens(usage.candidatesTokensDetails);
24
+ if (inputAudio)
25
+ span.setAttribute('gen_ai.usage.input_tokens_details.audio_tokens', inputAudio);
26
+ if (outputAudio)
27
+ span.setAttribute('gen_ai.usage.output_tokens_details.audio_tokens', outputAudio);
28
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Explicit-cache lifecycle telemetry for Google GenAI (Gemini).
3
+ *
4
+ * Explicit caching happens through API calls that are not LLM calls — the
5
+ * caller uploads content once via `client.caches.create` (returning a
6
+ * `cachedContents/{id}` name later referenced by `generateContent`), and may
7
+ * extend its TTL (`caches.update`) or remove it (`caches.delete`). No
8
+ * instrumentor covers these endpoints, so the cached content and its lifetime
9
+ * were invisible to the telemetry.
10
+ *
11
+ * One span per lifecycle call, carrying:
12
+ * - `weflayr.cache.operation` — create / update / delete
13
+ * - `weflayr.cache.cached_content_id` — the cache's server-generated name
14
+ * - `weflayr.cache.expire_time` — absolute expiry (create / update)
15
+ * - `gen_ai.usage.input_tokens` — the cached content's token count
16
+ * (create only; billed at the standard input rate)
17
+ * - the cached content itself (`gen_ai.input.messages` /
18
+ * `gen_ai.system_instructions` / `gen_ai.tool.definitions`) — the content
19
+ * is sent only on the create call and never repeated in the calls that use
20
+ * the cache, so this is the one place it can be captured. The span
21
+ * processor strips these when message-content capture is disabled.
22
+ */
23
+ export declare function instrumentCacheOperations(Caches: any, patched: [any, string, any][]): void;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ /**
3
+ * Explicit-cache lifecycle telemetry for Google GenAI (Gemini).
4
+ *
5
+ * Explicit caching happens through API calls that are not LLM calls — the
6
+ * caller uploads content once via `client.caches.create` (returning a
7
+ * `cachedContents/{id}` name later referenced by `generateContent`), and may
8
+ * extend its TTL (`caches.update`) or remove it (`caches.delete`). No
9
+ * instrumentor covers these endpoints, so the cached content and its lifetime
10
+ * were invisible to the telemetry.
11
+ *
12
+ * One span per lifecycle call, carrying:
13
+ * - `weflayr.cache.operation` — create / update / delete
14
+ * - `weflayr.cache.cached_content_id` — the cache's server-generated name
15
+ * - `weflayr.cache.expire_time` — absolute expiry (create / update)
16
+ * - `gen_ai.usage.input_tokens` — the cached content's token count
17
+ * (create only; billed at the standard input rate)
18
+ * - the cached content itself (`gen_ai.input.messages` /
19
+ * `gen_ai.system_instructions` / `gen_ai.tool.definitions`) — the content
20
+ * is sent only on the create call and never repeated in the calls that use
21
+ * the cache, so this is the one place it can be captured. The span
22
+ * processor strips these when message-content capture is disabled.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.instrumentCacheOperations = instrumentCacheOperations;
26
+ const api_1 = require("@opentelemetry/api");
27
+ const get_provider_name_1 = require("./get_provider_name");
28
+ const TRACER_NAME = 'weflayr.instrumentation.google.cache_operations';
29
+ const OPERATION_ATTR = 'weflayr.cache.operation';
30
+ const CACHED_CONTENT_ID_ATTR = 'weflayr.cache.cached_content_id';
31
+ const EXPIRE_TIME_ATTR = 'weflayr.cache.expire_time';
32
+ const OPERATIONS = ['create', 'update', 'delete'];
33
+ // The cached content mapped to the role+parts message shape the chat path uses.
34
+ function _contentToMessage(content) {
35
+ if (typeof content === 'string') {
36
+ return { role: 'user', parts: [{ type: 'text', content }] };
37
+ }
38
+ const role = (content && content.role) || 'user';
39
+ const rawParts = (content && content.parts) || [];
40
+ const parts = [];
41
+ for (const rawPart of rawParts) {
42
+ if (typeof rawPart === 'string') {
43
+ parts.push({ type: 'text', content: rawPart });
44
+ }
45
+ else if (rawPart && typeof rawPart.text === 'string') {
46
+ parts.push({ type: 'text', content: rawPart.text });
47
+ }
48
+ else if (rawPart && rawPart.inlineData) {
49
+ // Non-text parts (e.g. audio) become a byte-less blob stub so span
50
+ // attributes never carry raw media payloads.
51
+ parts.push({ type: 'blob', mime_type: rawPart.inlineData.mimeType || '' });
52
+ }
53
+ }
54
+ return { role, parts };
55
+ }
56
+ function _setSystemInstruction(span, systemInstruction) {
57
+ if (systemInstruction == null)
58
+ return;
59
+ const texts = typeof systemInstruction === 'string'
60
+ ? [systemInstruction]
61
+ : (systemInstruction.parts || [])
62
+ .map((part) => part && part.text)
63
+ .filter((text) => typeof text === 'string');
64
+ if (texts.length) {
65
+ span.setAttribute('gen_ai.system_instructions', JSON.stringify(texts.map((text) => ({ type: 'text', content: text }))));
66
+ }
67
+ }
68
+ function _setToolDefinitions(span, config) {
69
+ const definitions = [];
70
+ for (const tool of (config && config.tools) || []) {
71
+ for (const declaration of (tool && tool.functionDeclarations) || []) {
72
+ definitions.push(declaration);
73
+ }
74
+ }
75
+ if (definitions.length) {
76
+ span.setAttribute('gen_ai.tool.definitions', JSON.stringify(definitions));
77
+ }
78
+ }
79
+ // Stamp the server-side facts of the cache from a create/update response.
80
+ function _stampCachedContent(span, cachedContent, operation) {
81
+ if (!cachedContent)
82
+ return;
83
+ if (cachedContent.name) {
84
+ span.setAttribute(CACHED_CONTENT_ID_ATTR, String(cachedContent.name));
85
+ }
86
+ if (cachedContent.expireTime) {
87
+ span.setAttribute(EXPIRE_TIME_ATTR, String(cachedContent.expireTime));
88
+ }
89
+ // Gemini bills the cached tokens once, at creation; an update (TTL extension)
90
+ // returns the same usageMetadata but bills nothing.
91
+ if (operation !== 'create')
92
+ return;
93
+ const totalTokens = cachedContent.usageMetadata && cachedContent.usageMetadata.totalTokenCount;
94
+ if (totalTokens) {
95
+ span.setAttribute('gen_ai.usage.input_tokens', totalTokens);
96
+ }
97
+ }
98
+ function _startSpan(operation, params, system) {
99
+ const span = api_1.trace.getTracer(TRACER_NAME).startSpan(`cache_${operation}`);
100
+ span.setAttribute('gen_ai.system', system);
101
+ span.setAttribute('gen_ai.operation.name', `cache_${operation}`);
102
+ span.setAttribute(OPERATION_ATTR, operation);
103
+ if (params && params.model) {
104
+ // The chat path strips the leading "models/" prefix; mirror it.
105
+ span.setAttribute('gen_ai.request.model', params.model.replace(/^models\//, ''));
106
+ }
107
+ // update/delete address the cache by name; create gets it from the response.
108
+ if (params && params.name) {
109
+ span.setAttribute(CACHED_CONTENT_ID_ATTR, String(params.name));
110
+ }
111
+ if (operation === 'create') {
112
+ const config = (params && params.config) || {};
113
+ if (config.contents != null) {
114
+ const contentsList = Array.isArray(config.contents) ? config.contents : [config.contents];
115
+ span.setAttribute('gen_ai.input.messages', JSON.stringify(contentsList.map(_contentToMessage)));
116
+ }
117
+ _setSystemInstruction(span, config.systemInstruction);
118
+ _setToolDefinitions(span, config);
119
+ }
120
+ return span;
121
+ }
122
+ function _recordError(span, error) {
123
+ span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error?.message ?? String(error) });
124
+ span.recordException(error);
125
+ }
126
+ // Wrap `Caches.prototype.create/update/delete`, pushing the restore tuples onto
127
+ // the shared `patched` array the orchestrator owns for uninstrument().
128
+ function instrumentCacheOperations(Caches, patched) {
129
+ const owner = Caches.prototype;
130
+ for (const operation of OPERATIONS) {
131
+ const original = owner[operation];
132
+ if (typeof original !== 'function')
133
+ continue;
134
+ const wrapper = function cacheOperationWrapper(params, ...rest) {
135
+ const span = _startSpan(operation, params, (0, get_provider_name_1.getProviderName)(this));
136
+ return Promise.resolve(original.call(this, params, ...rest)).then((response) => {
137
+ try {
138
+ _stampCachedContent(span, response, operation);
139
+ }
140
+ catch {
141
+ // Never break the caller over an enrichment failure.
142
+ }
143
+ span.end();
144
+ return response;
145
+ }, (error) => {
146
+ _recordError(span, error);
147
+ span.end();
148
+ throw error;
149
+ });
150
+ };
151
+ owner[operation] = wrapper;
152
+ patched.push([owner, operation, original]);
153
+ }
154
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Context-caching enrichment for the Google GenAI (Gemini) chat span.
3
+ *
4
+ * Neither instrumentor records cached-content tokens, so we read
5
+ * `usageMetadata.cachedContentTokenCount` (explicit or implicit caching) and
6
+ * split it by modality: audio cached tokens go to
7
+ * `gen_ai.usage.input_tokens_details.cached_audio_tokens`and the remainder to `gen_ai.usage.cache_read_input_tokens`
8
+ *
9
+ * Also captures the request's explicit-cache reference: a call using explicit
10
+ * caching passes `config.cachedContent` (the `cachedContents/{id}` name of a
11
+ * cache created via `client.caches.create`), stamped as
12
+ * `weflayr.cache.cached_content_id` so the call can be joined to its cache
13
+ * lifecycle rows.
14
+ */
15
+ export declare function setCacheTelemetry(span: any, response: any): void;
16
+ export declare function setCacheConfigTelemetry(span: any, config: any): void;
@@ -1,5 +1,4 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  /**
4
3
  * Context-caching enrichment for the Google GenAI (Gemini) chat span.
5
4
  *
@@ -14,26 +13,26 @@
14
13
  * `weflayr.cache.cached_content_id` so the call can be joined to its cache
15
14
  * lifecycle rows.
16
15
  */
17
-
18
- const { _audioTokens } = require('./get_audio_telemetry');
19
-
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.setCacheTelemetry = setCacheTelemetry;
18
+ exports.setCacheConfigTelemetry = setCacheConfigTelemetry;
19
+ const get_audio_telemetry_1 = require("./get_audio_telemetry");
20
20
  const CACHED_CONTENT_ID_ATTR = 'weflayr.cache.cached_content_id';
21
-
22
21
  function setCacheTelemetry(span, response) {
23
- const usage = response && response.usageMetadata;
24
- const cachedTokens = (usage && usage.cachedContentTokenCount) || 0;
25
- if (!cachedTokens) return;
26
- const cachedAudio = _audioTokens(usage.cacheTokensDetails);
27
- if (cachedAudio)
28
- span.setAttribute('gen_ai.usage.input_tokens_details.cached_audio_tokens', cachedAudio);
29
- const cacheRead = Math.max(0, cachedTokens - cachedAudio);
30
- if (cacheRead) span.setAttribute('gen_ai.usage.cache_read_input_tokens', cacheRead);
22
+ const usage = response && response.usageMetadata;
23
+ const cachedTokens = (usage && usage.cachedContentTokenCount) || 0;
24
+ if (!cachedTokens)
25
+ return;
26
+ const cachedAudio = (0, get_audio_telemetry_1._audioTokens)(usage.cacheTokensDetails);
27
+ if (cachedAudio)
28
+ span.setAttribute('gen_ai.usage.input_tokens_details.cached_audio_tokens', cachedAudio);
29
+ const cacheRead = Math.max(0, cachedTokens - cachedAudio);
30
+ if (cacheRead)
31
+ span.setAttribute('gen_ai.usage.cache_read_input_tokens', cacheRead);
31
32
  }
32
-
33
33
  // Stamp the request's explicit-cache reference (`config.cachedContent`).
34
34
  function setCacheConfigTelemetry(span, config) {
35
- const cachedContent = config && config.cachedContent;
36
- if (cachedContent) span.setAttribute(CACHED_CONTENT_ID_ATTR, String(cachedContent));
35
+ const cachedContent = config && config.cachedContent;
36
+ if (cachedContent)
37
+ span.setAttribute(CACHED_CONTENT_ID_ATTR, String(cachedContent));
37
38
  }
38
-
39
- module.exports = { setCacheTelemetry, setCacheConfigTelemetry };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Embeddings-endpoint telemetry for Google GenAI (Gemini).
3
+ *
4
+ * `@traceloop/instrumentation-google-generativeai` wraps generate_content but not
5
+ * embeddings, so this covers it by starting its own span on the private
6
+ * `Models.prototype.embedContentInternal` (which the public `embedContent`
7
+ * delegates to). The Gemini Developer API returns NO token usage on embedContent
8
+ * (only Vertex does), so the span records the billable unit weflayr can price:
9
+ * the input character count under `gen_ai.usage.input_characters` (normalized to
10
+ * num_input_chars).
11
+ */
12
+ export declare function instrumentEmbeddings(Models: any, patched: [any, string, any][]): void;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * Embeddings-endpoint telemetry for Google GenAI (Gemini).
4
+ *
5
+ * `@traceloop/instrumentation-google-generativeai` wraps generate_content but not
6
+ * embeddings, so this covers it by starting its own span on the private
7
+ * `Models.prototype.embedContentInternal` (which the public `embedContent`
8
+ * delegates to). The Gemini Developer API returns NO token usage on embedContent
9
+ * (only Vertex does), so the span records the billable unit weflayr can price:
10
+ * the input character count under `gen_ai.usage.input_characters` (normalized to
11
+ * num_input_chars).
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.instrumentEmbeddings = instrumentEmbeddings;
15
+ const api_1 = require("@opentelemetry/api");
16
+ const get_provider_name_1 = require("./get_provider_name");
17
+ const TRACER_NAME = 'weflayr.instrumentation.google.embeddings';
18
+ const EMBEDDINGS_OPERATION = 'embeddings';
19
+ // `contents` is a string, a Content/Part object, or an array of those; the
20
+ // billable unit is the total number of characters of text across them.
21
+ function _contentCharacters(contents) {
22
+ if (contents == null)
23
+ return 0;
24
+ if (typeof contents === 'string')
25
+ return contents.length;
26
+ if (Array.isArray(contents)) {
27
+ return contents.reduce((total, item) => total + _contentCharacters(item), 0);
28
+ }
29
+ if (typeof contents === 'object') {
30
+ if (typeof contents.text === 'string')
31
+ return contents.text.length;
32
+ if (Array.isArray(contents.parts))
33
+ return _contentCharacters(contents.parts);
34
+ }
35
+ return 0;
36
+ }
37
+ // The embedded text mapped to the role+parts message shape the chat path uses:
38
+ // a string (or {text} / {parts} object) becomes one user message per content.
39
+ function _contentToMessage(content) {
40
+ if (typeof content === 'string') {
41
+ return { role: 'user', parts: [{ type: 'text', content }] };
42
+ }
43
+ if (content && typeof content.text === 'string') {
44
+ return { role: 'user', parts: [{ type: 'text', content: content.text }] };
45
+ }
46
+ return { role: 'user', parts: [] };
47
+ }
48
+ function _recordError(span, error) {
49
+ span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error?.message ?? String(error) });
50
+ span.recordException(error);
51
+ }
52
+ // Wrap `Models.prototype.embedContentInternal`, pushing the restore tuple onto
53
+ // the shared `patched` array the orchestrator owns for uninstrument().
54
+ function instrumentEmbeddings(Models, patched) {
55
+ const owner = Models.prototype;
56
+ const original = owner.embedContentInternal;
57
+ if (typeof original !== 'function')
58
+ return;
59
+ function wrapper(params, ...rest) {
60
+ const span = api_1.trace.getTracer(TRACER_NAME).startSpan(EMBEDDINGS_OPERATION);
61
+ span.setAttribute('gen_ai.system', (0, get_provider_name_1.getProviderName)(this));
62
+ span.setAttribute('gen_ai.operation.name', EMBEDDINGS_OPERATION);
63
+ if (params && params.model) {
64
+ // The chat path strips the leading "models/" prefix; mirror it.
65
+ span.setAttribute('gen_ai.request.model', params.model.replace(/^models\//, ''));
66
+ }
67
+ span.setAttribute('gen_ai.usage.input_characters', _contentCharacters(params && params.contents));
68
+ // The embedded text is the prompt; stamp it like the chat path does. The
69
+ // span processor strips it when message-content capture is disabled.
70
+ if (params && params.contents != null) {
71
+ const contentsList = Array.isArray(params.contents) ? params.contents : [params.contents];
72
+ span.setAttribute('gen_ai.input.messages', JSON.stringify(contentsList.map(_contentToMessage)));
73
+ }
74
+ return Promise.resolve(original.call(this, params, ...rest)).then((response) => {
75
+ span.end();
76
+ return response;
77
+ }, (error) => {
78
+ _recordError(span, error);
79
+ span.end();
80
+ throw error;
81
+ });
82
+ }
83
+ owner.embedContentInternal = wrapper;
84
+ patched.push([owner, 'embedContentInternal', original]);
85
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Provider-name enrichment for the Google GenAI (Gemini) chat span.
3
+ *
4
+ * `@traceloop/instrumentation-google-generativeai` hardcodes
5
+ * `gen_ai.provider.name = "gcp.gen_ai"` and can't tell Vertex from the Gemini
6
+ * Developer API. We read the client's Vertex flag and return the value to set as
7
+ * `gen_ai.system` (which the normalizer prefers): `vertex_ai` / `gemini`,
8
+ * matching what the Python google-genai instrumentor reports natively. The
9
+ * worker normalizes `vertex_ai` to the canonical `vertex`. Node-only.
10
+ */
11
+ export declare function getProviderName(instance: any): string;
@@ -1,5 +1,4 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  /**
4
3
  * Provider-name enrichment for the Google GenAI (Gemini) chat span.
5
4
  *
@@ -10,17 +9,17 @@
10
9
  * matching what the Python google-genai instrumentor reports natively. The
11
10
  * worker normalizes `vertex_ai` to the canonical `vertex`. Node-only.
12
11
  */
13
-
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getProviderName = getProviderName;
14
14
  // Read the Vertex-vs-Dev backend off the Models instance's api client.
15
15
  function getProviderName(instance) {
16
- try {
17
- if (instance && instance.apiClient && typeof instance.apiClient.isVertexAI === 'function') {
18
- return instance.apiClient.isVertexAI() ? 'vertex_ai' : 'gemini';
16
+ try {
17
+ if (instance && instance.apiClient && typeof instance.apiClient.isVertexAI === 'function') {
18
+ return instance.apiClient.isVertexAI() ? 'vertex_ai' : 'gemini';
19
+ }
19
20
  }
20
- } catch {
21
- // fall through to default
22
- }
23
- return 'gemini';
21
+ catch {
22
+ // fall through to default
23
+ }
24
+ return 'gemini';
24
25
  }
25
-
26
- module.exports = { getProviderName };
@@ -1,5 +1,3 @@
1
- 'use strict';
2
-
3
1
  /**
4
2
  * Reasoning (thinking) token enrichment for the Google GenAI (Gemini) chat span.
5
3
  *
@@ -10,12 +8,4 @@
10
8
  * `gen_ai.usage.thoughts_token_count` so the normalizer can fold them into the
11
9
  * completion count.
12
10
  */
13
-
14
- function setReasoningTelemetry(span, response) {
15
- const usage = response && response.usageMetadata;
16
- if (!usage) return;
17
- const thoughts = usage.thoughtsTokenCount || 0;
18
- if (thoughts) span.setAttribute('gen_ai.usage.thoughts_token_count', thoughts);
19
- }
20
-
21
- module.exports = { setReasoningTelemetry };
11
+ export declare function setReasoningTelemetry(span: any, response: any): void;