weflayr 0.23.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.
- package/README.md +2 -2
- package/dist/{api → src/api}/generated/facade.gen.d.ts +163 -12
- package/dist/{api → src/api}/generated/facade.gen.js +10 -2
- package/dist/src/api/generated/index.d.ts +2 -0
- package/dist/{api → src/api}/generated/index.js +9 -1
- package/dist/{api → src/api}/generated/sdk.gen.d.ts +35 -3
- package/dist/{api → src/api}/generated/sdk.gen.js +88 -4
- package/{src/api/generated/types.gen.ts → dist/src/api/generated/types.gen.d.ts} +692 -116
- package/dist/{api → src/api}/makeEndpoint.js +1 -3
- package/dist/src/auto-instrument.d.ts +42 -0
- package/dist/src/auto-instrument.js +156 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +49 -0
- package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.d.ts +20 -0
- package/dist/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +114 -0
- package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.d.ts +28 -0
- package/dist/src/instrumentation/anthropic/get_cache_config_telemetry.js +92 -0
- package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.d.ts +25 -0
- package/dist/src/instrumentation/anthropic/get_streaming_accumulation_telemetry.js +141 -0
- package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.d.ts +9 -0
- package/dist/src/instrumentation/anthropic/get_structured_output_schema_telemetry.js +17 -0
- package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.d.ts +15 -0
- package/dist/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +50 -0
- package/dist/src/instrumentation/anthropic/set_telemetry_attributes.d.ts +15 -0
- package/dist/src/instrumentation/anthropic/set_telemetry_attributes.js +39 -0
- package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.d.ts +22 -0
- package/dist/src/instrumentation/bedrock/get_cache_config_telemetry.js +97 -0
- package/dist/src/instrumentation/bedrock/get_cache_telemetry.d.ts +22 -0
- package/dist/src/instrumentation/bedrock/get_cache_telemetry.js +102 -0
- package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.d.ts +15 -0
- package/dist/src/instrumentation/bedrock/get_input_message_content_telemetry.js +91 -0
- package/dist/src/instrumentation/bedrock/get_model_id_telemetry.d.ts +21 -0
- package/dist/src/instrumentation/bedrock/get_model_id_telemetry.js +54 -0
- package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.d.ts +19 -0
- package/dist/src/instrumentation/bedrock/get_reasoning_output_telemetry.js +81 -0
- package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.d.ts +27 -0
- package/dist/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +126 -0
- package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.d.ts +17 -0
- package/dist/src/instrumentation/bedrock/get_tool_call_output_telemetry.js +85 -0
- package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.d.ts +15 -0
- package/dist/src/instrumentation/bedrock/get_tool_definitions_telemetry.js +68 -0
- package/dist/src/instrumentation/bedrock/set_telemetry_attributes.d.ts +18 -0
- package/dist/src/instrumentation/bedrock/set_telemetry_attributes.js +47 -0
- package/dist/src/instrumentation/cohere/get_chat_telemetry.d.ts +23 -0
- package/dist/src/instrumentation/cohere/get_chat_telemetry.js +77 -0
- package/dist/src/instrumentation/cohere/get_embeddings_telemetry.d.ts +18 -0
- package/dist/src/instrumentation/cohere/get_embeddings_telemetry.js +88 -0
- package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.d.ts +12 -0
- package/dist/src/instrumentation/cohere/get_structured_output_schema_telemetry.js +18 -0
- package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.d.ts +31 -0
- package/dist/src/instrumentation/cohere/get_tool_call_output_telemetry.js +106 -0
- package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.d.ts +27 -0
- package/dist/src/instrumentation/cohere/get_tool_definitions_telemetry.js +75 -0
- package/dist/src/instrumentation/cohere/set_telemetry_attributes.d.ts +17 -0
- package/dist/src/instrumentation/cohere/set_telemetry_attributes.js +44 -0
- package/dist/src/instrumentation/elevenlabs/full_instrumentation.d.ts +28 -0
- package/dist/src/instrumentation/elevenlabs/full_instrumentation.js +209 -0
- package/dist/src/instrumentation/google/get_audio_telemetry.d.ts +9 -0
- package/dist/src/instrumentation/google/get_audio_telemetry.js +28 -0
- package/dist/src/instrumentation/google/get_cache_operations_telemetry.d.ts +23 -0
- package/dist/src/instrumentation/google/get_cache_operations_telemetry.js +154 -0
- package/dist/src/instrumentation/google/get_cache_telemetry.d.ts +16 -0
- package/dist/src/instrumentation/google/get_cache_telemetry.js +38 -0
- package/dist/src/instrumentation/google/get_embeddings_telemetry.d.ts +12 -0
- package/dist/src/instrumentation/google/get_embeddings_telemetry.js +85 -0
- package/dist/src/instrumentation/google/get_provider_name.d.ts +11 -0
- package/{src → dist/src}/instrumentation/google/get_provider_name.js +11 -12
- package/{src/instrumentation/google/get_reasoning_telemetry.js → dist/src/instrumentation/google/get_reasoning_telemetry.d.ts} +1 -11
- package/dist/src/instrumentation/google/get_reasoning_telemetry.js +21 -0
- package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.d.ts +12 -0
- package/dist/src/instrumentation/google/get_structured_output_schema_telemetry.js +19 -0
- package/dist/src/instrumentation/google/set_telemetry_attributes.d.ts +18 -0
- package/dist/src/instrumentation/google/set_telemetry_attributes.js +98 -0
- package/dist/src/instrumentation/openai/get_audio_telemetry.d.ts +25 -0
- package/dist/src/instrumentation/openai/get_audio_telemetry.js +123 -0
- package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.d.ts +35 -0
- package/dist/src/instrumentation/openai/get_bedrock_mantle_telemetry.js +148 -0
- package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.d.ts +27 -0
- package/dist/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +72 -0
- package/dist/src/instrumentation/openai/get_cache_config_telemetry.d.ts +28 -0
- package/dist/src/instrumentation/openai/get_cache_config_telemetry.js +91 -0
- package/dist/src/instrumentation/openai/get_embeddings_telemetry.d.ts +18 -0
- package/dist/src/instrumentation/openai/get_embeddings_telemetry.js +86 -0
- package/dist/src/instrumentation/openai/get_streaming_usage.d.ts +21 -0
- package/dist/src/instrumentation/openai/get_streaming_usage.js +74 -0
- package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.d.ts +12 -0
- package/dist/src/instrumentation/openai/get_structured_output_schema_telemetry.js +20 -0
- package/dist/src/instrumentation/openai/set_telemetry_attributes.d.ts +17 -0
- package/dist/src/instrumentation/openai/set_telemetry_attributes.js +47 -0
- package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.d.ts +35 -0
- package/dist/src/instrumentation/shared/get_structured_output_schema_telemetry.js +76 -0
- package/dist/src/instrumentation/vercel/full_instrumentation.d.ts +3 -0
- package/dist/src/instrumentation/vercel/full_instrumentation.js +54 -0
- package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.d.ts +22 -0
- package/dist/src/instrumentation/vercel/get_cache_creation_telemetry.js +66 -0
- package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.d.ts +24 -0
- package/dist/src/instrumentation/vercel/get_structured_output_schema_telemetry.js +84 -0
- package/dist/src/logger.d.ts +1 -0
- package/dist/src/logger.js +6 -0
- package/dist/src/otel/exporter.d.ts +19 -0
- package/dist/src/otel/exporter.js +94 -0
- package/dist/src/otel/propagation.d.ts +46 -0
- package/dist/src/otel/propagation.js +110 -0
- package/dist/src/otel/span-filter.d.ts +3 -0
- package/dist/src/otel/span-filter.js +61 -0
- package/dist/src/otel/span-processor.d.ts +55 -0
- package/dist/src/otel/span-processor.js +169 -0
- package/dist/src/otel/vercel-ai-sdk-span-filter.d.ts +12 -0
- package/dist/src/otel/vercel-ai-sdk-span-filter.js +88 -0
- package/dist/src/setup.d.ts +50 -0
- package/dist/src/setup.js +155 -0
- package/package.json +11 -5
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -7
- package/LICENSE-MIT +0 -21
- package/NOTICE +0 -12
- package/dist/api/generated/index.d.ts +0 -2
- package/dist/api/generated/types.gen.d.ts +0 -749
- package/eslint.config.mjs +0 -36
- package/index.d.ts +0 -167
- package/openapi-ts.config.mjs +0 -9
- package/scripts/generate_facade.mjs +0 -86
- package/src/api/caseConversion.ts +0 -58
- package/src/api/generated/client/client.gen.ts +0 -277
- package/src/api/generated/client/index.ts +0 -27
- package/src/api/generated/client/types.gen.ts +0 -218
- package/src/api/generated/client/utils.gen.ts +0 -316
- package/src/api/generated/client.gen.ts +0 -16
- package/src/api/generated/core/auth.gen.ts +0 -48
- package/src/api/generated/core/bodySerializer.gen.ts +0 -82
- package/src/api/generated/core/params.gen.ts +0 -178
- package/src/api/generated/core/pathSerializer.gen.ts +0 -171
- package/src/api/generated/core/queryKeySerializer.gen.ts +0 -117
- package/src/api/generated/core/serverSentEvents.gen.ts +0 -242
- package/src/api/generated/core/types.gen.ts +0 -110
- package/src/api/generated/core/utils.gen.ts +0 -140
- package/src/api/generated/facade.gen.ts +0 -68
- package/src/api/generated/index.ts +0 -4
- package/src/api/generated/sdk.gen.ts +0 -121
- package/src/api/index.ts +0 -45
- package/src/api/makeEndpoint.ts +0 -54
- package/src/auto-instrument.js +0 -171
- package/src/index.js +0 -19
- package/src/instrumentation/anthropic/get_cache_and_reasoning_telemetry.js +0 -107
- package/src/instrumentation/anthropic/get_streaming_stop_reason_telemetry.js +0 -121
- package/src/instrumentation/anthropic/get_tool_definitions_telemetry.js +0 -50
- package/src/instrumentation/anthropic/set_telemetry_attributes.js +0 -37
- package/src/instrumentation/bedrock/get_cache_telemetry.js +0 -104
- package/src/instrumentation/bedrock/get_input_message_content_telemetry.js +0 -94
- package/src/instrumentation/bedrock/get_streaming_output_message_telemetry.js +0 -87
- package/src/instrumentation/bedrock/set_telemetry_attributes.js +0 -36
- package/src/instrumentation/cohere/get_chat_telemetry.js +0 -88
- package/src/instrumentation/cohere/get_embeddings_telemetry.js +0 -107
- package/src/instrumentation/cohere/set_telemetry_attributes.js +0 -32
- package/src/instrumentation/elevenlabs/full_instrumentation.js +0 -236
- package/src/instrumentation/google/get_audio_telemetry.js +0 -30
- package/src/instrumentation/google/get_cache_telemetry.js +0 -25
- package/src/instrumentation/google/get_embeddings_telemetry.js +0 -99
- package/src/instrumentation/google/set_telemetry_attributes.js +0 -98
- package/src/instrumentation/openai/get_audio_telemetry.js +0 -149
- package/src/instrumentation/openai/get_cache_and_reasoning_telemetry.js +0 -71
- package/src/instrumentation/openai/get_embeddings_telemetry.js +0 -107
- package/src/instrumentation/openai/get_streaming_usage.js +0 -81
- package/src/instrumentation/openai/set_telemetry_attributes.js +0 -39
- package/src/instrumentation/vercel/full_instrumentation.js +0 -44
- package/src/logger.js +0 -8
- package/src/otel/exporter.js +0 -108
- package/src/otel/propagation.js +0 -133
- package/src/otel/span-filter.js +0 -69
- package/src/otel/span-processor.js +0 -162
- package/src/otel/vercel-ai-sdk-span-filter.js +0 -79
- package/src/setup.js +0 -167
- package/tests/api/index.test.js +0 -437
- package/tests/index.test.js +0 -824
- package/tests/instrumentation/anthropic/get_cache_and_reasoning_telemetry.test.js +0 -158
- package/tests/instrumentation/anthropic/get_streaming_stop_reason_telemetry.test.js +0 -117
- package/tests/instrumentation/anthropic/get_tool_definitions_telemetry.test.js +0 -82
- package/tests/instrumentation/bedrock/get_cache_telemetry.test.js +0 -102
- package/tests/instrumentation/bedrock/get_input_message_content_telemetry.test.js +0 -89
- package/tests/instrumentation/bedrock/get_streaming_output_message_telemetry.test.js +0 -87
- package/tests/instrumentation/cohere/get_chat_telemetry.test.js +0 -148
- package/tests/instrumentation/cohere/get_embeddings_telemetry.test.js +0 -132
- package/tests/instrumentation/elevenlabs/full_instrumentation.test.js +0 -258
- package/tests/instrumentation/google/get_embeddings_telemetry.test.js +0 -128
- package/tests/instrumentation/google/get_reasoning_telemetry.test.js +0 -41
- package/tests/instrumentation/google/set_telemetry_attributes.test.js +0 -219
- package/tests/instrumentation/openai/get_audio_telemetry.test.js +0 -170
- package/tests/instrumentation/openai/get_cache_and_reasoning_telemetry.test.js +0 -83
- package/tests/instrumentation/openai/get_embeddings_telemetry.test.js +0 -145
- package/tests/instrumentation/openai/get_streaming_usage.test.js +0 -105
- package/tests/instrumentation/vercel/full_instrumentation.test.js +0 -16
- package/tests/otel/vercel-ai-sdk-span-filter.test.js +0 -159
- package/tsconfig.json +0 -18
- /package/dist/{api → src/api}/caseConversion.d.ts +0 -0
- /package/dist/{api → src/api}/caseConversion.js +0 -0
- /package/dist/{api → src/api}/generated/client/client.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/client/client.gen.js +0 -0
- /package/dist/{api → src/api}/generated/client/index.d.ts +0 -0
- /package/dist/{api → src/api}/generated/client/index.js +0 -0
- /package/dist/{api → src/api}/generated/client/types.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/client/types.gen.js +0 -0
- /package/dist/{api → src/api}/generated/client/utils.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/client/utils.gen.js +0 -0
- /package/dist/{api → src/api}/generated/client.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/client.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/auth.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/auth.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/bodySerializer.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/bodySerializer.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/params.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/params.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/pathSerializer.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/pathSerializer.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/queryKeySerializer.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/serverSentEvents.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/types.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/types.gen.js +0 -0
- /package/dist/{api → src/api}/generated/core/utils.gen.d.ts +0 -0
- /package/dist/{api → src/api}/generated/core/utils.gen.js +0 -0
- /package/dist/{api → src/api}/generated/types.gen.js +0 -0
- /package/dist/{api → src/api}/index.d.ts +0 -0
- /package/dist/{api → src/api}/index.js +0 -0
- /package/dist/{api → src/api}/makeEndpoint.d.ts +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2024 Langfuse GmbH
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
// Original source: https://github.com/langfuse/langfuse-js/blob/main/packages/otel/src/span-processor.ts
|
|
5
|
+
//
|
|
6
|
+
// Modifications copyright 2026 Weflayr
|
|
7
|
+
// This file has been modified from its original form:
|
|
8
|
+
// - Translated from TypeScript to JavaScript
|
|
9
|
+
// - Removed MediaService integration (no media upload support yet)
|
|
10
|
+
// - Removed LangfuseAPIClient / app-root marker logic (not used)
|
|
11
|
+
// - Removed Langfuse-specific span attributes (TRACE_INPUT/OUTPUT/METADATA, IS_APP_ROOT, ENVIRONMENT, RELEASE)
|
|
12
|
+
// - Mask hook now receives the full flat attribute bag, not a {data} envelope, and runs synchronously
|
|
13
|
+
// - default_tags are applied as span attributes in onStart
|
|
14
|
+
// - propagated tags come from Weflayr's tag bag (see propagation.js), not Langfuse's typed schema
|
|
15
|
+
//
|
|
16
|
+
// See LICENSE-MIT in the package root for the full license text.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WeflayrSpanProcessor = exports.CONTENT_CAPTURE_ENV = void 0;
|
|
19
|
+
const api_1 = require("@opentelemetry/api");
|
|
20
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
21
|
+
const propagation_1 = require("./propagation");
|
|
22
|
+
const span_filter_1 = require("./span-filter");
|
|
23
|
+
const vercel_ai_sdk_span_filter_1 = require("./vercel-ai-sdk-span-filter");
|
|
24
|
+
const logger_1 = require("../logger");
|
|
25
|
+
// setup({captureMessageContent: ...}) records the choice in this env var (the
|
|
26
|
+
// official OTel GenAI one). Instrumentors gate content on their own knobs
|
|
27
|
+
// (openllmetry reads its own config and captures by default), so the processor
|
|
28
|
+
// enforces the flag itself: when the env var is "false", message content is
|
|
29
|
+
// stripped from every span before export.
|
|
30
|
+
exports.CONTENT_CAPTURE_ENV = 'OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT';
|
|
31
|
+
// The new-semconv JSON message attributes and the legacy indexed
|
|
32
|
+
// `gen_ai.prompt.{i}.*` / `gen_ai.completion.{i}.*` attributes - plus the
|
|
33
|
+
// request's tool definitions and structured-output schema (`ai.schema` is the
|
|
34
|
+
// Vercel AI SDK's spelling): their descriptions are prompt content the same
|
|
35
|
+
// way the messages are.
|
|
36
|
+
const CONTENT_ATTRIBUTES = [
|
|
37
|
+
'gen_ai.input.messages',
|
|
38
|
+
'gen_ai.output.messages',
|
|
39
|
+
'gen_ai.system_instructions',
|
|
40
|
+
'gen_ai.tool.definitions',
|
|
41
|
+
'gen_ai.request.structured_output_schema',
|
|
42
|
+
// The legacy Vercel AI SDK's (ai <= 6) response content. finishReason and
|
|
43
|
+
// providerMetadata are NOT stripped: metadata and billing, not content.
|
|
44
|
+
'ai.schema',
|
|
45
|
+
'ai.response.text',
|
|
46
|
+
'ai.response.object',
|
|
47
|
+
'ai.response.reasoning',
|
|
48
|
+
'ai.response.toolCalls',
|
|
49
|
+
];
|
|
50
|
+
const CONTENT_ATTRIBUTE_PREFIXES = ['gen_ai.prompt.', 'gen_ai.completion.', 'ai.prompt'];
|
|
51
|
+
function _isContentAttribute(key) {
|
|
52
|
+
return (CONTENT_ATTRIBUTES.includes(key) ||
|
|
53
|
+
CONTENT_ATTRIBUTE_PREFIXES.some((prefix) => key.startsWith(prefix)));
|
|
54
|
+
}
|
|
55
|
+
// Stamped on every exported span when a `mask` is configured: the mask
|
|
56
|
+
// function's source code, so the stored raw event shows what redaction ran
|
|
57
|
+
// client-side when debugging missing attributes.
|
|
58
|
+
const MASK_FUNCTION_ATTRIBUTE = 'weflayr.mask_function';
|
|
59
|
+
class WeflayrSpanProcessor {
|
|
60
|
+
_delegate;
|
|
61
|
+
_defaultTags;
|
|
62
|
+
_mask;
|
|
63
|
+
_maskFunctionSource;
|
|
64
|
+
_shouldExportSpan;
|
|
65
|
+
_vercelAiSdkSpanFilter;
|
|
66
|
+
// LLM spans we've started but not yet seen end. On forceFlush we end any
|
|
67
|
+
// leftovers with ERROR status — covers cases like openllmetry's anthropic
|
|
68
|
+
// streaming wrapper, which leaks the span when the underlying call
|
|
69
|
+
// rejects. Generic across providers; no per-provider patching needed.
|
|
70
|
+
_openLlmSpans;
|
|
71
|
+
constructor({ exporter, exportMode = 'batch', defaultTags = {}, mask, shouldExportSpan, }) {
|
|
72
|
+
if (!exporter) {
|
|
73
|
+
throw new Error('WeflayrSpanProcessor: exporter is required');
|
|
74
|
+
}
|
|
75
|
+
this._delegate =
|
|
76
|
+
exportMode === 'immediate'
|
|
77
|
+
? new sdk_trace_base_1.SimpleSpanProcessor(exporter)
|
|
78
|
+
: new sdk_trace_base_1.BatchSpanProcessor(exporter);
|
|
79
|
+
this._defaultTags = defaultTags;
|
|
80
|
+
this._mask = mask;
|
|
81
|
+
this._maskFunctionSource = mask ? String(mask) : null;
|
|
82
|
+
this._shouldExportSpan = shouldExportSpan ?? span_filter_1.isDefaultExportSpan;
|
|
83
|
+
this._vercelAiSdkSpanFilter = new vercel_ai_sdk_span_filter_1.VercelAiSdkSpanFilter();
|
|
84
|
+
this._openLlmSpans = new Set();
|
|
85
|
+
}
|
|
86
|
+
onStart(span, parentContext) {
|
|
87
|
+
for (const [k, v] of Object.entries(this._defaultTags)) {
|
|
88
|
+
span.setAttribute(`${propagation_1.EXTRA_TAG_PREFIX}${k}`, v);
|
|
89
|
+
}
|
|
90
|
+
const propagated = (0, propagation_1.getMergedMetadataFromContext)(parentContext);
|
|
91
|
+
for (const [k, v] of Object.entries(propagated)) {
|
|
92
|
+
span.setAttribute(k, v);
|
|
93
|
+
}
|
|
94
|
+
if ((0, span_filter_1.isKnownLLMInstrumentor)(span)) {
|
|
95
|
+
this._openLlmSpans.add(span);
|
|
96
|
+
}
|
|
97
|
+
this._vercelAiSdkSpanFilter.onStart(span);
|
|
98
|
+
(0, logger_1.debug)('span start: name=%s defaultTags=%d propagatedMetadata=%d', span.name, Object.keys(this._defaultTags).length, Object.keys(propagated).length);
|
|
99
|
+
return this._delegate.onStart(span, parentContext);
|
|
100
|
+
}
|
|
101
|
+
onEnd(span) {
|
|
102
|
+
// Same concrete object stored in onStart, viewed here as a ReadableSpan.
|
|
103
|
+
this._openLlmSpans.delete(span);
|
|
104
|
+
try {
|
|
105
|
+
const vercelVerdict = this._vercelAiSdkSpanFilter.shouldExport(span);
|
|
106
|
+
if (vercelVerdict === true) {
|
|
107
|
+
(0, vercel_ai_sdk_span_filter_1.stampVercelGatewayProviderName)(span);
|
|
108
|
+
}
|
|
109
|
+
if (vercelVerdict === false || (vercelVerdict === null && !this._shouldExportSpan(span))) {
|
|
110
|
+
(0, logger_1.debug)('span end: filtered out name=%s scope=%s', span.name, span.instrumentationScope?.name);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
(0, logger_1.debug)('span end: exporting name=%s scope=%s', span.name, span.instrumentationScope?.name);
|
|
118
|
+
if ((process.env[exports.CONTENT_CAPTURE_ENV] || '').toLowerCase() === 'false') {
|
|
119
|
+
for (const key of Object.keys(span.attributes)) {
|
|
120
|
+
if (_isContentAttribute(key))
|
|
121
|
+
delete span.attributes[key];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (this._mask) {
|
|
125
|
+
try {
|
|
126
|
+
const masked = this._mask(span.attributes);
|
|
127
|
+
if (masked && masked !== span.attributes) {
|
|
128
|
+
for (const k of Object.keys(span.attributes))
|
|
129
|
+
delete span.attributes[k];
|
|
130
|
+
Object.assign(span.attributes, masked);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
for (const k of Object.keys(span.attributes))
|
|
135
|
+
delete span.attributes[k];
|
|
136
|
+
}
|
|
137
|
+
// Stamped after masking so the mask can't strip it.
|
|
138
|
+
span.attributes[MASK_FUNCTION_ATTRIBUTE] = this._maskFunctionSource;
|
|
139
|
+
}
|
|
140
|
+
return this._delegate.onEnd(span);
|
|
141
|
+
}
|
|
142
|
+
async forceFlush() {
|
|
143
|
+
this._endOrphanedLlmSpans();
|
|
144
|
+
return this._delegate.forceFlush();
|
|
145
|
+
}
|
|
146
|
+
_endOrphanedLlmSpans() {
|
|
147
|
+
const orphans = [...this._openLlmSpans];
|
|
148
|
+
this._openLlmSpans.clear();
|
|
149
|
+
for (const span of orphans) {
|
|
150
|
+
try {
|
|
151
|
+
if (typeof span.isRecording === 'function' && !span.isRecording())
|
|
152
|
+
continue;
|
|
153
|
+
span.setStatus({
|
|
154
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
155
|
+
message: 'weflayr: span did not complete before flush',
|
|
156
|
+
});
|
|
157
|
+
span.end();
|
|
158
|
+
(0, logger_1.debug)('forceFlush: ended orphaned LLM span name=%s', span.name);
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
(0, logger_1.debug)('forceFlush: failed to end orphan span: %s', err?.message || err);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
shutdown() {
|
|
166
|
+
return this._delegate.shutdown();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.WeflayrSpanProcessor = WeflayrSpanProcessor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
export declare class VercelAiSdkSpanFilter {
|
|
3
|
+
private _openSpanOperations;
|
|
4
|
+
private _openLegacySchemas;
|
|
5
|
+
onStart(span: ReadableSpan): void;
|
|
6
|
+
/**
|
|
7
|
+
* Export verdict for a Vercel AI SDK span, or null when the span is not
|
|
8
|
+
* one (the caller falls back to the default filter).
|
|
9
|
+
*/
|
|
10
|
+
shouldExport(span: ReadableSpan): boolean | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function stampVercelGatewayProviderName(span: ReadableSpan): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The Vercel AI SDK's OTel integrations emit aggregate spans around each model
|
|
3
|
+
// call, all repeating the same usage counts:
|
|
4
|
+
// - `@ai-sdk/otel` (ai >= 7, scope "gen_ai"): per-call "chat" spans are
|
|
5
|
+
// wrapped in "agent_step" + "invoke_agent" spans, and embed/embedMany
|
|
6
|
+
// emits an outer "embeddings" operation span around the model-call
|
|
7
|
+
// "embeddings" span(s).
|
|
8
|
+
// - the legacy integration (ai <= 6, scope "ai"): `ai.<fn>.do<Call>` spans
|
|
9
|
+
// are wrapped in an outer `ai.<fn>` span.
|
|
10
|
+
// Exactly one span per model call may reach the exporter — exporting an
|
|
11
|
+
// aggregate alongside its children would bill every call twice.
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.VercelAiSdkSpanFilter = void 0;
|
|
14
|
+
exports.stampVercelGatewayProviderName = stampVercelGatewayProviderName;
|
|
15
|
+
const VERCEL_SEMCONV_SCOPE = 'gen_ai';
|
|
16
|
+
const VERCEL_LEGACY_SCOPE = 'ai';
|
|
17
|
+
const LEGACY_MODEL_CALL_SPAN_NAME = /\.do(Generate|Stream|Embed)$/;
|
|
18
|
+
function _parentSpanId(span) {
|
|
19
|
+
return span.parentSpanContext?.spanId ?? span.parentSpanId;
|
|
20
|
+
}
|
|
21
|
+
class VercelAiSdkSpanFilter {
|
|
22
|
+
// spanId -> gen_ai.operation.name for open "gen_ai"-scope spans, so a
|
|
23
|
+
// span can check what its parent is (children end before their parent).
|
|
24
|
+
_openSpanOperations = new Map();
|
|
25
|
+
// spanId -> ai.schema of open legacy generateObject/streamObject ROOT spans:
|
|
26
|
+
// ai <= 6 records the schema only there, and this filter drops the root, so
|
|
27
|
+
// the schema is copied onto the model-call child when it starts (the root's
|
|
28
|
+
// creation attributes are already set by then).
|
|
29
|
+
_openLegacySchemas = new Map();
|
|
30
|
+
onStart(span) {
|
|
31
|
+
const scope = span.instrumentationScope?.name;
|
|
32
|
+
if (scope === VERCEL_LEGACY_SCOPE) {
|
|
33
|
+
const schema = span.attributes['ai.schema'];
|
|
34
|
+
if (schema !== undefined && !LEGACY_MODEL_CALL_SPAN_NAME.test(span.name)) {
|
|
35
|
+
this._openLegacySchemas.set(span.spanContext().spanId, schema);
|
|
36
|
+
}
|
|
37
|
+
const parentSpanId = _parentSpanId(span);
|
|
38
|
+
if (parentSpanId &&
|
|
39
|
+
span.attributes['ai.schema'] === undefined &&
|
|
40
|
+
this._openLegacySchemas.has(parentSpanId)) {
|
|
41
|
+
span.attributes['ai.schema'] = this._openLegacySchemas.get(parentSpanId);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (scope !== VERCEL_SEMCONV_SCOPE)
|
|
46
|
+
return;
|
|
47
|
+
this._openSpanOperations.set(span.spanContext().spanId, span.attributes['gen_ai.operation.name']);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Export verdict for a Vercel AI SDK span, or null when the span is not
|
|
51
|
+
* one (the caller falls back to the default filter).
|
|
52
|
+
*/
|
|
53
|
+
shouldExport(span) {
|
|
54
|
+
const scope = span.instrumentationScope?.name;
|
|
55
|
+
if (scope === VERCEL_LEGACY_SCOPE) {
|
|
56
|
+
this._openLegacySchemas.delete(span.spanContext().spanId);
|
|
57
|
+
return LEGACY_MODEL_CALL_SPAN_NAME.test(span.name);
|
|
58
|
+
}
|
|
59
|
+
if (scope !== VERCEL_SEMCONV_SCOPE) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const operation = span.attributes['gen_ai.operation.name'];
|
|
63
|
+
this._openSpanOperations.delete(span.spanContext().spanId);
|
|
64
|
+
if (operation === 'chat') {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (operation === 'embeddings') {
|
|
68
|
+
// Keep the outer aggregate (one event per embed/embedMany call, with the
|
|
69
|
+
// total usage) and drop the nested model-call span(s) repeating it.
|
|
70
|
+
const parentSpanId = _parentSpanId(span);
|
|
71
|
+
return (parentSpanId && this._openSpanOperations.get(parentSpanId)) !== 'embeddings';
|
|
72
|
+
}
|
|
73
|
+
// invoke_agent / agent_step (usage aggregates) and execute_tool (no usage).
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.VercelAiSdkSpanFilter = VercelAiSdkSpanFilter;
|
|
78
|
+
// `@ai-sdk/otel` reports the Vercel AI Gateway as the bare provider id
|
|
79
|
+
// "gateway" — too generic a name to special-case downstream. Stamp the weflayr
|
|
80
|
+
// provider override (which the normalizer prefers) with the canonical name.
|
|
81
|
+
// A providerNameOverride set through propagateMetadata was stamped at span start and
|
|
82
|
+
// wins.
|
|
83
|
+
function stampVercelGatewayProviderName(span) {
|
|
84
|
+
if (span.attributes['gen_ai.provider.name'] === 'gateway' &&
|
|
85
|
+
span.attributes['weflayr.provider_name'] === undefined) {
|
|
86
|
+
span.attributes['weflayr.provider_name'] = 'vercel_ai_gateway';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
import { WeflayrSpanProcessor, type OtelSpanAttributes, type Tags } from './otel/span-processor';
|
|
3
|
+
export interface SetupOptions {
|
|
4
|
+
/** Weflayr API key. Defaults to the `WEFLAYR_API_KEY` environment variable. */
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
/** Override the intake base URL. Defaults to WEFLAYR_BASE_URL or https://api.weflayr.com. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Tags applied to every emitted span. */
|
|
9
|
+
defaultTags?: Tags;
|
|
10
|
+
/**
|
|
11
|
+
* `'batch'` (default) groups spans for throughput. `'immediate'` flushes every
|
|
12
|
+
* span synchronously — recommended for short-lived runtimes (Lambda, edge).
|
|
13
|
+
*/
|
|
14
|
+
exportMode?: 'batch' | 'immediate';
|
|
15
|
+
/**
|
|
16
|
+
* When `false`, sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=false
|
|
17
|
+
* so instrumentations strip `gen_ai.prompt` / `gen_ai.completion` from spans
|
|
18
|
+
* before they're emitted. Defaults to `true`.
|
|
19
|
+
*/
|
|
20
|
+
captureMessageContent?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Last-line-of-defense scrubber. Receives the span attribute bag just before
|
|
23
|
+
* export; return the (optionally mutated) bag.
|
|
24
|
+
*/
|
|
25
|
+
mask?: (attrs: OtelSpanAttributes) => OtelSpanAttributes;
|
|
26
|
+
/** Whether the exporter logs a warning to stderr on every failed export. Defaults to `true`. */
|
|
27
|
+
warnOnExportError?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface State {
|
|
30
|
+
tracerProvider: TracerProvider | null;
|
|
31
|
+
processor: WeflayrSpanProcessor | null;
|
|
32
|
+
beforeExitListener: (() => Promise<void>) | null;
|
|
33
|
+
}
|
|
34
|
+
export declare const _state: State;
|
|
35
|
+
/**
|
|
36
|
+
* Configure the Weflayr SDK.
|
|
37
|
+
*
|
|
38
|
+
* Call once per process, before `autoInstrument`. For per-request or
|
|
39
|
+
* per-tenant data in a long-running server use `propagateMetadata(...)` —
|
|
40
|
+
* it stores metadata in OTel's `Context` (built on AsyncLocalStorage) and
|
|
41
|
+
* isolates correctly across concurrent requests.
|
|
42
|
+
*
|
|
43
|
+
* Calling `setup` again is supported but replaces the previous
|
|
44
|
+
* configuration: the prior processor is shut down and detached so we never
|
|
45
|
+
* stack exporters (which would otherwise double-export every span and leak
|
|
46
|
+
* HTTP pools).
|
|
47
|
+
*/
|
|
48
|
+
export declare function setup(options: SetupOptions): void;
|
|
49
|
+
export declare function flush(): Promise<void>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._state = void 0;
|
|
4
|
+
exports.setup = setup;
|
|
5
|
+
exports.flush = flush;
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
8
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
9
|
+
const exporter_1 = require("./otel/exporter");
|
|
10
|
+
const span_processor_1 = require("./otel/span-processor");
|
|
11
|
+
const logger_1 = require("./logger");
|
|
12
|
+
const package_json_1 = require("../package.json");
|
|
13
|
+
const SDK_LANGUAGE = 'javascript';
|
|
14
|
+
const DEFAULT_BASE_URL = 'https://api.weflayr.com';
|
|
15
|
+
exports._state = {
|
|
16
|
+
tracerProvider: null,
|
|
17
|
+
processor: null,
|
|
18
|
+
beforeExitListener: null,
|
|
19
|
+
};
|
|
20
|
+
// `trace.getTracerProvider()` returns a ProxyTracerProvider that forwards to
|
|
21
|
+
// whoever called `.register()` last. Unwrap it to reach the real provider.
|
|
22
|
+
// The delegate/registration internals aren't part of the public TracerProvider
|
|
23
|
+
// type, so this reaches into them dynamically.
|
|
24
|
+
function _unwrapTracerProvider(p) {
|
|
25
|
+
const maybeProxy = p;
|
|
26
|
+
if (maybeProxy && typeof maybeProxy.getDelegate === 'function') {
|
|
27
|
+
return maybeProxy.getDelegate();
|
|
28
|
+
}
|
|
29
|
+
return p;
|
|
30
|
+
}
|
|
31
|
+
// `NodeTracerProvider` 2.x dropped the public `addSpanProcessor` API —
|
|
32
|
+
// processors are construction-time only. To attach to a provider somebody
|
|
33
|
+
// else owns, we splice into the internal MultiSpanProcessor. This matches
|
|
34
|
+
// the actual public OTel JS guidance for composing post-construction.
|
|
35
|
+
function _attachProcessorToExistingProvider(provider, processor) {
|
|
36
|
+
if (!provider)
|
|
37
|
+
return false;
|
|
38
|
+
const internals = provider;
|
|
39
|
+
if (typeof internals.addSpanProcessor === 'function') {
|
|
40
|
+
internals.addSpanProcessor(processor);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const multi = internals._activeSpanProcessor;
|
|
44
|
+
if (multi && Array.isArray(multi._spanProcessors)) {
|
|
45
|
+
multi._spanProcessors.push(processor);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configure the Weflayr SDK.
|
|
52
|
+
*
|
|
53
|
+
* Call once per process, before `autoInstrument`. For per-request or
|
|
54
|
+
* per-tenant data in a long-running server use `propagateMetadata(...)` —
|
|
55
|
+
* it stores metadata in OTel's `Context` (built on AsyncLocalStorage) and
|
|
56
|
+
* isolates correctly across concurrent requests.
|
|
57
|
+
*
|
|
58
|
+
* Calling `setup` again is supported but replaces the previous
|
|
59
|
+
* configuration: the prior processor is shut down and detached so we never
|
|
60
|
+
* stack exporters (which would otherwise double-export every span and leak
|
|
61
|
+
* HTTP pools).
|
|
62
|
+
*/
|
|
63
|
+
function setup(options) {
|
|
64
|
+
const opts = options || {};
|
|
65
|
+
const apiKey = opts.apiKey || process.env.WEFLAYR_API_KEY;
|
|
66
|
+
if (typeof apiKey !== 'string' || !apiKey) {
|
|
67
|
+
throw new Error('weflayr.setup: `apiKey` is required (pass it explicitly or set WEFLAYR_API_KEY)');
|
|
68
|
+
}
|
|
69
|
+
const resolvedOptions = { ...opts, apiKey };
|
|
70
|
+
if (resolvedOptions.captureMessageContent === false) {
|
|
71
|
+
process.env[span_processor_1.CONTENT_CAPTURE_ENV] = 'false';
|
|
72
|
+
}
|
|
73
|
+
else if (resolvedOptions.captureMessageContent === true) {
|
|
74
|
+
process.env[span_processor_1.CONTENT_CAPTURE_ENV] = 'true';
|
|
75
|
+
}
|
|
76
|
+
_detachPreviousWeflayrProcessor();
|
|
77
|
+
const baseUrl = resolvedOptions.baseUrl || process.env.WEFLAYR_BASE_URL || DEFAULT_BASE_URL;
|
|
78
|
+
const exporter = (0, exporter_1.buildExporter)({
|
|
79
|
+
baseUrl,
|
|
80
|
+
apiKey: resolvedOptions.apiKey,
|
|
81
|
+
warnOnExportError: resolvedOptions.warnOnExportError !== false,
|
|
82
|
+
});
|
|
83
|
+
const processor = new span_processor_1.WeflayrSpanProcessor({
|
|
84
|
+
exporter,
|
|
85
|
+
exportMode: resolvedOptions.exportMode || 'batch',
|
|
86
|
+
defaultTags: resolvedOptions.defaultTags || {},
|
|
87
|
+
mask: resolvedOptions.mask,
|
|
88
|
+
});
|
|
89
|
+
// Adopt an existing TracerProvider when there is one — e.g. the user already
|
|
90
|
+
// configured Datadog/Honeycomb/OTel, or called weflayr.setup() before.
|
|
91
|
+
// provider.register() silently refuses to override the proxy if another
|
|
92
|
+
// provider is already wired in, so naively creating a new provider would
|
|
93
|
+
// leave our processor attached to a dead one and we'd drop every LLM span.
|
|
94
|
+
const currentTracerProvider = _unwrapTracerProvider(api_1.trace.getTracerProvider());
|
|
95
|
+
let tracerProvider;
|
|
96
|
+
if (_attachProcessorToExistingProvider(currentTracerProvider, processor)) {
|
|
97
|
+
tracerProvider = currentTracerProvider;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const nodeTracerProvider = new sdk_trace_node_1.NodeTracerProvider({
|
|
101
|
+
resource: (0, resources_1.resourceFromAttributes)({
|
|
102
|
+
sdk_version: package_json_1.version,
|
|
103
|
+
sdk_language: SDK_LANGUAGE,
|
|
104
|
+
}),
|
|
105
|
+
spanProcessors: [processor],
|
|
106
|
+
});
|
|
107
|
+
nodeTracerProvider.register();
|
|
108
|
+
tracerProvider = nodeTracerProvider;
|
|
109
|
+
}
|
|
110
|
+
// beforeExit fires when the event loop empties on a clean exit, giving us a
|
|
111
|
+
// last async tick to drain buffered spans. It does NOT fire on process.exit()
|
|
112
|
+
// or uncaught fatals — callers handling those paths still need to call flush
|
|
113
|
+
// explicitly (e.g. in a finally) for the OTLP HTTP request to complete.
|
|
114
|
+
if (!exports._state.beforeExitListener) {
|
|
115
|
+
exports._state.beforeExitListener = async () => {
|
|
116
|
+
try {
|
|
117
|
+
await flush();
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// best-effort: process is already winding down.
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
process.on('beforeExit', exports._state.beforeExitListener);
|
|
124
|
+
}
|
|
125
|
+
exports._state.tracerProvider = tracerProvider;
|
|
126
|
+
exports._state.processor = processor;
|
|
127
|
+
(0, logger_1.debug)('setup ready: baseUrl=%s exportMode=%s defaultTags=%d', baseUrl, resolvedOptions.exportMode || 'batch', Object.keys(resolvedOptions.defaultTags || {}).length);
|
|
128
|
+
}
|
|
129
|
+
async function flush() {
|
|
130
|
+
if (!exports._state.processor)
|
|
131
|
+
return;
|
|
132
|
+
(0, logger_1.debug)('flush: forcing exporter flush');
|
|
133
|
+
await exports._state.processor.forceFlush();
|
|
134
|
+
}
|
|
135
|
+
// Shut down + detach the prior weflayr processor — idempotency for setup().
|
|
136
|
+
// Without this, calling setup() twice (key rotation, hot reload, tests that
|
|
137
|
+
// reconfigure) would leave the first processor wired in alongside the new
|
|
138
|
+
// one, double-exporting every span and leaking exporter HTTP pools.
|
|
139
|
+
function _detachPreviousWeflayrProcessor() {
|
|
140
|
+
const previousProcessor = exports._state.processor;
|
|
141
|
+
if (!previousProcessor)
|
|
142
|
+
return;
|
|
143
|
+
const tp = exports._state.tracerProvider;
|
|
144
|
+
const multi = tp && tp._activeSpanProcessor;
|
|
145
|
+
if (multi && Array.isArray(multi._spanProcessors)) {
|
|
146
|
+
multi._spanProcessors = multi._spanProcessors.filter((processor) => processor !== previousProcessor);
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
previousProcessor.shutdown();
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// best-effort cleanup.
|
|
153
|
+
}
|
|
154
|
+
exports._state.processor = null;
|
|
155
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weflayr",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Weflayr
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
3
|
+
"version": "0.26.0",
|
|
4
|
+
"description": "Weflayr JS/TS SDK — instrument any LLM client",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/src"
|
|
9
|
+
],
|
|
7
10
|
"scripts": {
|
|
8
11
|
"build": "tsc",
|
|
9
12
|
"generate-api": "openapi-ts && node scripts/generate_facade.mjs",
|
|
@@ -36,9 +39,12 @@
|
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@hey-api/openapi-ts": "^0.99.0",
|
|
42
|
+
"@opentelemetry/context-async-hooks": "^2.8.0",
|
|
43
|
+
"@types/async-retry": "^1.4.9",
|
|
39
44
|
"@types/node": "^26.1.1",
|
|
40
45
|
"eslint": "^9.18.0",
|
|
41
46
|
"prettier": "^3.4.2",
|
|
42
|
-
"typescript": "^6.0.3"
|
|
47
|
+
"typescript": "^6.0.3",
|
|
48
|
+
"typescript-eslint": "^8.65.0"
|
|
43
49
|
}
|
|
44
50
|
}
|
package/.prettierignore
DELETED
package/.prettierrc.json
DELETED
package/LICENSE-MIT
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Langfuse GmbH
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/NOTICE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Weflayr Node.js SDK
|
|
2
|
-
Copyright 2026 Weflayr
|
|
3
|
-
|
|
4
|
-
This product includes software derived from langfuse-js
|
|
5
|
-
(https://github.com/langfuse/langfuse-js), Copyright 2024 Langfuse GmbH,
|
|
6
|
-
licensed under the MIT License.
|
|
7
|
-
|
|
8
|
-
Specifically, the OpenTelemetry span filter, span processor, and tag-propagation
|
|
9
|
-
helpers in src/otel/ are derived from langfuse-js packages/otel and packages/core
|
|
10
|
-
and have been adapted for the Weflayr intake API and tag schema.
|
|
11
|
-
|
|
12
|
-
See LICENSE-MIT for the full MIT license text.
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { deleteCustomersTags, deleteKeyMetrics, deleteRevenue, getCustomersTags, getKeyMetrics, getMargin, getRevenue, type Options, setCustomersTags, setKeyMetrics, setRevenue } from './sdk.gen.js';
|
|
2
|
-
export type { AllCustomerTagsOutput, ApiErrorOutput, ClientOptions, CustomerMarginRow, CustomersUpdatedOutput, CustomerTags, CustomerTagsOutput, DeleteCustomersTagsData, DeleteCustomersTagsError, DeleteCustomersTagsErrors, DeleteCustomersTagsResponse, DeleteCustomersTagsResponses, DeleteKeyMetricsData, DeleteKeyMetricsError, DeleteKeyMetricsErrors, DeleteKeyMetricsResponse, DeleteKeyMetricsResponses, DeleteRevenueData, DeleteRevenueError, DeleteRevenueErrors, DeleteRevenueResponse, DeleteRevenueResponses, GetCustomersTagsData, GetCustomersTagsError, GetCustomersTagsErrors, GetCustomersTagsResponse, GetCustomersTagsResponses, GetKeyMetricsData, GetKeyMetricsError, GetKeyMetricsErrors, GetKeyMetricsResponse, GetKeyMetricsResponses, GetMarginData, GetMarginError, GetMarginErrors, GetMarginResponse, GetMarginResponses, GetRevenueData, GetRevenueError, GetRevenueErrors, GetRevenueResponse, GetRevenueResponses, InvalidFieldDetail, InvalidPayloadOutput, KeyMetricOutput, KeyMetricRow, KeyMetricRowOutput, MarginListOutput, RevenueOrKeyMetricDeletedRowOutput, RevenueOrKeyMetricImportedRowOutput, RevenueOutput, RevenueRow, RevenueRowOutput, SetCustomersTagsData, SetCustomersTagsError, SetCustomersTagsErrors, SetCustomersTagsResponse, SetCustomersTagsResponses, SetCustomerTagsInput, SetKeyMetricsData, SetKeyMetricsError, SetKeyMetricsErrors, SetKeyMetricsInput, SetKeyMetricsResponse, SetKeyMetricsResponses, SetRevenueData, SetRevenueError, SetRevenueErrors, SetRevenueInput, SetRevenueResponse, SetRevenueResponses, TagsDeletedOutput } from './types.gen.js';
|