@blaxel/telemetry 0.2.17-dev.124 → 0.2.17-dev.126
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/telemetry.d.ts +8 -0
- package/dist/telemetry.js +33 -0
- package/dist/telemetry_provider.js +8 -0
- package/package.json +2 -2
package/dist/telemetry.d.ts
CHANGED
|
@@ -42,6 +42,14 @@ declare class TelemetryManager {
|
|
|
42
42
|
flush(): Promise<void>;
|
|
43
43
|
getLogger(): Promise<Logger>;
|
|
44
44
|
setupSignalHandler(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Check if telemetry is properly initialized and active
|
|
47
|
+
*/
|
|
48
|
+
get isActive(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Re-initialize telemetry if it was shut down
|
|
51
|
+
*/
|
|
52
|
+
reinitialize(): Promise<void>;
|
|
45
53
|
/**
|
|
46
54
|
* Get resource attributes for OpenTelemetry.
|
|
47
55
|
*/
|
package/dist/telemetry.js
CHANGED
|
@@ -142,6 +142,39 @@ class TelemetryManager {
|
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
+
// Handle uncaughtException differently - log but don't shutdown telemetry
|
|
146
|
+
process.on("uncaughtException", (error) => {
|
|
147
|
+
core_1.logger.error("Uncaught exception:", error);
|
|
148
|
+
// Don't shutdown telemetry for uncaught exceptions
|
|
149
|
+
});
|
|
150
|
+
// Don't listen to 'exit' event as it can be triggered by various things
|
|
151
|
+
// and we don't want to shutdown telemetry unless explicitly requested
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Check if telemetry is properly initialized and active
|
|
155
|
+
*/
|
|
156
|
+
get isActive() {
|
|
157
|
+
return (this.initialized &&
|
|
158
|
+
this.configured &&
|
|
159
|
+
this.nodeTracerProvider !== null &&
|
|
160
|
+
this.meterProvider !== null);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Re-initialize telemetry if it was shut down
|
|
164
|
+
*/
|
|
165
|
+
async reinitialize() {
|
|
166
|
+
if (!this.isActive) {
|
|
167
|
+
core_1.logger.info("Reinitializing telemetry...");
|
|
168
|
+
this.initialized = false;
|
|
169
|
+
this.configured = false;
|
|
170
|
+
this.nodeTracerProvider = null;
|
|
171
|
+
this.meterProvider = null;
|
|
172
|
+
this.loggerProvider = null;
|
|
173
|
+
this.otelLogger = null;
|
|
174
|
+
this.initialize();
|
|
175
|
+
await this.setConfiguration();
|
|
176
|
+
core_1.logger.info("Telemetry reinitialized successfully");
|
|
177
|
+
}
|
|
145
178
|
}
|
|
146
179
|
/**
|
|
147
180
|
* Get resource attributes for OpenTelemetry.
|
|
@@ -34,6 +34,13 @@ class OtelSpan {
|
|
|
34
34
|
}
|
|
35
35
|
class OtelTelemetryProvider {
|
|
36
36
|
startSpan(name, options) {
|
|
37
|
+
// Check if telemetry is active, reinitialize if needed
|
|
38
|
+
core_1.logger.debug("Telemetry is active:", telemetry_1.blaxelTelemetry.isActive);
|
|
39
|
+
if (!telemetry_1.blaxelTelemetry.isActive) {
|
|
40
|
+
core_1.logger.debug("Telemetry not active, reinitializing...");
|
|
41
|
+
// Synchronous reinitialize - just call initialize, setConfiguration will happen async
|
|
42
|
+
telemetry_1.blaxelTelemetry.initialize();
|
|
43
|
+
}
|
|
37
44
|
// Use the tracer from the registered NodeTracerProvider
|
|
38
45
|
const tracer = api_1.trace.getTracer("blaxel");
|
|
39
46
|
// Prepare OpenTelemetry span options
|
|
@@ -55,6 +62,7 @@ class OtelTelemetryProvider {
|
|
|
55
62
|
otelOptions: JSON.stringify(otelOptions),
|
|
56
63
|
activeTraceId: activeSpan?.spanContext().traceId,
|
|
57
64
|
contextKeys: Object.keys(ctx),
|
|
65
|
+
telemetryActive: telemetry_1.blaxelTelemetry.isActive,
|
|
58
66
|
}));
|
|
59
67
|
if (options?.parentContext) {
|
|
60
68
|
// If explicit parent context is provided, use it
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/telemetry",
|
|
3
|
-
"version": "0.2.17-dev.
|
|
3
|
+
"version": "0.2.17-dev.126",
|
|
4
4
|
"description": "Blaxel SDK for TypeScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Blaxel, INC (https://blaxel.ai)",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
72
72
|
"@opentelemetry/sdk-trace-node": "^2.0.0",
|
|
73
73
|
"ai": "^4.3.13",
|
|
74
|
-
"@blaxel/core": "0.2.17-dev.
|
|
74
|
+
"@blaxel/core": "0.2.17-dev.126"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@eslint/js": "^9.26.0",
|