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.js';
|
|
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.js';
|
|
9
|
+
import { D as DataCaptureOptions } from '../../../types-Dmazk5Bk.js';
|
|
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 };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkOUCVXP4Gjs = require('../../../chunk-OUCVXP4G.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkDISMHYXCjs = require('../../../chunk-DISMHYXC.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkOXBO24RBjs = require('../../../chunk-OXBO24RB.js');
|
|
17
|
+
|
|
18
|
+
// src/observability-sdk/setup/node/setup.ts
|
|
19
|
+
var _sdknode = require('@opentelemetry/sdk-node');
|
|
20
|
+
var _sdklogs = require('@opentelemetry/sdk-logs');
|
|
21
|
+
|
|
22
|
+
// src/observability-sdk/setup/utils.ts
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var _resources = require('@opentelemetry/resources');
|
|
27
|
+
var _incubating = require('@opentelemetry/semantic-conventions/incubating'); var semconv = _interopRequireWildcard(_incubating);
|
|
28
|
+
function createMergedResource(attributes, serviceName, givenResource) {
|
|
29
|
+
const langwatchResource = _resources.resourceFromAttributes.call(void 0, {
|
|
30
|
+
[semconv.ATTR_TELEMETRY_SDK_NAME]: _chunkOUCVXP4Gjs.LANGWATCH_SDK_NAME_OBSERVABILITY,
|
|
31
|
+
[semconv.ATTR_TELEMETRY_SDK_LANGUAGE]: _chunkOUCVXP4Gjs.LANGWATCH_SDK_LANGUAGE,
|
|
32
|
+
[semconv.ATTR_TELEMETRY_SDK_VERSION]: _chunkOUCVXP4Gjs.LANGWATCH_SDK_VERSION
|
|
33
|
+
});
|
|
34
|
+
const userResource = _resources.resourceFromAttributes.call(void 0, _chunkOXBO24RBjs.__spreadValues.call(void 0, {
|
|
35
|
+
[semconv.ATTR_SERVICE_NAME]: serviceName != null ? serviceName : _chunkOUCVXP4Gjs.DEFAULT_SERVICE_NAME
|
|
36
|
+
}, attributes != null ? attributes : {}));
|
|
37
|
+
return (givenResource != null ? givenResource : _resources.defaultResource.call(void 0, )).merge(langwatchResource).merge(userResource);
|
|
38
|
+
}
|
|
39
|
+
function getConcreteProvider(provider) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (!provider || typeof provider !== "object") return void 0;
|
|
42
|
+
const constructorName = (_a = provider.constructor) == null ? void 0 : _a.name;
|
|
43
|
+
if (["NodeTracerProvider", "BasicTracerProvider"].includes(constructorName)) {
|
|
44
|
+
return provider;
|
|
45
|
+
}
|
|
46
|
+
if (typeof provider.addSpanProcessor === "function") {
|
|
47
|
+
return provider;
|
|
48
|
+
}
|
|
49
|
+
let delegate;
|
|
50
|
+
if (typeof provider.getDelegate === "function") {
|
|
51
|
+
delegate = provider.getDelegate();
|
|
52
|
+
} else if (provider.delegate) {
|
|
53
|
+
delegate = provider.delegate;
|
|
54
|
+
}
|
|
55
|
+
if (delegate && typeof delegate === "object") {
|
|
56
|
+
const delegateConstructorName = (_b = delegate.constructor) == null ? void 0 : _b.name;
|
|
57
|
+
if (["NodeTracerProvider", "BasicTracerProvider"].includes(delegateConstructorName)) {
|
|
58
|
+
return delegate;
|
|
59
|
+
}
|
|
60
|
+
if (typeof delegate.addSpanProcessor === "function") {
|
|
61
|
+
return delegate;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
function isConcreteProvider(provider) {
|
|
67
|
+
return !!getConcreteProvider(provider);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/observability-sdk/setup/node/setup.ts
|
|
71
|
+
var _api = require('@opentelemetry/api');
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var _sdktracebase = require('@opentelemetry/sdk-trace-base');
|
|
77
|
+
var createNoOpHandle = (logger) => ({
|
|
78
|
+
shutdown: async () => {
|
|
79
|
+
logger.debug("Shutdown called for LangWatch no-op. Nothing will be shutdown");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var getLangWatchConfig = (options) => {
|
|
83
|
+
var _a, _b, _c, _d;
|
|
84
|
+
const isDisabled = options.langwatch === "disabled";
|
|
85
|
+
const config = typeof options.langwatch === "object" ? options.langwatch : {};
|
|
86
|
+
return {
|
|
87
|
+
disabled: isDisabled,
|
|
88
|
+
apiKey: isDisabled ? void 0 : (_a = config.apiKey) != null ? _a : process.env.LANGWATCH_API_KEY,
|
|
89
|
+
endpoint: isDisabled ? void 0 : (_c = (_b = config.endpoint) != null ? _b : process.env.LANGWATCH_ENDPOINT) != null ? _c : "https://api.langwatch.ai",
|
|
90
|
+
processorType: (_d = config.processorType) != null ? _d : "simple"
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
var checkForEarlyExit = (options, logger) => {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
if ((_a = options.advanced) == null ? void 0 : _a.disabled) {
|
|
96
|
+
logger.debug("Observability disabled via advanced.disabled");
|
|
97
|
+
return createNoOpHandle(logger);
|
|
98
|
+
}
|
|
99
|
+
if ((_b = options.advanced) == null ? void 0 : _b.skipOpenTelemetrySetup) {
|
|
100
|
+
logger.debug("Skipping OpenTelemetry setup");
|
|
101
|
+
return createNoOpHandle(logger);
|
|
102
|
+
}
|
|
103
|
+
const globalProvider = _api.trace.getTracerProvider();
|
|
104
|
+
const alreadySetup = isConcreteProvider(globalProvider);
|
|
105
|
+
if (alreadySetup && !((_c = options.advanced) == null ? void 0 : _c.UNSAFE_forceOpenTelemetryReinitialization)) {
|
|
106
|
+
logger.error(
|
|
107
|
+
`OpenTelemetry is already set up in this process.
|
|
108
|
+
Spans will NOT be sent to LangWatch unless you add the LangWatch span processor or exporter to your existing OpenTelemetry setup.
|
|
109
|
+
You must either:
|
|
110
|
+
1. Remove your existing OpenTelemetry setup and only use LangWatch,
|
|
111
|
+
2. Add the LangWatch span processor to your existing setup, or replace the existing exporter with the LangWatch exporter.
|
|
112
|
+
|
|
113
|
+
For step-by-step instructions, see the LangWatch docs and check out the integration guide for your framework:
|
|
114
|
+
https://docs.langwatch.ai/integration/typescript/guide
|
|
115
|
+
|
|
116
|
+
See also: https://github.com/open-telemetry/opentelemetry-js/issues/5299`
|
|
117
|
+
);
|
|
118
|
+
return createNoOpHandle(logger);
|
|
119
|
+
}
|
|
120
|
+
if (alreadySetup) {
|
|
121
|
+
logger.warn(
|
|
122
|
+
"OpenTelemetry is already set up, but UNSAFE_forceOpenTelemetryReinitialization=true. Proceeding with reinitialization. This may cause conflicts."
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
};
|
|
127
|
+
var warnIfMisconfigured = (options, langwatch, logger) => {
|
|
128
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
129
|
+
if (langwatch.disabled) {
|
|
130
|
+
const hasAlternativeExport = (_h = (_g = (_e = (_c = (_a = options.spanProcessors) == null ? void 0 : _a.length) != null ? _c : (_b = options.logRecordProcessors) == null ? void 0 : _b.length) != null ? _e : (_d = options.debug) == null ? void 0 : _d.consoleTracing) != null ? _g : (_f = options.debug) == null ? void 0 : _f.consoleLogging) != null ? _h : options.traceExporter;
|
|
131
|
+
if (!hasAlternativeExport) {
|
|
132
|
+
const errorMessage = "LangWatch integration is disabled but no custom span processors, trace exporters, or console tracing is configured. OpenTelemetry will be set up but traces will not be exported anywhere. Either:\n 1. Enable LangWatch integration (remove langwatch: 'disabled')\n 2. Provide custom spanProcessors, logRecordProcessors, or traceExporter\n 3. Enable debug.consoleTracing or debug.consoleLogging for development\n 4. Use advanced.disabled to completely disable observability\n 5. Use advanced.skipOpenTelemetrySetup to handle OpenTelemetry setup yourself";
|
|
133
|
+
if ((_i = options.advanced) == null ? void 0 : _i.throwOnSetupError) {
|
|
134
|
+
throw new Error(errorMessage);
|
|
135
|
+
} else {
|
|
136
|
+
logger.error(errorMessage);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
function setupObservability(options = {}) {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
const logger = (_d = (_a = options.debug) == null ? void 0 : _a.logger) != null ? _d : new (0, _chunkDISMHYXCjs.ConsoleLogger)({
|
|
144
|
+
level: (_c = (_b = options.debug) == null ? void 0 : _b.logLevel) != null ? _c : "warn",
|
|
145
|
+
prefix: "LangWatch Observability SDK"
|
|
146
|
+
});
|
|
147
|
+
_chunkDISMHYXCjs.initializeObservabilitySdkConfig.call(void 0, {
|
|
148
|
+
logger,
|
|
149
|
+
dataCapture: options.dataCapture
|
|
150
|
+
});
|
|
151
|
+
const earlyExit = checkForEarlyExit(options, logger);
|
|
152
|
+
if (earlyExit) return earlyExit;
|
|
153
|
+
try {
|
|
154
|
+
const sdk = createAndStartNodeSdk(options, logger, createMergedResource(
|
|
155
|
+
options.attributes,
|
|
156
|
+
options.serviceName,
|
|
157
|
+
options.resource
|
|
158
|
+
));
|
|
159
|
+
logger.info("LangWatch Observability SDK setup completed successfully");
|
|
160
|
+
return {
|
|
161
|
+
shutdown: async () => {
|
|
162
|
+
logger.debug("Shutting down NodeSDK");
|
|
163
|
+
await (sdk == null ? void 0 : sdk.shutdown());
|
|
164
|
+
logger.info("NodeSDK shutdown complete");
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
} catch (err) {
|
|
168
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
169
|
+
logger.error(`Failed to initialize NodeSDK: ${errorMessage}`);
|
|
170
|
+
if (err instanceof Error && err.stack) {
|
|
171
|
+
logger.debug(`Stack trace: ${err.stack}`);
|
|
172
|
+
}
|
|
173
|
+
if ((_e = options.advanced) == null ? void 0 : _e.throwOnSetupError) throw err;
|
|
174
|
+
return createNoOpHandle(logger);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function createAndStartNodeSdk(options, logger, resource) {
|
|
178
|
+
var _a, _b, _c, _d, _e;
|
|
179
|
+
const langwatch = getLangWatchConfig(options);
|
|
180
|
+
if (langwatch.disabled) {
|
|
181
|
+
logger.warn("LangWatch integration disabled, using user-provided SpanProcessors and LogRecordProcessors");
|
|
182
|
+
} else {
|
|
183
|
+
logger.info(`Using LangWatch ${langwatch.processorType} processors for tracing and logging`);
|
|
184
|
+
}
|
|
185
|
+
const spanProcessors = [];
|
|
186
|
+
const logProcessors = [];
|
|
187
|
+
if ((_a = options.debug) == null ? void 0 : _a.consoleTracing) {
|
|
188
|
+
spanProcessors.push(new (0, _sdktracebase.SimpleSpanProcessor)(new (0, _sdktracebase.ConsoleSpanExporter)()));
|
|
189
|
+
logger.debug("Console tracing enabled; adding console span exporter");
|
|
190
|
+
}
|
|
191
|
+
if ((_b = options.debug) == null ? void 0 : _b.consoleLogging) {
|
|
192
|
+
logProcessors.push(new (0, _sdklogs.SimpleLogRecordProcessor)(new (0, _sdklogs.ConsoleLogRecordExporter)()));
|
|
193
|
+
logger.debug("Console recording of logs enabled; adding console log record processor");
|
|
194
|
+
}
|
|
195
|
+
if (!langwatch.disabled) {
|
|
196
|
+
const traceExporter = new (0, _chunkOUCVXP4Gjs.LangWatchTraceExporter)({
|
|
197
|
+
apiKey: langwatch.apiKey,
|
|
198
|
+
endpoint: langwatch.endpoint
|
|
199
|
+
});
|
|
200
|
+
const logExporter = new (0, _chunkOUCVXP4Gjs.LangWatchLogsExporter)({
|
|
201
|
+
apiKey: langwatch.apiKey,
|
|
202
|
+
endpoint: langwatch.endpoint
|
|
203
|
+
});
|
|
204
|
+
if (langwatch.processorType === "batch") {
|
|
205
|
+
spanProcessors.push(new (0, _sdktracebase.BatchSpanProcessor)(traceExporter));
|
|
206
|
+
logProcessors.push(new (0, _sdklogs.BatchLogRecordProcessor)(logExporter));
|
|
207
|
+
logger.debug(`Added LangWatch ${langwatch.processorType} SpanProcessor and LogRecordProcessor to SDK`);
|
|
208
|
+
} else {
|
|
209
|
+
spanProcessors.push(new (0, _sdktracebase.SimpleSpanProcessor)(traceExporter));
|
|
210
|
+
logProcessors.push(new (0, _sdklogs.SimpleLogRecordProcessor)(logExporter));
|
|
211
|
+
logger.debug(`Added LangWatch ${langwatch.processorType} SpanProcessor and LogRecordProcessor to SDK`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (options.traceExporter) {
|
|
215
|
+
spanProcessors.push(new (0, _sdktracebase.SimpleSpanProcessor)(options.traceExporter));
|
|
216
|
+
logger.debug(`Added user-provided SpanProcessor to SDK`);
|
|
217
|
+
}
|
|
218
|
+
if ((_c = options.spanProcessors) == null ? void 0 : _c.length) {
|
|
219
|
+
spanProcessors.push(...options.spanProcessors);
|
|
220
|
+
logger.debug(`Added user-provided ${options.spanProcessors.length} SpanProcessors to SDK`);
|
|
221
|
+
}
|
|
222
|
+
if ((_d = options.logRecordProcessors) == null ? void 0 : _d.length) {
|
|
223
|
+
logProcessors.push(...options.logRecordProcessors);
|
|
224
|
+
logger.debug(`Added user-provided ${options.logRecordProcessors.length} LogRecordProcessors to SDK`);
|
|
225
|
+
}
|
|
226
|
+
warnIfMisconfigured(options, langwatch, logger);
|
|
227
|
+
const loggerProvider = logProcessors.length ? new (0, _sdklogs.LoggerProvider)({
|
|
228
|
+
resource,
|
|
229
|
+
processors: logProcessors
|
|
230
|
+
}) : void 0;
|
|
231
|
+
if (loggerProvider) {
|
|
232
|
+
logger.debug("Created LangWatch logger provider");
|
|
233
|
+
}
|
|
234
|
+
const sdk = new (0, _sdknode.NodeSDK)({
|
|
235
|
+
resource,
|
|
236
|
+
serviceName: options.serviceName,
|
|
237
|
+
autoDetectResources: options.autoDetectResources,
|
|
238
|
+
contextManager: options.contextManager,
|
|
239
|
+
textMapPropagator: options.textMapPropagator,
|
|
240
|
+
metricReader: options.metricReader,
|
|
241
|
+
views: options.views,
|
|
242
|
+
resourceDetectors: options.resourceDetectors,
|
|
243
|
+
sampler: options.sampler,
|
|
244
|
+
spanProcessors,
|
|
245
|
+
logRecordProcessors: logProcessors,
|
|
246
|
+
spanLimits: options.spanLimits,
|
|
247
|
+
idGenerator: options.idGenerator,
|
|
248
|
+
instrumentations: options.instrumentations
|
|
249
|
+
});
|
|
250
|
+
sdk.start();
|
|
251
|
+
logger.info("NodeSDK started successfully");
|
|
252
|
+
if (loggerProvider) {
|
|
253
|
+
_chunkOUCVXP4Gjs.setLangWatchLoggerProvider.call(void 0, loggerProvider);
|
|
254
|
+
logger.debug("Set LangWatch logger provider");
|
|
255
|
+
}
|
|
256
|
+
if (!((_e = options.advanced) == null ? void 0 : _e.disableAutoShutdown)) {
|
|
257
|
+
process.on("SIGTERM", () => {
|
|
258
|
+
void (async () => {
|
|
259
|
+
logger.debug("SIGTERM received: shutting down OpenTelemetry...");
|
|
260
|
+
try {
|
|
261
|
+
await sdk.shutdown();
|
|
262
|
+
logger.debug("OpenTelemetry shutdown complete");
|
|
263
|
+
} catch (err) {
|
|
264
|
+
logger.error("Error shutting down OpenTelemetry", err);
|
|
265
|
+
} finally {
|
|
266
|
+
process.exit(0);
|
|
267
|
+
}
|
|
268
|
+
})();
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return sdk;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
exports.setupObservability = setupObservability;
|
|
276
|
+
//# sourceMappingURL=index.js.map
|