langwatch 0.3.2 → 0.4.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/dist/{add-LBBS4I3H.js → add-35QACTIV.js} +34 -28
- package/dist/add-35QACTIV.js.map +1 -0
- package/dist/{add-RD3ZKFAT.mjs → add-TRJAXM4D.mjs} +22 -16
- package/dist/add-TRJAXM4D.mjs.map +1 -0
- package/dist/chunk-4ZSSHX6F.js +636 -0
- package/dist/chunk-4ZSSHX6F.js.map +1 -0
- package/dist/chunk-5EVBOHJY.js +155 -0
- package/dist/chunk-5EVBOHJY.js.map +1 -0
- package/dist/{chunk-YN4436PK.mjs → chunk-CU3443HD.mjs} +14 -9
- package/dist/{chunk-2JU376G7.js → chunk-D2CSG4SJ.js} +4 -4
- package/dist/chunk-D2CSG4SJ.js.map +1 -0
- package/dist/chunk-DISMHYXC.js +184 -0
- package/dist/chunk-DISMHYXC.js.map +1 -0
- package/dist/{chunk-E7UE2MPD.mjs → chunk-ECUXLXFT.mjs} +2 -2
- package/dist/chunk-EJWJXTPU.mjs +626 -0
- package/dist/chunk-EJWJXTPU.mjs.map +1 -0
- package/dist/chunk-GQMDZ4GY.mjs +155 -0
- package/dist/chunk-GQMDZ4GY.mjs.map +1 -0
- package/dist/{chunk-3GKPQB4R.mjs → chunk-HUI45ULC.mjs} +4 -4
- package/dist/chunk-HUI45ULC.mjs.map +1 -0
- package/dist/{chunk-HJU67C7H.js → chunk-K64Y6YUG.js} +10 -10
- package/dist/{chunk-HJU67C7H.js.map → chunk-K64Y6YUG.js.map} +1 -1
- package/dist/chunk-LP76VXI3.mjs +636 -0
- package/dist/chunk-LP76VXI3.mjs.map +1 -0
- package/dist/chunk-M4VUHTT2.js +626 -0
- package/dist/chunk-M4VUHTT2.js.map +1 -0
- package/dist/{chunk-PR3JDWC3.mjs → chunk-N2V6J3U2.mjs} +28 -3
- package/dist/chunk-N2V6J3U2.mjs.map +1 -0
- package/dist/chunk-OUCVXP4G.js +258 -0
- package/dist/chunk-OUCVXP4G.js.map +1 -0
- package/dist/{chunk-FJLK5CFL.js → chunk-OXBO24RB.js} +13 -8
- package/dist/chunk-OXBO24RB.js.map +1 -0
- package/dist/chunk-PGWR3OQY.mjs +258 -0
- package/dist/chunk-PGWR3OQY.mjs.map +1 -0
- package/dist/{chunk-SMXXAVMB.js → chunk-SGNJDRCT.js} +2 -2
- package/dist/chunk-SGNJDRCT.js.map +1 -0
- package/dist/{chunk-W5ZEP3CI.mjs → chunk-SYMZPWZE.mjs} +2 -2
- package/dist/chunk-SYMZPWZE.mjs.map +1 -0
- package/dist/{chunk-KGDAENGD.js → chunk-YH5TIVK2.js} +28 -3
- package/dist/chunk-YH5TIVK2.js.map +1 -0
- package/dist/chunk-YNQ44U6D.mjs +184 -0
- package/dist/chunk-YNQ44U6D.mjs.map +1 -0
- package/dist/cli/index.js +8 -8
- package/dist/cli/index.mjs +8 -8
- package/dist/{create-G5MTGOOH.js → create-7K2CC4KQ.js} +11 -11
- package/dist/{create-G5MTGOOH.js.map → create-7K2CC4KQ.js.map} +1 -1
- package/dist/{create-QUZYBMQB.mjs → create-MK7NEGCM.mjs} +8 -8
- package/dist/implementation-C4lvooSg.d.mts +576 -0
- package/dist/implementation-CzemP9jY.d.ts +576 -0
- package/dist/index-DTEZr0Jn.d.mts +34 -0
- package/dist/index-DTEZr0Jn.d.ts +34 -0
- package/dist/index.d.mts +121 -47
- package/dist/index.d.ts +121 -47
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -23
- package/dist/index.mjs.map +1 -1
- package/dist/init-GDKJICSS.js +16 -0
- package/dist/{init-XU2JFY6N.js.map → init-GDKJICSS.js.map} +1 -1
- package/dist/{init-H67RW22E.mjs → init-RINSTP4L.mjs} +5 -5
- package/dist/{list-7NPSX2E4.mjs → list-7L23G5DY.mjs} +28 -16
- package/dist/list-7L23G5DY.mjs.map +1 -0
- package/dist/{list-ZXFLAF52.js → list-OLLQ7XKZ.js} +29 -17
- package/dist/list-OLLQ7XKZ.js.map +1 -0
- package/dist/{login-EK4WVOI2.mjs → login-RCNKL5AM.mjs} +6 -5
- package/dist/login-RCNKL5AM.mjs.map +1 -0
- package/dist/{login-76NQIHKR.js → login-XF3BQQPV.js} +7 -6
- package/dist/login-XF3BQQPV.js.map +1 -0
- package/dist/observability-sdk/index.d.mts +134 -0
- package/dist/observability-sdk/index.d.ts +134 -0
- package/dist/observability-sdk/index.js +41 -0
- package/dist/observability-sdk/index.js.map +1 -0
- package/dist/observability-sdk/index.mjs +41 -0
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +69 -0
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +69 -0
- package/dist/observability-sdk/instrumentation/langchain/index.js +518 -0
- package/dist/observability-sdk/instrumentation/langchain/index.js.map +1 -0
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +518 -0
- package/dist/observability-sdk/instrumentation/langchain/index.mjs.map +1 -0
- package/dist/observability-sdk/setup/node/index.d.mts +368 -0
- package/dist/observability-sdk/setup/node/index.d.ts +368 -0
- package/dist/observability-sdk/setup/node/index.js +276 -0
- package/dist/observability-sdk/setup/node/index.js.map +1 -0
- package/dist/observability-sdk/setup/node/index.mjs +276 -0
- package/dist/observability-sdk/setup/node/index.mjs.map +1 -0
- package/dist/{remove-SDJYEPAY.mjs → remove-3VLQNVHN.mjs} +11 -8
- package/dist/remove-3VLQNVHN.mjs.map +1 -0
- package/dist/{remove-XBNGIVMR.js → remove-L6JVJBWY.js} +18 -15
- package/dist/remove-L6JVJBWY.js.map +1 -0
- package/dist/{sync-ST2IWXSB.mjs → sync-DPMTUTVL.mjs} +39 -33
- package/dist/sync-DPMTUTVL.mjs.map +1 -0
- package/dist/{sync-EISKGPTL.js → sync-PSU3F5Z4.js} +52 -46
- package/dist/sync-PSU3F5Z4.js.map +1 -0
- package/dist/{prompt-D-jpMrLS.d.mts → types-1q5wIYP5.d.mts} +628 -14
- package/dist/{prompt-D-jpMrLS.d.ts → types-C9k5gGhU.d.ts} +628 -14
- package/dist/types-DRiQaKFG.d.mts +254 -0
- package/dist/types-DRiQaKFG.d.ts +254 -0
- package/dist/types-Dmazk5Bk.d.mts +44 -0
- package/dist/types-Dmazk5Bk.d.ts +44 -0
- package/package.json +39 -39
- package/dist/add-LBBS4I3H.js.map +0 -1
- package/dist/add-RD3ZKFAT.mjs.map +0 -1
- package/dist/chunk-2JU376G7.js.map +0 -1
- package/dist/chunk-2ODBGSBI.js +0 -4
- package/dist/chunk-2ODBGSBI.js.map +0 -1
- package/dist/chunk-3GKPQB4R.mjs.map +0 -1
- package/dist/chunk-52GXX3MA.js +0 -426
- package/dist/chunk-52GXX3MA.js.map +0 -1
- package/dist/chunk-5NC5ILKA.js +0 -94
- package/dist/chunk-5NC5ILKA.js.map +0 -1
- package/dist/chunk-AAROJADR.mjs +0 -49
- package/dist/chunk-AAROJADR.mjs.map +0 -1
- package/dist/chunk-DTEKFQ4U.js +0 -159
- package/dist/chunk-DTEKFQ4U.js.map +0 -1
- package/dist/chunk-F63YKTXA.mjs +0 -47
- package/dist/chunk-F63YKTXA.mjs.map +0 -1
- package/dist/chunk-FJLK5CFL.js.map +0 -1
- package/dist/chunk-GJSEBQXF.mjs +0 -392
- package/dist/chunk-GJSEBQXF.mjs.map +0 -1
- package/dist/chunk-IGHXIIIK.js +0 -49
- package/dist/chunk-IGHXIIIK.js.map +0 -1
- package/dist/chunk-J7ICRUU4.mjs +0 -426
- package/dist/chunk-J7ICRUU4.mjs.map +0 -1
- package/dist/chunk-KGDAENGD.js.map +0 -1
- package/dist/chunk-LD74LVRU.js +0 -47
- package/dist/chunk-LD74LVRU.js.map +0 -1
- package/dist/chunk-PCQVQ7SB.js +0 -45
- package/dist/chunk-PCQVQ7SB.js.map +0 -1
- package/dist/chunk-PR3JDWC3.mjs.map +0 -1
- package/dist/chunk-PWZBLTHR.js +0 -118
- package/dist/chunk-PWZBLTHR.js.map +0 -1
- package/dist/chunk-QEWDG5QE.mjs +0 -45
- package/dist/chunk-QEWDG5QE.mjs.map +0 -1
- package/dist/chunk-SMXXAVMB.js.map +0 -1
- package/dist/chunk-STV4ZVNA.mjs +0 -118
- package/dist/chunk-STV4ZVNA.mjs.map +0 -1
- package/dist/chunk-T5AZMMVS.mjs +0 -94
- package/dist/chunk-T5AZMMVS.mjs.map +0 -1
- package/dist/chunk-UU33HCCZ.mjs +0 -159
- package/dist/chunk-UU33HCCZ.mjs.map +0 -1
- package/dist/chunk-VGHLQXKB.js +0 -392
- package/dist/chunk-VGHLQXKB.js.map +0 -1
- package/dist/chunk-W5ZEP3CI.mjs.map +0 -1
- package/dist/chunk-Y666BJA5.mjs +0 -4
- package/dist/chunk-YN4436PK.mjs.map +0 -1
- package/dist/client-B2HqIKg6.d.ts +0 -51
- package/dist/client-XyCqclCi.d.mts +0 -51
- package/dist/client-browser.d.mts +0 -8
- package/dist/client-browser.d.ts +0 -8
- package/dist/client-browser.js +0 -88
- package/dist/client-browser.js.map +0 -1
- package/dist/client-browser.mjs +0 -88
- package/dist/client-browser.mjs.map +0 -1
- package/dist/client-node.d.mts +0 -8
- package/dist/client-node.d.ts +0 -8
- package/dist/client-node.js +0 -95
- package/dist/client-node.js.map +0 -1
- package/dist/client-node.mjs +0 -95
- package/dist/client-node.mjs.map +0 -1
- package/dist/evaluation/index.d.mts +0 -897
- package/dist/evaluation/index.d.ts +0 -897
- package/dist/evaluation/index.js +0 -14
- package/dist/evaluation/index.js.map +0 -1
- package/dist/evaluation/index.mjs +0 -14
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.mts +0 -64
- package/dist/filterable-batch-span-processor-zO5kcjBY.d.ts +0 -64
- package/dist/init-XU2JFY6N.js +0 -16
- package/dist/list-7NPSX2E4.mjs.map +0 -1
- package/dist/list-ZXFLAF52.js.map +0 -1
- package/dist/login-76NQIHKR.js.map +0 -1
- package/dist/login-EK4WVOI2.mjs.map +0 -1
- package/dist/observability/index.d.mts +0 -260
- package/dist/observability/index.d.ts +0 -260
- package/dist/observability/index.js +0 -21
- package/dist/observability/index.js.map +0 -1
- package/dist/observability/index.mjs +0 -21
- package/dist/observability/index.mjs.map +0 -1
- package/dist/observability/instrumentation/langchain/index.d.mts +0 -40
- package/dist/observability/instrumentation/langchain/index.d.ts +0 -40
- package/dist/observability/instrumentation/langchain/index.js +0 -668
- package/dist/observability/instrumentation/langchain/index.js.map +0 -1
- package/dist/observability/instrumentation/langchain/index.mjs +0 -668
- package/dist/observability/instrumentation/langchain/index.mjs.map +0 -1
- package/dist/prompt/index.d.mts +0 -10
- package/dist/prompt/index.d.ts +0 -10
- package/dist/prompt/index.js +0 -22
- package/dist/prompt/index.js.map +0 -1
- package/dist/prompt/index.mjs +0 -22
- package/dist/prompt/index.mjs.map +0 -1
- package/dist/record-evaluation-CmxMXa-3.d.mts +0 -25
- package/dist/record-evaluation-CmxMXa-3.d.ts +0 -25
- package/dist/remove-SDJYEPAY.mjs.map +0 -1
- package/dist/remove-XBNGIVMR.js.map +0 -1
- package/dist/sync-EISKGPTL.js.map +0 -1
- package/dist/sync-ST2IWXSB.mjs.map +0 -1
- package/dist/trace-CqaKo0kZ.d.ts +0 -622
- package/dist/trace-DtVc5GhF.d.mts +0 -622
- /package/dist/{chunk-Y666BJA5.mjs.map → chunk-CU3443HD.mjs.map} +0 -0
- /package/dist/{chunk-E7UE2MPD.mjs.map → chunk-ECUXLXFT.mjs.map} +0 -0
- /package/dist/{create-QUZYBMQB.mjs.map → create-MK7NEGCM.mjs.map} +0 -0
- /package/dist/{init-H67RW22E.mjs.map → init-RINSTP4L.mjs.map} +0 -0
- /package/dist/{evaluation → observability-sdk}/index.mjs.map +0 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { L as Logger } from '../../../index-DTEZr0Jn.mjs';
|
|
2
|
+
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { SpanExporter, SpanProcessor, SpanLimits, Sampler, IdGenerator } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
5
|
+
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
6
|
+
import { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';
|
|
7
|
+
import { ResourceDetector, Resource } from '@opentelemetry/resources';
|
|
8
|
+
import { S as SemConvAttributes } from '../../../types-DRiQaKFG.mjs';
|
|
9
|
+
import { D as DataCaptureOptions } from '../../../types-Dmazk5Bk.mjs';
|
|
10
|
+
import '@opentelemetry/api-logs';
|
|
11
|
+
import '@opentelemetry/semantic-conventions';
|
|
12
|
+
import '@opentelemetry/semantic-conventions/incubating';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 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
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
interface SetupObservabilityOptions {
|
|
41
|
+
/**
|
|
42
|
+
* LangWatch configuration for sending observability data to 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.
|
|
47
|
+
*/
|
|
48
|
+
langwatch?: {
|
|
49
|
+
/**
|
|
50
|
+
* LangWatch API key for authentication.
|
|
51
|
+
* Defaults to LANGWATCH_API_KEY environment variable.
|
|
52
|
+
*
|
|
53
|
+
* @example "sk-lw-1234567890abcdef"
|
|
54
|
+
* @default LANGWATCH_API_KEY environment variable
|
|
55
|
+
*/
|
|
56
|
+
apiKey?: string;
|
|
57
|
+
/**
|
|
58
|
+
* LangWatch endpoint URL for sending traces and logs.
|
|
59
|
+
* Defaults to LANGWATCH_ENDPOINT environment variable or production endpoint.
|
|
60
|
+
*
|
|
61
|
+
* @default "https://api.langwatch.ai"
|
|
62
|
+
* @default LANGWATCH_ENDPOINT environment variable
|
|
63
|
+
*/
|
|
64
|
+
endpoint?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Type of span processor to use for LangWatch exporter.
|
|
67
|
+
*
|
|
68
|
+
* - 'simple': Exports spans immediately (good for debugging)
|
|
69
|
+
* - 'batch': Batches spans for better performance (recommended for production)
|
|
70
|
+
*
|
|
71
|
+
* @default 'simple'
|
|
72
|
+
*/
|
|
73
|
+
processorType?: "simple" | "batch";
|
|
74
|
+
} | "disabled";
|
|
75
|
+
/**
|
|
76
|
+
* Name of the service being instrumented.
|
|
77
|
+
* Used to identify your service in traces, logs, and metrics.
|
|
78
|
+
*
|
|
79
|
+
* @example "user-service"
|
|
80
|
+
*/
|
|
81
|
+
serviceName?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Global attributes added to all telemetry data.
|
|
84
|
+
* Useful for adding service-level metadata like version, environment, etc.
|
|
85
|
+
*
|
|
86
|
+
* @example { "service.version": "1.0.0", "deployment.environment": "production" }
|
|
87
|
+
*/
|
|
88
|
+
attributes?: SemConvAttributes;
|
|
89
|
+
/**
|
|
90
|
+
* Configuration for automatic data capture.
|
|
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
|
+
*
|
|
127
|
+
* @default "all"
|
|
128
|
+
*/
|
|
129
|
+
dataCapture?: DataCaptureOptions;
|
|
130
|
+
/**
|
|
131
|
+
* Custom trace exporter for sending spans to external systems.
|
|
132
|
+
* If not provided, LangWatch will create its own exporter.
|
|
133
|
+
* This is a simpler alternative to spanProcessors for single exporter use cases.
|
|
134
|
+
*
|
|
135
|
+
* @example new OTLPTraceExporter({ url: "https://custom-collector.com/v1/traces" })
|
|
136
|
+
*/
|
|
137
|
+
traceExporter?: SpanExporter;
|
|
138
|
+
/**
|
|
139
|
+
* Custom span processors for advanced trace processing.
|
|
140
|
+
* Use this when you need full control over batching, filtering, or
|
|
141
|
+
* custom processing logic.
|
|
142
|
+
*
|
|
143
|
+
* @example [new SimpleSpanProcessor(new LangWatchExporter())]
|
|
144
|
+
* @example [new BatchSpanProcessor(exporter, { maxExportBatchSize: 100 })]
|
|
145
|
+
*/
|
|
146
|
+
spanProcessors?: SpanProcessor[];
|
|
147
|
+
/**
|
|
148
|
+
* Span limits configuration.
|
|
149
|
+
* Controls the maximum number of attributes, events, and links per span.
|
|
150
|
+
*
|
|
151
|
+
* @example { attributeCountLimit: 128, eventCountLimit: 128 }
|
|
152
|
+
*/
|
|
153
|
+
spanLimits?: SpanLimits;
|
|
154
|
+
/**
|
|
155
|
+
* Sampling strategy for controlling which traces to collect.
|
|
156
|
+
*
|
|
157
|
+
* @example new TraceIdRatioBasedSampler(0.1) // Sample 10% of traces
|
|
158
|
+
*/
|
|
159
|
+
sampler?: Sampler;
|
|
160
|
+
/**
|
|
161
|
+
* Custom ID generator for span and trace IDs.
|
|
162
|
+
*
|
|
163
|
+
* @example new RandomIdGenerator()
|
|
164
|
+
*/
|
|
165
|
+
idGenerator?: IdGenerator;
|
|
166
|
+
/**
|
|
167
|
+
* Custom log record processors for advanced log processing.
|
|
168
|
+
* Use this when you need full control over batching, filtering, or
|
|
169
|
+
* custom processing logic.
|
|
170
|
+
*
|
|
171
|
+
* @example [new BatchLogRecordProcessor(exporter, { maxExportBatchSize: 100 })]
|
|
172
|
+
*/
|
|
173
|
+
logRecordProcessors?: LogRecordProcessor[];
|
|
174
|
+
/**
|
|
175
|
+
* Custom metric reader for collecting and exporting metrics.
|
|
176
|
+
*
|
|
177
|
+
* @example new PeriodicExportingMetricReader({ exporter: new PrometheusExporter() })
|
|
178
|
+
*/
|
|
179
|
+
metricReader?: IMetricReader;
|
|
180
|
+
/**
|
|
181
|
+
* Metric views for controlling aggregation and filtering.
|
|
182
|
+
* Views determine which metrics are collected and how they are processed.
|
|
183
|
+
*
|
|
184
|
+
* @example [{ instrumentName: 'http.server.duration', aggregation: Aggregation.Histogram() }]
|
|
185
|
+
*/
|
|
186
|
+
views?: ViewOptions[];
|
|
187
|
+
/**
|
|
188
|
+
* Auto-instrumentation libraries to enable.
|
|
189
|
+
* These automatically capture telemetry from common libraries and frameworks.
|
|
190
|
+
*
|
|
191
|
+
* @example [new HttpInstrumentation(), new ExpressInstrumentation()]
|
|
192
|
+
*/
|
|
193
|
+
instrumentations?: (Instrumentation | Instrumentation[])[];
|
|
194
|
+
/**
|
|
195
|
+
* Whether to automatically detect and configure resource attributes.
|
|
196
|
+
* When enabled, OpenTelemetry automatically detects host, process, and environment info.
|
|
197
|
+
*
|
|
198
|
+
* @default true
|
|
199
|
+
*/
|
|
200
|
+
autoDetectResources?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Custom context manager for managing trace context across async operations.
|
|
203
|
+
*/
|
|
204
|
+
contextManager?: ContextManager;
|
|
205
|
+
/**
|
|
206
|
+
* Text map propagator for trace context propagation across service boundaries.
|
|
207
|
+
* Controls how trace context is serialized in HTTP headers and other carriers.
|
|
208
|
+
*
|
|
209
|
+
* @example new W3CTraceContextPropagator()
|
|
210
|
+
*/
|
|
211
|
+
textMapPropagator?: TextMapPropagator;
|
|
212
|
+
/**
|
|
213
|
+
* Resource detectors for automatic resource attribute detection.
|
|
214
|
+
* These detect information about the runtime environment.
|
|
215
|
+
*
|
|
216
|
+
* @example [envDetector, processDetector, hostDetector]
|
|
217
|
+
*/
|
|
218
|
+
resourceDetectors?: Array<ResourceDetector>;
|
|
219
|
+
/**
|
|
220
|
+
* Custom resource configuration representing the entity being monitored.
|
|
221
|
+
* Includes service, host, and deployment metadata.
|
|
222
|
+
*
|
|
223
|
+
* @example new Resource({ "service.name": "my-service", "service.version": "1.0.0" })
|
|
224
|
+
*/
|
|
225
|
+
resource?: Resource;
|
|
226
|
+
/**
|
|
227
|
+
* Debug and development options.
|
|
228
|
+
* These control console output and SDK internal logging behavior.
|
|
229
|
+
*/
|
|
230
|
+
debug?: {
|
|
231
|
+
/**
|
|
232
|
+
* Enable console output for traces (debugging).
|
|
233
|
+
* When true, spans will be logged to the console in addition
|
|
234
|
+
* to any other configured exporters.
|
|
235
|
+
*
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
consoleTracing?: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Enable console output for logs (debugging).
|
|
241
|
+
* When true, log records will be logged to the console in addition
|
|
242
|
+
* to any other configured exporters.
|
|
243
|
+
*
|
|
244
|
+
* @default false
|
|
245
|
+
*/
|
|
246
|
+
consoleLogging?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Log level for LangWatch SDK internal logging.
|
|
249
|
+
* Controls verbosity of SDK diagnostic messages.
|
|
250
|
+
*
|
|
251
|
+
* @default 'warn'
|
|
252
|
+
*/
|
|
253
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
254
|
+
/**
|
|
255
|
+
* Custom logger for LangWatch SDK internal logging.
|
|
256
|
+
* If not provided, a console logger will be used.
|
|
257
|
+
*/
|
|
258
|
+
logger?: Logger;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Advanced and potentially unsafe configuration options.
|
|
262
|
+
* These options are for special use cases and should be used with caution.
|
|
263
|
+
*/
|
|
264
|
+
advanced?: {
|
|
265
|
+
/**
|
|
266
|
+
* Whether to throw errors during setup or return no-op handles.
|
|
267
|
+
*
|
|
268
|
+
* When false (default), setup errors are logged but the function
|
|
269
|
+
* returns no-op handles to prevent breaking your application.
|
|
270
|
+
* When true, setup errors will be thrown.
|
|
271
|
+
*
|
|
272
|
+
* @default false
|
|
273
|
+
*/
|
|
274
|
+
throwOnSetupError?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Skip OpenTelemetry setup entirely and return no-op handles.
|
|
277
|
+
* Useful when you want to handle OpenTelemetry setup yourself.
|
|
278
|
+
*
|
|
279
|
+
* @default false
|
|
280
|
+
*/
|
|
281
|
+
skipOpenTelemetrySetup?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Force reinitialization of OpenTelemetry even if already set up.
|
|
284
|
+
*
|
|
285
|
+
* WARNING: This can cause conflicts and is primarily intended for testing.
|
|
286
|
+
* Use with extreme caution in production.
|
|
287
|
+
*
|
|
288
|
+
* @default false
|
|
289
|
+
*/
|
|
290
|
+
UNSAFE_forceOpenTelemetryReinitialization?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Disable all observability setup and return no-op handles.
|
|
293
|
+
*
|
|
294
|
+
* When true, no OpenTelemetry setup will occur and all operations
|
|
295
|
+
* will be no-ops. Useful for testing or when you want to completely
|
|
296
|
+
* disable observability without changing your code.
|
|
297
|
+
*
|
|
298
|
+
* @default false
|
|
299
|
+
*/
|
|
300
|
+
disabled?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Disable the automatic shutdown of the observability system when the application
|
|
303
|
+
* terminates.
|
|
304
|
+
*
|
|
305
|
+
* @default false
|
|
306
|
+
*/
|
|
307
|
+
disableAutoShutdown?: boolean;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Handle returned from observability setup. If you disable the automatic shutdown,
|
|
312
|
+
* do you are running in an environment where you can't listen to SIGTERM to handle
|
|
313
|
+
* shutdowns, you can use the shutdown function to manually shut down the
|
|
314
|
+
* observability system, and ensure that no data is lost.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const { shutdown } = setupObservability(options);
|
|
319
|
+
*
|
|
320
|
+
* // Shutdown when the application is terminating
|
|
321
|
+
* process.on('SIGTERM', async () => {
|
|
322
|
+
* await shutdown();
|
|
323
|
+
* process.exit(0);
|
|
324
|
+
* });
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
interface ObservabilityHandle {
|
|
328
|
+
/**
|
|
329
|
+
* Gracefully shuts down the observability system.
|
|
330
|
+
*
|
|
331
|
+
* This method should be called when the application is terminating
|
|
332
|
+
* to ensure all pending traces are exported before shutdown.
|
|
333
|
+
*
|
|
334
|
+
* The shutdown process:
|
|
335
|
+
* 1. Flushes any pending traces to the exporter
|
|
336
|
+
* 2. Closes the trace exporter
|
|
337
|
+
* 3. Shuts down the tracer provider
|
|
338
|
+
* 4. Cleans up any registered instrumentations
|
|
339
|
+
*
|
|
340
|
+
* @returns Promise that resolves when shutdown is complete
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* // Graceful shutdown
|
|
345
|
+
* process.on('SIGTERM', async () => {
|
|
346
|
+
* console.log('Shutting down observability...');
|
|
347
|
+
* await shutdown();
|
|
348
|
+
* console.log('Observability shutdown complete');
|
|
349
|
+
* process.exit(0);
|
|
350
|
+
* });
|
|
351
|
+
*
|
|
352
|
+
* // Force shutdown with timeout
|
|
353
|
+
* process.on('SIGINT', async () => {
|
|
354
|
+
* console.log('Force shutdown...');
|
|
355
|
+
* await Promise.race([
|
|
356
|
+
* shutdown(),
|
|
357
|
+
* new Promise(resolve => setTimeout(resolve, 5000))
|
|
358
|
+
* ]);
|
|
359
|
+
* process.exit(1);
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
shutdown: () => Promise<void>;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
declare function setupObservability(options?: SetupObservabilityOptions): ObservabilityHandle;
|
|
367
|
+
|
|
368
|
+
export { type ObservabilityHandle, type SetupObservabilityOptions, setupObservability };
|