langwatch 1.18.0 → 1.20.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 +25 -11
- package/dist/agent/index.d.mts +122 -79
- package/dist/agent/index.d.ts +122 -79
- package/dist/agent/index.js +523 -300
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +522 -301
- package/dist/agent/index.mjs.map +1 -1
- package/dist/chunk-5VYEG3RS.js +117 -0
- package/dist/chunk-5VYEG3RS.js.map +1 -0
- package/dist/{chunk-O4J3ZPZY.js → chunk-5ZNEXSAB.js} +7912 -2564
- package/dist/chunk-5ZNEXSAB.js.map +1 -0
- package/dist/chunk-BDQ2RG7R.mjs +852 -0
- package/dist/chunk-BDQ2RG7R.mjs.map +1 -0
- package/dist/chunk-BL3GHEKF.js +59 -0
- package/dist/chunk-BL3GHEKF.js.map +1 -0
- package/dist/chunk-C7IWJ2GJ.mjs +59 -0
- package/dist/chunk-C7IWJ2GJ.mjs.map +1 -0
- package/dist/chunk-EQ5CFQGJ.js +852 -0
- package/dist/chunk-EQ5CFQGJ.js.map +1 -0
- package/dist/{chunk-NPEK4RSD.mjs → chunk-ET5KYCG2.mjs} +7757 -2409
- package/dist/chunk-ET5KYCG2.mjs.map +1 -0
- package/dist/{chunk-MVQJMRM6.mjs → chunk-FKYYEGJ7.mjs} +120 -112
- package/dist/chunk-FKYYEGJ7.mjs.map +1 -0
- package/dist/{chunk-JJASOJOK.js → chunk-HCK7TCSK.js} +138 -130
- package/dist/chunk-HCK7TCSK.js.map +1 -0
- package/dist/{chunk-LCG5Y2EG.js → chunk-N76BG37W.js} +15 -101
- package/dist/chunk-N76BG37W.js.map +1 -0
- package/dist/chunk-SERULD4Z.mjs +117 -0
- package/dist/chunk-SERULD4Z.mjs.map +1 -0
- package/dist/{chunk-73QOHSHU.js → chunk-WDUUAIG3.js} +2 -2
- package/dist/chunk-WDUUAIG3.js.map +1 -0
- package/dist/{chunk-WMDQVWA6.mjs → chunk-WSGVZ3J2.mjs} +22 -108
- package/dist/chunk-WSGVZ3J2.mjs.map +1 -0
- package/dist/{chunk-57L2K66L.mjs → chunk-XQ4CP2JK.mjs} +2 -2
- package/dist/chunk-XQ4CP2JK.mjs.map +1 -0
- package/dist/cli/bundle.js +766 -479
- package/dist/implementation-B4Z2ksnA.d.mts +261 -0
- package/dist/implementation-BFUgzz5C.d.ts +261 -0
- package/dist/index.d.mts +398 -1123
- package/dist/index.d.ts +398 -1123
- package/dist/index.js +7613 -3566
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7419 -3372
- package/dist/index.mjs.map +1 -1
- package/dist/observability-sdk/index.d.mts +16 -76
- package/dist/observability-sdk/index.d.ts +16 -76
- package/dist/observability-sdk/index.js +8 -5
- package/dist/observability-sdk/index.js.map +1 -1
- package/dist/observability-sdk/index.mjs +8 -5
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +3 -5
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +3 -5
- package/dist/observability-sdk/instrumentation/langchain/index.js +160 -112
- package/dist/observability-sdk/instrumentation/langchain/index.js.map +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +148 -100
- package/dist/observability-sdk/instrumentation/langchain/index.mjs.map +1 -1
- package/dist/observability-sdk/semconv/index.d.mts +37 -0
- package/dist/observability-sdk/semconv/index.d.ts +37 -0
- package/dist/observability-sdk/semconv/index.js +121 -0
- package/dist/observability-sdk/semconv/index.js.map +1 -0
- package/dist/observability-sdk/semconv/index.mjs +121 -0
- package/dist/observability-sdk/semconv/index.mjs.map +1 -0
- package/dist/observability-sdk/setup/node/index.d.mts +73 -313
- package/dist/observability-sdk/setup/node/index.d.ts +73 -313
- package/dist/observability-sdk/setup/node/index.js +6 -4
- package/dist/observability-sdk/setup/node/index.js.map +1 -1
- package/dist/observability-sdk/setup/node/index.mjs +5 -3
- package/dist/types-B696jWYQ.d.mts +16010 -0
- package/dist/types-Bo6OvFct.d.ts +16010 -0
- package/dist/{types-VOZv9LYO.d.mts → types-CoS5PmeU.d.mts} +22 -59
- package/dist/{types-VOZv9LYO.d.ts → types-CoS5PmeU.d.ts} +22 -59
- package/dist/{types-DLfhJb38.d.mts → types-RkiBQZ9j.d.mts} +1 -6
- package/dist/{types-DLfhJb38.d.ts → types-RkiBQZ9j.d.ts} +1 -6
- package/dist/values-1yj9l0Sa.d.mts +112 -0
- package/dist/values-1yj9l0Sa.d.ts +112 -0
- package/package.json +95 -64
- package/dist/chunk-57L2K66L.mjs.map +0 -1
- package/dist/chunk-73QOHSHU.js.map +0 -1
- package/dist/chunk-HY2N6TO5.mjs +0 -566
- package/dist/chunk-HY2N6TO5.mjs.map +0 -1
- package/dist/chunk-JJASOJOK.js.map +0 -1
- package/dist/chunk-LCG5Y2EG.js.map +0 -1
- package/dist/chunk-MVQJMRM6.mjs.map +0 -1
- package/dist/chunk-NPEK4RSD.mjs.map +0 -1
- package/dist/chunk-O4J3ZPZY.js.map +0 -1
- package/dist/chunk-UEJSGC3P.js +0 -566
- package/dist/chunk-UEJSGC3P.js.map +0 -1
- package/dist/chunk-WMDQVWA6.mjs.map +0 -1
- package/dist/implementation-BvX-7vox.d.ts +0 -716
- package/dist/implementation-CQ__V0Vc.d.mts +0 -716
- package/dist/types-CNEUr6Hm.d.ts +0 -36682
- package/dist/types-DfPAHmAh.d.mts +0 -36682
|
@@ -1,231 +1,112 @@
|
|
|
1
|
-
import { L as Logger } from '../../../index-D7rKIGrO.js';
|
|
2
|
-
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { SpanExporter, SpanProcessor, SpanLimits, Sampler, IdGenerator } from '@opentelemetry/sdk-trace-base';
|
|
4
1
|
import { TracerProvider, ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
+
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { ResourceDetector, Resource } from '@opentelemetry/resources';
|
|
5
4
|
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
6
5
|
import { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { c as DataCaptureOptions } from '../../../types-
|
|
6
|
+
import { SpanExporter, SpanProcessor, SpanLimits, Sampler, IdGenerator } from '@opentelemetry/sdk-trace-base';
|
|
7
|
+
import { L as Logger } from '../../../index-D7rKIGrO.js';
|
|
8
|
+
import { c as DataCaptureOptions } from '../../../types-RkiBQZ9j.js';
|
|
9
|
+
import { a as SemConvAttributes } from '../../../types-CoS5PmeU.js';
|
|
10
10
|
import '@opentelemetry/api-logs';
|
|
11
|
-
import '@opentelemetry/semantic-conventions';
|
|
12
|
-
import '@opentelemetry/semantic-conventions/incubating';
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Configuration options for setting up LangWatch observability.
|
|
16
|
-
*
|
|
17
|
-
* This interface provides comprehensive configuration for initializing
|
|
18
|
-
* LangWatch tracing with a familiar flat structure for main options
|
|
19
|
-
* and grouped sections for debug and advanced configuration.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const options: SetupObservabilityOptions = {
|
|
24
|
-
* langwatch: {
|
|
25
|
-
* apiKey: "sk-lw-1234567890abcdef"
|
|
26
|
-
* },
|
|
27
|
-
* serviceName: "my-service",
|
|
28
|
-
* attributes: {
|
|
29
|
-
* "service.version": "1.0.0",
|
|
30
|
-
* "deployment.environment": "production"
|
|
31
|
-
* },
|
|
32
|
-
* spanProcessors: [new BatchSpanProcessor(new JaegerExporter())],
|
|
33
|
-
* debug: {
|
|
34
|
-
* consoleTracing: true,
|
|
35
|
-
* logLevel: 'debug'
|
|
36
|
-
* }
|
|
37
|
-
* };
|
|
38
|
-
* ```
|
|
14
|
+
* See the docs for example configuration and field-by-field details.
|
|
39
15
|
*/
|
|
40
16
|
interface SetupObservabilityOptions {
|
|
41
17
|
/**
|
|
42
|
-
* LangWatch
|
|
43
|
-
*
|
|
44
|
-
* Set to 'disabled' to completely disable LangWatch integration.
|
|
45
|
-
* API key and endpoint can also be set via LANGWATCH_API_KEY and
|
|
46
|
-
* LANGWATCH_ENDPOINT environment variables.
|
|
18
|
+
* LangWatch config for sending data; 'disabled' turns it off. apiKey/
|
|
19
|
+
* endpoint default from LANGWATCH_API_KEY / LANGWATCH_ENDPOINT.
|
|
47
20
|
*/
|
|
48
21
|
langwatch?: {
|
|
49
22
|
/**
|
|
50
23
|
* LangWatch API key for authentication.
|
|
51
|
-
* Defaults to LANGWATCH_API_KEY environment variable.
|
|
52
|
-
*
|
|
53
|
-
* @example "sk-lw-1234567890abcdef"
|
|
54
24
|
* @default LANGWATCH_API_KEY environment variable
|
|
55
25
|
*/
|
|
56
26
|
apiKey?: string;
|
|
57
27
|
/**
|
|
58
|
-
* LangWatch endpoint
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @default "https://app.langwatch.ai"
|
|
62
|
-
* @default LANGWATCH_ENDPOINT environment variable
|
|
28
|
+
* LangWatch endpoint for traces and logs.
|
|
29
|
+
* @default LANGWATCH_ENDPOINT env var, else "https://app.langwatch.ai"
|
|
63
30
|
*/
|
|
64
31
|
endpoint?: string;
|
|
65
32
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* - 'simple': Exports spans immediately (good for debugging)
|
|
69
|
-
* - 'batch': Batches spans for better performance (recommended for production)
|
|
70
|
-
*
|
|
33
|
+
* Span processor type: 'simple' exports immediately (debugging),
|
|
34
|
+
* 'batch' batches for throughput (recommended for production).
|
|
71
35
|
* @default 'batch'
|
|
72
36
|
*/
|
|
73
37
|
processorType?: "simple" | "batch";
|
|
74
38
|
} | "disabled";
|
|
75
39
|
/**
|
|
76
|
-
* Name of the service being instrumented
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @example "user-service"
|
|
40
|
+
* Name of the service being instrumented, for identification in
|
|
41
|
+
* traces, logs, and metrics.
|
|
80
42
|
*/
|
|
81
43
|
serviceName?: string;
|
|
82
44
|
/**
|
|
83
|
-
* Global attributes added to all telemetry data.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @example { "service.version": "1.0.0", "deployment.environment": "production" }
|
|
45
|
+
* Global attributes added to all telemetry data (e.g. service version,
|
|
46
|
+
* deployment environment).
|
|
87
47
|
*/
|
|
88
48
|
attributes?: SemConvAttributes;
|
|
89
49
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* This provides control over input/output data capture by LangWatch instrumentations.
|
|
93
|
-
* You can use a simple string mode, a configuration object, or a predicate function
|
|
94
|
-
* for dynamic control based on the operation context.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* // Simple mode - capture everything
|
|
99
|
-
* dataCapture: "all"
|
|
100
|
-
*
|
|
101
|
-
* // Simple mode - capture only input data
|
|
102
|
-
* dataCapture: "input"
|
|
103
|
-
*
|
|
104
|
-
* // Simple mode - capture only output data
|
|
105
|
-
* dataCapture: "output"
|
|
106
|
-
*
|
|
107
|
-
* // Simple mode - capture nothing
|
|
108
|
-
* dataCapture: "none"
|
|
109
|
-
*
|
|
110
|
-
* // Configuration object
|
|
111
|
-
* dataCapture: {
|
|
112
|
-
* mode: "all"
|
|
113
|
-
* }
|
|
114
|
-
*
|
|
115
|
-
* // Dynamic predicate function
|
|
116
|
-
* dataCapture: (context) => {
|
|
117
|
-
* // Don't capture sensitive data in production
|
|
118
|
-
* if (context.environment === "production" &&
|
|
119
|
-
* context.operationName.includes("password")) {
|
|
120
|
-
* return "none";
|
|
121
|
-
* }
|
|
122
|
-
* // Capture everything else
|
|
123
|
-
* return "all";
|
|
124
|
-
* }
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
50
|
+
* Automatic input/output data capture: a mode string ("all" | "input" |
|
|
51
|
+
* "output" | "none"), a config object, or a context-based predicate.
|
|
127
52
|
* @default "all"
|
|
128
53
|
*/
|
|
129
54
|
dataCapture?: DataCaptureOptions;
|
|
130
55
|
/**
|
|
131
|
-
* Dedicated TracerProvider for
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* and does NOT touch the global provider. Spans created through this
|
|
135
|
-
* provider's tracers go only to LangWatch. The other SDK keeps the
|
|
136
|
-
* global provider and never sees LLM traces.
|
|
137
|
-
*
|
|
138
|
-
* Pass any instrumentations you want on this provider via the
|
|
139
|
-
* `instrumentations` option — they will be registered against this
|
|
140
|
-
* provider instead of the global one.
|
|
141
|
-
*
|
|
142
|
-
* @remarks Trace-only mode. Log export (`logRecordProcessors`,
|
|
143
|
-
* `debug.consoleLogging`) is not supported when using a dedicated
|
|
144
|
-
* TracerProvider — use the default setup for full log+trace support.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
149
|
-
*
|
|
150
|
-
* const lwProvider = new NodeTracerProvider();
|
|
151
|
-
* setupObservability({
|
|
152
|
-
* tracerProvider: lwProvider,
|
|
153
|
-
* langwatch: { apiKey: "..." },
|
|
154
|
-
* });
|
|
155
|
-
*
|
|
156
|
-
* // Use lwProvider.getTracer() for LLM calls
|
|
157
|
-
* const tracer = lwProvider.getTracer("my-llm-service");
|
|
158
|
-
* ```
|
|
56
|
+
* Dedicated TracerProvider for isolation from other OTel SDKs: LangWatch
|
|
57
|
+
* attaches its exporter here without touching the global provider, so
|
|
58
|
+
* another SDK sharing the process never sees LLM traces (trace-only).
|
|
159
59
|
*/
|
|
160
60
|
tracerProvider?: TracerProvider;
|
|
161
61
|
/**
|
|
162
|
-
* Custom trace exporter for
|
|
163
|
-
*
|
|
164
|
-
* This is a simpler alternative to spanProcessors for single exporter use cases.
|
|
165
|
-
*
|
|
166
|
-
* @example new OTLPTraceExporter({ url: "https://custom-collector.com/v1/traces" })
|
|
62
|
+
* Custom trace exporter for external systems; LangWatch creates its own
|
|
63
|
+
* if omitted. Simpler than spanProcessors for a single exporter.
|
|
167
64
|
*/
|
|
168
65
|
traceExporter?: SpanExporter;
|
|
169
66
|
/**
|
|
170
|
-
* Custom span processors for
|
|
171
|
-
*
|
|
172
|
-
* custom processing logic.
|
|
173
|
-
*
|
|
174
|
-
* @example [new SimpleSpanProcessor(new LangWatchExporter())]
|
|
175
|
-
* @example [new BatchSpanProcessor(exporter, { maxExportBatchSize: 100 })]
|
|
67
|
+
* Custom span processors for full control over batching, filtering,
|
|
68
|
+
* or processing logic.
|
|
176
69
|
*/
|
|
177
70
|
spanProcessors?: SpanProcessor[];
|
|
178
71
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
|
|
72
|
+
* OTLP protocol this process exports spans with (default "http"). "grpc"
|
|
73
|
+
* refuses to start without a traceExporter or spanProcessors built from
|
|
74
|
+
* the optional peer `@opentelemetry/exporter-trace-otlp-grpc`.
|
|
75
|
+
*/
|
|
76
|
+
otlpProtocol?: "http" | "grpc";
|
|
77
|
+
/**
|
|
78
|
+
* Span limits: max attributes, events, and links per span.
|
|
183
79
|
*/
|
|
184
80
|
spanLimits?: SpanLimits;
|
|
185
81
|
/**
|
|
186
82
|
* Sampling strategy for controlling which traces to collect.
|
|
187
|
-
*
|
|
188
|
-
* @example new TraceIdRatioBasedSampler(0.1) // Sample 10% of traces
|
|
189
83
|
*/
|
|
190
84
|
sampler?: Sampler;
|
|
191
85
|
/**
|
|
192
86
|
* Custom ID generator for span and trace IDs.
|
|
193
|
-
*
|
|
194
|
-
* @example new RandomIdGenerator()
|
|
195
87
|
*/
|
|
196
88
|
idGenerator?: IdGenerator;
|
|
197
89
|
/**
|
|
198
|
-
* Custom log record processors for
|
|
199
|
-
*
|
|
200
|
-
* custom processing logic.
|
|
201
|
-
*
|
|
202
|
-
* @example [new BatchLogRecordProcessor({ exporter, maxExportBatchSize: 100 })]
|
|
90
|
+
* Custom log record processors for full control over batching,
|
|
91
|
+
* filtering, or processing logic.
|
|
203
92
|
*/
|
|
204
93
|
logRecordProcessors?: LogRecordProcessor[];
|
|
205
94
|
/**
|
|
206
95
|
* Custom metric reader for collecting and exporting metrics.
|
|
207
|
-
*
|
|
208
|
-
* @example new PeriodicExportingMetricReader({ exporter: new PrometheusExporter() })
|
|
209
96
|
*/
|
|
210
97
|
metricReader?: IMetricReader;
|
|
211
98
|
/**
|
|
212
|
-
* Metric views
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* @example [{ instrumentName: 'http.server.duration', aggregation: Aggregation.Histogram() }]
|
|
99
|
+
* Metric views: control which metrics are collected and how they're
|
|
100
|
+
* aggregated/filtered.
|
|
216
101
|
*/
|
|
217
102
|
views?: ViewOptions[];
|
|
218
103
|
/**
|
|
219
|
-
* Auto-instrumentation libraries to enable
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* @example [new HttpInstrumentation(), new ExpressInstrumentation()]
|
|
104
|
+
* Auto-instrumentation libraries to enable, capturing telemetry from
|
|
105
|
+
* common libraries and frameworks.
|
|
223
106
|
*/
|
|
224
107
|
instrumentations?: (Instrumentation | Instrumentation[])[];
|
|
225
108
|
/**
|
|
226
|
-
*
|
|
227
|
-
* When enabled, OpenTelemetry automatically detects host, process, and environment info.
|
|
228
|
-
*
|
|
109
|
+
* Auto-detect resource attributes (host, process, environment info).
|
|
229
110
|
* @default true
|
|
230
111
|
*/
|
|
231
112
|
autoDetectResources?: boolean;
|
|
@@ -234,24 +115,18 @@ interface SetupObservabilityOptions {
|
|
|
234
115
|
*/
|
|
235
116
|
contextManager?: ContextManager;
|
|
236
117
|
/**
|
|
237
|
-
* Text map propagator
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* @example new W3CTraceContextPropagator()
|
|
118
|
+
* Text map propagator: controls how trace context is serialized in
|
|
119
|
+
* HTTP headers and other carriers across service boundaries.
|
|
241
120
|
*/
|
|
242
121
|
textMapPropagator?: TextMapPropagator;
|
|
243
122
|
/**
|
|
244
|
-
* Resource detectors for automatic
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* @example [envDetector, processDetector, hostDetector]
|
|
123
|
+
* Resource detectors for automatic detection of runtime environment
|
|
124
|
+
* attributes.
|
|
248
125
|
*/
|
|
249
|
-
resourceDetectors?:
|
|
126
|
+
resourceDetectors?: ResourceDetector[];
|
|
250
127
|
/**
|
|
251
|
-
* Custom resource configuration
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* @example new Resource({ "service.name": "my-service", "service.version": "1.0.0" })
|
|
128
|
+
* Custom resource configuration for the entity being monitored
|
|
129
|
+
* (service, host, deployment metadata).
|
|
255
130
|
*/
|
|
256
131
|
resource?: Resource;
|
|
257
132
|
/**
|
|
@@ -260,25 +135,17 @@ interface SetupObservabilityOptions {
|
|
|
260
135
|
*/
|
|
261
136
|
debug?: {
|
|
262
137
|
/**
|
|
263
|
-
*
|
|
264
|
-
* When true, spans will be logged to the console in addition
|
|
265
|
-
* to any other configured exporters.
|
|
266
|
-
*
|
|
138
|
+
* Log spans to the console in addition to configured exporters.
|
|
267
139
|
* @default false
|
|
268
140
|
*/
|
|
269
141
|
consoleTracing?: boolean;
|
|
270
142
|
/**
|
|
271
|
-
*
|
|
272
|
-
* When true, log records will be logged to the console in addition
|
|
273
|
-
* to any other configured exporters.
|
|
274
|
-
*
|
|
143
|
+
* Log records to the console in addition to configured exporters.
|
|
275
144
|
* @default false
|
|
276
145
|
*/
|
|
277
146
|
consoleLogging?: boolean;
|
|
278
147
|
/**
|
|
279
|
-
* Log level for LangWatch SDK internal
|
|
280
|
-
* Controls verbosity of SDK diagnostic messages.
|
|
281
|
-
*
|
|
148
|
+
* Log level for LangWatch SDK internal diagnostic messages.
|
|
282
149
|
* @default 'warn'
|
|
283
150
|
*/
|
|
284
151
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
@@ -294,175 +161,68 @@ interface SetupObservabilityOptions {
|
|
|
294
161
|
*/
|
|
295
162
|
advanced?: {
|
|
296
163
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* When false (default), setup errors are logged but the function
|
|
300
|
-
* returns no-op handles to prevent breaking your application.
|
|
301
|
-
* When true, setup errors will be thrown.
|
|
302
|
-
*
|
|
164
|
+
* Throw during setup instead of returning no-op handles; false means
|
|
165
|
+
* a setup failure is logged but never breaks your application.
|
|
303
166
|
* @default false
|
|
304
167
|
*/
|
|
305
168
|
throwOnSetupError?: boolean;
|
|
306
169
|
/**
|
|
307
|
-
* Skip OpenTelemetry setup
|
|
308
|
-
*
|
|
309
|
-
*
|
|
170
|
+
* Skip OpenTelemetry setup and return no-op handles, for when you
|
|
171
|
+
* set up OpenTelemetry yourself.
|
|
310
172
|
* @default false
|
|
311
173
|
*/
|
|
312
174
|
skipOpenTelemetrySetup?: boolean;
|
|
313
175
|
/**
|
|
314
|
-
* Force reinitialization
|
|
315
|
-
*
|
|
316
|
-
* WARNING: This can cause conflicts and is primarily intended for testing.
|
|
317
|
-
* Use with extreme caution in production.
|
|
318
|
-
*
|
|
176
|
+
* Force OpenTelemetry reinitialization even if already set up.
|
|
177
|
+
* WARNING: can cause conflicts; testing only, avoid in production.
|
|
319
178
|
* @default false
|
|
320
179
|
*/
|
|
321
180
|
UNSAFE_forceOpenTelemetryReinitialization?: boolean;
|
|
322
181
|
/**
|
|
323
182
|
* Attach LangWatch processors to an existing global TracerProvider
|
|
324
|
-
* instead of
|
|
325
|
-
* initialized.
|
|
326
|
-
*
|
|
327
|
-
* Use this when running LangWatch alongside another OTel-based SDK.
|
|
328
|
-
* LangWatch will add its span processors to the
|
|
329
|
-
* existing provider so both SDKs receive spans. Combine with
|
|
330
|
-
* LangWatchTraceExporter filter options to scope LangWatch to only
|
|
331
|
-
* LLM-related spans.
|
|
332
|
-
*
|
|
183
|
+
* instead of no-op'ing when another OTel SDK already initialized one.
|
|
333
184
|
* @default false
|
|
334
185
|
*/
|
|
335
186
|
attachToExistingProvider?: boolean;
|
|
336
187
|
/**
|
|
337
|
-
* Disable all observability setup and return no-op handles
|
|
338
|
-
*
|
|
339
|
-
* When true, no OpenTelemetry setup will occur and all operations
|
|
340
|
-
* will be no-ops. Useful for testing or when you want to completely
|
|
341
|
-
* disable observability without changing your code.
|
|
342
|
-
*
|
|
188
|
+
* Disable all observability setup and return no-op handles, for
|
|
189
|
+
* testing or disabling without code changes.
|
|
343
190
|
* @default false
|
|
344
191
|
*/
|
|
345
192
|
disabled?: boolean;
|
|
346
193
|
/**
|
|
347
|
-
* Disable
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* When enabled (default), the SDK registers handlers for `beforeExit` (event loop
|
|
351
|
-
* drains), `SIGINT` (Ctrl+C), and `SIGTERM` (external kill / Docker stop) to flush
|
|
352
|
-
* pending traces before the process exits.
|
|
353
|
-
*
|
|
354
|
-
* The SDK never terminates your process. Node runs every listener registered for a
|
|
355
|
-
* signal, so once the flush is done the SDK stands aside and lets your own shutdown
|
|
356
|
-
* logic decide when the process ends. The one exception keeps one-shot scripts
|
|
357
|
-
* working: if the SDK's handler turns out to be the only listener for that signal,
|
|
358
|
-
* it removes itself and re-raises the signal, so the process ends on the signal
|
|
359
|
-
* exactly as it would have if the SDK were not installed.
|
|
360
|
-
*
|
|
361
|
-
* Note: `process.exit()` calls (e.g. from test runners like vitest) bypass these
|
|
362
|
-
* handlers. In those environments, call `shutdown()` explicitly in your teardown.
|
|
363
|
-
*
|
|
364
|
-
* @default false
|
|
194
|
+
* Disable auto shutdown on `beforeExit`/`SIGINT`/`SIGTERM` (off by
|
|
195
|
+
* default). The SDK flushes then stands aside, re-raising the signal
|
|
196
|
+
* only if it was the sole listener; `process.exit()` bypasses this.
|
|
365
197
|
*/
|
|
366
198
|
disableAutoShutdown?: boolean;
|
|
367
199
|
/**
|
|
368
|
-
* Exit
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
* other `SIGINT` / `SIGTERM` listener that has not finished — a queue drain, in-flight
|
|
372
|
-
* database writes, connection teardown — is cut off mid-flight, and the process
|
|
373
|
-
* reports success even though it was signalled. This is what the SDK used to do
|
|
374
|
-
* unconditionally; the option exists only so an application that depended on it can
|
|
375
|
-
* keep the old behaviour while it moves the exit into its own signal handler, where
|
|
376
|
-
* it belongs.
|
|
377
|
-
*
|
|
378
|
-
* Leave this off unless your process now fails to exit on a signal, which happens
|
|
379
|
-
* only when you register a signal handler of your own that never terminates the
|
|
380
|
-
* process. Ignored when `disableAutoShutdown` is set.
|
|
381
|
-
*
|
|
382
|
-
* @default false
|
|
200
|
+
* Exit with status 0 once shutdown flushes (off by default). WARNING:
|
|
201
|
+
* cuts off any other in-flight signal listener and reports success
|
|
202
|
+
* regardless; ignored when `disableAutoShutdown` is set.
|
|
383
203
|
*/
|
|
384
204
|
UNSAFE_exitProcessAfterAutoShutdown?: boolean;
|
|
385
205
|
};
|
|
386
206
|
}
|
|
387
207
|
/**
|
|
388
|
-
* Handle returned from observability setup.
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* manually shut down the observability system and ensure that no data is lost.
|
|
392
|
-
*
|
|
393
|
-
* @example
|
|
394
|
-
* ```typescript
|
|
395
|
-
* const { shutdown } = setupObservability({
|
|
396
|
-
* advanced: { disableAutoShutdown: true }
|
|
397
|
-
* });
|
|
398
|
-
*
|
|
399
|
-
* // Manual shutdown in test teardown
|
|
400
|
-
* afterAll(async () => {
|
|
401
|
-
* await shutdown();
|
|
402
|
-
* });
|
|
403
|
-
* ```
|
|
208
|
+
* Handle returned from observability setup. Call `shutdown` yourself when
|
|
209
|
+
* automatic shutdown is disabled, or signals aren't available (e.g. test
|
|
210
|
+
* runners that call `process.exit()`).
|
|
404
211
|
*/
|
|
405
212
|
interface ObservabilityHandle {
|
|
406
213
|
/**
|
|
407
|
-
* Gracefully shuts down the
|
|
408
|
-
*
|
|
409
|
-
* This method should be called when the application is terminating
|
|
410
|
-
* to ensure all pending traces are exported before shutdown.
|
|
411
|
-
*
|
|
412
|
-
* The shutdown process:
|
|
413
|
-
* 1. Flushes any pending traces to the exporter
|
|
414
|
-
* 2. Closes the trace exporter
|
|
415
|
-
* 3. Shuts down the tracer provider
|
|
416
|
-
* 4. Cleans up any registered instrumentations
|
|
417
|
-
*
|
|
214
|
+
* Gracefully shuts down: flushes pending traces, closes the exporter,
|
|
215
|
+
* and cleans up instrumentations. Call when the application terminates.
|
|
418
216
|
* @returns Promise that resolves when shutdown is complete
|
|
419
|
-
*
|
|
420
|
-
* @example
|
|
421
|
-
* ```typescript
|
|
422
|
-
* // Graceful shutdown
|
|
423
|
-
* process.on('SIGTERM', async () => {
|
|
424
|
-
* console.log('Shutting down observability...');
|
|
425
|
-
* await shutdown();
|
|
426
|
-
* console.log('Observability shutdown complete');
|
|
427
|
-
* process.exit(0);
|
|
428
|
-
* });
|
|
429
|
-
*
|
|
430
|
-
* // Force shutdown with timeout
|
|
431
|
-
* process.on('SIGINT', async () => {
|
|
432
|
-
* console.log('Force shutdown...');
|
|
433
|
-
* await Promise.race([
|
|
434
|
-
* shutdown(),
|
|
435
|
-
* new Promise(resolve => setTimeout(resolve, 5000))
|
|
436
|
-
* ]);
|
|
437
|
-
* process.exit(1);
|
|
438
|
-
* });
|
|
439
|
-
* ```
|
|
440
217
|
*/
|
|
441
218
|
shutdown: () => Promise<void>;
|
|
442
219
|
}
|
|
443
220
|
|
|
444
221
|
declare function setupObservability(options?: SetupObservabilityOptions): ObservabilityHandle;
|
|
445
222
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
* - Does nothing if OpenTelemetry is already configured (by you or another library)
|
|
450
|
-
* - Sets up LangWatch observability if no tracer provider exists
|
|
451
|
-
* - Does nothing if LANGWATCH_API_KEY is not set
|
|
452
|
-
*
|
|
453
|
-
* This is useful for libraries/SDKs that want to ensure tracing is available
|
|
454
|
-
* without conflicting with user's existing observability setup.
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* ```typescript
|
|
458
|
-
* import { ensureSetup } from "langwatch/observability/node";
|
|
459
|
-
*
|
|
460
|
-
* // Safe to call - won't conflict with existing setup
|
|
461
|
-
* ensureSetup();
|
|
462
|
-
*
|
|
463
|
-
* // Now you can use tracing
|
|
464
|
-
* const tracer = trace.getTracer("my-app");
|
|
465
|
-
* ```
|
|
223
|
+
* Ensures observability is set up, only if not already configured:
|
|
224
|
+
* idempotent, sets up a tracer provider if none exists, does nothing if
|
|
225
|
+
* LANGWATCH_API_KEY is unset.
|
|
466
226
|
*/
|
|
467
227
|
declare const ensureSetup: () => ObservabilityHandle;
|
|
468
228
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../../../chunk-
|
|
6
|
-
require('../../../chunk-
|
|
4
|
+
var _chunkEQ5CFQGJjs = require('../../../chunk-EQ5CFQGJ.js');
|
|
5
|
+
require('../../../chunk-HCK7TCSK.js');
|
|
6
|
+
require('../../../chunk-BL3GHEKF.js');
|
|
7
|
+
require('../../../chunk-5VYEG3RS.js');
|
|
8
|
+
require('../../../chunk-N76BG37W.js');
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
exports.ensureSetup =
|
|
12
|
+
exports.ensureSetup = _chunkEQ5CFQGJjs.ensureSetup; exports.setupObservability = _chunkEQ5CFQGJjs.setupObservability;
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/sdks/typescript/dist/observability-sdk/setup/node/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,6DAAmC;AACnC,sCAAmC;AACnC,sCAAmC;AACnC;AACE;AACA;AACF,qHAAC","file":"/home/runner/work/langwatch/langwatch/sdks/typescript/dist/observability-sdk/setup/node/index.js"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/langwatch/langwatch/sdks/typescript/dist/observability-sdk/setup/node/index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,6DAAmC;AACnC,sCAAmC;AACnC,sCAAmC;AACnC,sCAAmC;AACnC,sCAAmC;AACnC;AACE;AACA;AACF,qHAAC","file":"/home/runner/work/langwatch/langwatch/sdks/typescript/dist/observability-sdk/setup/node/index.js"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureSetup,
|
|
3
3
|
setupObservability
|
|
4
|
-
} from "../../../chunk-
|
|
5
|
-
import "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
4
|
+
} from "../../../chunk-BDQ2RG7R.mjs";
|
|
5
|
+
import "../../../chunk-FKYYEGJ7.mjs";
|
|
6
|
+
import "../../../chunk-C7IWJ2GJ.mjs";
|
|
7
|
+
import "../../../chunk-SERULD4Z.mjs";
|
|
8
|
+
import "../../../chunk-WSGVZ3J2.mjs";
|
|
7
9
|
export {
|
|
8
10
|
ensureSetup,
|
|
9
11
|
setupObservability
|