tracebeam-sdk 0.1.0 → 0.2.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/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +735 -377
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +722 -376
- package/dist/index.mjs.map +1 -1
- package/dist/integrations/express.d.mts +26 -2
- package/dist/integrations/express.d.ts +26 -2
- package/dist/integrations/express.js +30 -0
- package/dist/integrations/express.js.map +1 -1
- package/dist/integrations/express.mjs +29 -0
- package/dist/integrations/express.mjs.map +1 -1
- package/dist/integrations/fastify.d.mts +1 -1
- package/dist/integrations/fastify.d.ts +1 -1
- package/dist/integrations/fastify.js.map +1 -1
- package/dist/integrations/fastify.mjs.map +1 -1
- package/dist/{client-CaHega3m.d.mts → sdk-bh44OWR9.d.mts} +11 -80
- package/dist/{client-CaHega3m.d.ts → sdk-bh44OWR9.d.ts} +11 -80
- package/package.json +16 -7
|
@@ -53,6 +53,8 @@ interface Event {
|
|
|
53
53
|
tags: Tags;
|
|
54
54
|
/** Additional context data */
|
|
55
55
|
extra: Extra;
|
|
56
|
+
/** Request latency in milliseconds */
|
|
57
|
+
latency?: number;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Options for capture methods
|
|
@@ -66,6 +68,8 @@ interface CaptureOptions {
|
|
|
66
68
|
extra?: Extra;
|
|
67
69
|
/** Custom timestamp (ISO 8601) */
|
|
68
70
|
timestamp?: string;
|
|
71
|
+
/** Request latency in milliseconds */
|
|
72
|
+
latency?: number;
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
75
|
* Batch payload sent to Ingest API
|
|
@@ -97,111 +101,38 @@ interface TransportErrorResponse {
|
|
|
97
101
|
type TransportResponse = TransportSuccessResponse | TransportErrorResponse;
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
|
-
* TraceBeamSDK client for capturing and sending events
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* // Initialize from environment variables
|
|
105
|
-
* const sdk = TraceBeamSDK.fromEnv();
|
|
106
|
-
*
|
|
107
|
-
* // Capture an exception
|
|
108
|
-
* try {
|
|
109
|
-
* doSomething();
|
|
110
|
-
* } catch (error) {
|
|
111
|
-
* sdk.captureException(error);
|
|
112
|
-
* }
|
|
113
|
-
*
|
|
114
|
-
* // Capture a message
|
|
115
|
-
* sdk.captureMessage('User signup completed', {
|
|
116
|
-
* level: 'info',
|
|
117
|
-
* tags: { feature: 'auth' }
|
|
118
|
-
* });
|
|
119
|
-
*
|
|
120
|
-
* // Graceful shutdown
|
|
121
|
-
* await sdk.close();
|
|
122
|
-
* ```
|
|
104
|
+
* TraceBeamSDK client for capturing and sending events via OTLP
|
|
123
105
|
*/
|
|
124
106
|
declare class TraceBeamSDK {
|
|
125
107
|
private readonly config;
|
|
126
|
-
private
|
|
127
|
-
private
|
|
108
|
+
private provider;
|
|
109
|
+
private tracer;
|
|
110
|
+
private isInitialized;
|
|
128
111
|
private globalTags;
|
|
129
112
|
private globalExtra;
|
|
130
113
|
private userId;
|
|
131
|
-
private isInitialized;
|
|
132
114
|
/**
|
|
133
115
|
* Create SDK instance from configuration
|
|
134
116
|
*/
|
|
135
117
|
constructor(config: TraceBeamConfig);
|
|
136
|
-
/**
|
|
137
|
-
* Create SDK instance from environment variables
|
|
138
|
-
*
|
|
139
|
-
* Required env vars:
|
|
140
|
-
* - TRACEBEAM_API_KEY
|
|
141
|
-
* - TRACEBEAM_PROJECT_ID
|
|
142
|
-
*
|
|
143
|
-
* Optional env vars:
|
|
144
|
-
* - TRACEBEAM_ENVIRONMENT (default: 'development')
|
|
145
|
-
* - TRACEBEAM_ENDPOINT (default: 'https://ingest.tracebeam.io')
|
|
146
|
-
* - TRACEBEAM_BATCH_SIZE (default: 100)
|
|
147
|
-
* - TRACEBEAM_FLUSH_INTERVAL (default: 5000)
|
|
148
|
-
* - TRACEBEAM_HTTP_TIMEOUT (default: 10000)
|
|
149
|
-
* - TRACEBEAM_MAX_QUEUE_SIZE (default: 10000)
|
|
150
|
-
* - TRACEBEAM_SAMPLE_RATE (default: 1.0)
|
|
151
|
-
* - TRACEBEAM_DEBUG (default: false)
|
|
152
|
-
*/
|
|
153
118
|
static fromEnv(): TraceBeamSDK;
|
|
154
119
|
/**
|
|
155
120
|
* Capture an exception/error
|
|
156
|
-
* Returns immediately (non-blocking)
|
|
157
121
|
*/
|
|
158
|
-
captureException(error: Error | string, options?: CaptureOptions): void;
|
|
122
|
+
captureException(error: Error | string | unknown, options?: CaptureOptions): void;
|
|
159
123
|
/**
|
|
160
|
-
* Capture a message
|
|
161
|
-
* Returns immediately (non-blocking)
|
|
124
|
+
* Capture a message
|
|
162
125
|
*/
|
|
163
126
|
captureMessage(message: string, options?: CaptureOptions): void;
|
|
164
|
-
/**
|
|
165
|
-
* Set the current user ID
|
|
166
|
-
* Will be included in all subsequent events
|
|
167
|
-
*/
|
|
168
127
|
setUser(userId: string | null): void;
|
|
169
|
-
/**
|
|
170
|
-
* Set a global tag
|
|
171
|
-
* Will be included in all subsequent events
|
|
172
|
-
*/
|
|
173
128
|
setTag(key: string, value: string): void;
|
|
174
|
-
/**
|
|
175
|
-
* Set multiple global tags
|
|
176
|
-
* Will be included in all subsequent events
|
|
177
|
-
*/
|
|
178
129
|
setTags(tags: Tags): void;
|
|
179
|
-
/**
|
|
180
|
-
* Set global extra context
|
|
181
|
-
* Will be included in all subsequent events
|
|
182
|
-
*/
|
|
183
130
|
setExtra(key: string, value: unknown): void;
|
|
184
|
-
/**
|
|
185
|
-
* Set multiple global extra context values
|
|
186
|
-
*/
|
|
187
131
|
setExtras(extras: Extra): void;
|
|
188
|
-
/**
|
|
189
|
-
* Manually flush queued events
|
|
190
|
-
* Call this to ensure events are sent before process exit
|
|
191
|
-
*/
|
|
192
132
|
flush(): Promise<void>;
|
|
193
|
-
/**
|
|
194
|
-
* Graceful shutdown
|
|
195
|
-
* Flushes remaining events and stops background workers
|
|
196
|
-
*/
|
|
197
133
|
close(): Promise<void>;
|
|
198
|
-
/**
|
|
199
|
-
* Check if SDK is active and can capture events
|
|
200
|
-
*/
|
|
201
134
|
isActive(): boolean;
|
|
202
135
|
private canCapture;
|
|
203
|
-
private createEventWithContext;
|
|
204
|
-
private handleFlush;
|
|
205
136
|
}
|
|
206
137
|
|
|
207
|
-
export { type CaptureOptions as C, type
|
|
138
|
+
export { type CaptureOptions as C, type EventLevel as E, type TraceBeamConfig as T, TraceBeamSDK as a, type Tags as b, type Extra as c, type Event as d, type EventBatch as e, type TransportSuccessResponse as f, type TransportErrorResponse as g, type TransportResponse as h };
|
|
@@ -53,6 +53,8 @@ interface Event {
|
|
|
53
53
|
tags: Tags;
|
|
54
54
|
/** Additional context data */
|
|
55
55
|
extra: Extra;
|
|
56
|
+
/** Request latency in milliseconds */
|
|
57
|
+
latency?: number;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Options for capture methods
|
|
@@ -66,6 +68,8 @@ interface CaptureOptions {
|
|
|
66
68
|
extra?: Extra;
|
|
67
69
|
/** Custom timestamp (ISO 8601) */
|
|
68
70
|
timestamp?: string;
|
|
71
|
+
/** Request latency in milliseconds */
|
|
72
|
+
latency?: number;
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
75
|
* Batch payload sent to Ingest API
|
|
@@ -97,111 +101,38 @@ interface TransportErrorResponse {
|
|
|
97
101
|
type TransportResponse = TransportSuccessResponse | TransportErrorResponse;
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
|
-
* TraceBeamSDK client for capturing and sending events
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* // Initialize from environment variables
|
|
105
|
-
* const sdk = TraceBeamSDK.fromEnv();
|
|
106
|
-
*
|
|
107
|
-
* // Capture an exception
|
|
108
|
-
* try {
|
|
109
|
-
* doSomething();
|
|
110
|
-
* } catch (error) {
|
|
111
|
-
* sdk.captureException(error);
|
|
112
|
-
* }
|
|
113
|
-
*
|
|
114
|
-
* // Capture a message
|
|
115
|
-
* sdk.captureMessage('User signup completed', {
|
|
116
|
-
* level: 'info',
|
|
117
|
-
* tags: { feature: 'auth' }
|
|
118
|
-
* });
|
|
119
|
-
*
|
|
120
|
-
* // Graceful shutdown
|
|
121
|
-
* await sdk.close();
|
|
122
|
-
* ```
|
|
104
|
+
* TraceBeamSDK client for capturing and sending events via OTLP
|
|
123
105
|
*/
|
|
124
106
|
declare class TraceBeamSDK {
|
|
125
107
|
private readonly config;
|
|
126
|
-
private
|
|
127
|
-
private
|
|
108
|
+
private provider;
|
|
109
|
+
private tracer;
|
|
110
|
+
private isInitialized;
|
|
128
111
|
private globalTags;
|
|
129
112
|
private globalExtra;
|
|
130
113
|
private userId;
|
|
131
|
-
private isInitialized;
|
|
132
114
|
/**
|
|
133
115
|
* Create SDK instance from configuration
|
|
134
116
|
*/
|
|
135
117
|
constructor(config: TraceBeamConfig);
|
|
136
|
-
/**
|
|
137
|
-
* Create SDK instance from environment variables
|
|
138
|
-
*
|
|
139
|
-
* Required env vars:
|
|
140
|
-
* - TRACEBEAM_API_KEY
|
|
141
|
-
* - TRACEBEAM_PROJECT_ID
|
|
142
|
-
*
|
|
143
|
-
* Optional env vars:
|
|
144
|
-
* - TRACEBEAM_ENVIRONMENT (default: 'development')
|
|
145
|
-
* - TRACEBEAM_ENDPOINT (default: 'https://ingest.tracebeam.io')
|
|
146
|
-
* - TRACEBEAM_BATCH_SIZE (default: 100)
|
|
147
|
-
* - TRACEBEAM_FLUSH_INTERVAL (default: 5000)
|
|
148
|
-
* - TRACEBEAM_HTTP_TIMEOUT (default: 10000)
|
|
149
|
-
* - TRACEBEAM_MAX_QUEUE_SIZE (default: 10000)
|
|
150
|
-
* - TRACEBEAM_SAMPLE_RATE (default: 1.0)
|
|
151
|
-
* - TRACEBEAM_DEBUG (default: false)
|
|
152
|
-
*/
|
|
153
118
|
static fromEnv(): TraceBeamSDK;
|
|
154
119
|
/**
|
|
155
120
|
* Capture an exception/error
|
|
156
|
-
* Returns immediately (non-blocking)
|
|
157
121
|
*/
|
|
158
|
-
captureException(error: Error | string, options?: CaptureOptions): void;
|
|
122
|
+
captureException(error: Error | string | unknown, options?: CaptureOptions): void;
|
|
159
123
|
/**
|
|
160
|
-
* Capture a message
|
|
161
|
-
* Returns immediately (non-blocking)
|
|
124
|
+
* Capture a message
|
|
162
125
|
*/
|
|
163
126
|
captureMessage(message: string, options?: CaptureOptions): void;
|
|
164
|
-
/**
|
|
165
|
-
* Set the current user ID
|
|
166
|
-
* Will be included in all subsequent events
|
|
167
|
-
*/
|
|
168
127
|
setUser(userId: string | null): void;
|
|
169
|
-
/**
|
|
170
|
-
* Set a global tag
|
|
171
|
-
* Will be included in all subsequent events
|
|
172
|
-
*/
|
|
173
128
|
setTag(key: string, value: string): void;
|
|
174
|
-
/**
|
|
175
|
-
* Set multiple global tags
|
|
176
|
-
* Will be included in all subsequent events
|
|
177
|
-
*/
|
|
178
129
|
setTags(tags: Tags): void;
|
|
179
|
-
/**
|
|
180
|
-
* Set global extra context
|
|
181
|
-
* Will be included in all subsequent events
|
|
182
|
-
*/
|
|
183
130
|
setExtra(key: string, value: unknown): void;
|
|
184
|
-
/**
|
|
185
|
-
* Set multiple global extra context values
|
|
186
|
-
*/
|
|
187
131
|
setExtras(extras: Extra): void;
|
|
188
|
-
/**
|
|
189
|
-
* Manually flush queued events
|
|
190
|
-
* Call this to ensure events are sent before process exit
|
|
191
|
-
*/
|
|
192
132
|
flush(): Promise<void>;
|
|
193
|
-
/**
|
|
194
|
-
* Graceful shutdown
|
|
195
|
-
* Flushes remaining events and stops background workers
|
|
196
|
-
*/
|
|
197
133
|
close(): Promise<void>;
|
|
198
|
-
/**
|
|
199
|
-
* Check if SDK is active and can capture events
|
|
200
|
-
*/
|
|
201
134
|
isActive(): boolean;
|
|
202
135
|
private canCapture;
|
|
203
|
-
private createEventWithContext;
|
|
204
|
-
private handleFlush;
|
|
205
136
|
}
|
|
206
137
|
|
|
207
|
-
export { type CaptureOptions as C, type
|
|
138
|
+
export { type CaptureOptions as C, type EventLevel as E, type TraceBeamConfig as T, TraceBeamSDK as a, type Tags as b, type Extra as c, type Event as d, type EventBatch as e, type TransportSuccessResponse as f, type TransportErrorResponse as g, type TransportResponse as h };
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tracebeam-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Node.js SDK for TraceBeam API Observability Platform",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./integrations/express": {
|
|
15
15
|
"types": "./dist/integrations/express.d.ts",
|
|
16
16
|
"import": "./dist/integrations/express.js",
|
|
17
|
-
"require": "./dist/integrations/express.
|
|
17
|
+
"require": "./dist/integrations/express.js"
|
|
18
18
|
},
|
|
19
19
|
"./integrations/fastify": {
|
|
20
20
|
"types": "./dist/integrations/fastify.d.ts",
|
|
21
21
|
"import": "./dist/integrations/fastify.js",
|
|
22
|
-
"require": "./dist/integrations/fastify.
|
|
22
|
+
"require": "./dist/integrations/fastify.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vitest": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"express": "^
|
|
56
|
+
"express": "^5.2.1",
|
|
57
57
|
"fastify": "^4.0.0 || ^5.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
@@ -63,5 +63,14 @@
|
|
|
63
63
|
"fastify": {
|
|
64
64
|
"optional": true
|
|
65
65
|
}
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@opentelemetry/api": "^1.9.0",
|
|
69
|
+
"@opentelemetry/auto-instrumentations-node": "^0.68.0",
|
|
70
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.210.0",
|
|
71
|
+
"@opentelemetry/resources": "^2.4.0",
|
|
72
|
+
"@opentelemetry/sdk-trace-node": "^2.4.0",
|
|
73
|
+
"@opentelemetry/semantic-conventions": "^1.39.0",
|
|
74
|
+
"@types/express": "^5.0.6"
|
|
66
75
|
}
|
|
67
|
-
}
|
|
76
|
+
}
|