@blaxel/telemetry 0.2.18 → 0.2.19-dev.159
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.js +1 -0
- package/dist/telemetry_provider.d.ts +0 -2
- package/dist/telemetry_provider.js +11 -17
- package/package.json +2 -2
package/dist/telemetry.js
CHANGED
|
@@ -195,6 +195,7 @@ class TelemetryManager {
|
|
|
195
195
|
core_1.telemetryRegistry.registerProvider(new telemetry_provider_1.OtelTelemetryProvider());
|
|
196
196
|
const httpInstrumentation = new instrumentation_http_1.HttpInstrumentation({
|
|
197
197
|
requireParentforOutgoingSpans: true,
|
|
198
|
+
requireParentforIncomingSpans: true,
|
|
198
199
|
});
|
|
199
200
|
(0, instrumentation_1.registerInstrumentations)({
|
|
200
201
|
instrumentations: [httpInstrumentation],
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { BlaxelSpan, BlaxelSpanOptions, BlaxelTelemetryProvider } from "@blaxel/core";
|
|
2
2
|
export declare class OtelTelemetryProvider implements BlaxelTelemetryProvider {
|
|
3
|
-
private spans;
|
|
4
|
-
retrieveActiveSpanContext(): import("@opentelemetry/api").Context;
|
|
5
3
|
startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
6
4
|
flush(): Promise<void>;
|
|
7
5
|
}
|
|
@@ -5,7 +5,6 @@ const api_1 = require("@opentelemetry/api");
|
|
|
5
5
|
const telemetry_1 = require("./telemetry");
|
|
6
6
|
class OtelSpan {
|
|
7
7
|
span;
|
|
8
|
-
closed = false;
|
|
9
8
|
constructor(span) {
|
|
10
9
|
this.span = span;
|
|
11
10
|
}
|
|
@@ -21,12 +20,11 @@ class OtelSpan {
|
|
|
21
20
|
}
|
|
22
21
|
setStatus(status, message) {
|
|
23
22
|
this.span.setStatus({
|
|
24
|
-
code: status ===
|
|
23
|
+
code: status === "ok" ? api_1.SpanStatusCode.OK : api_1.SpanStatusCode.ERROR,
|
|
25
24
|
message,
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
end() {
|
|
29
|
-
this.closed = true;
|
|
30
28
|
this.span.end();
|
|
31
29
|
}
|
|
32
30
|
getContext() {
|
|
@@ -34,26 +32,22 @@ class OtelSpan {
|
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
class OtelTelemetryProvider {
|
|
37
|
-
spans = [];
|
|
38
|
-
retrieveActiveSpanContext() {
|
|
39
|
-
for (let i = this.spans.length - 1; i >= 0; i--) {
|
|
40
|
-
const span = this.spans[i];
|
|
41
|
-
if (!span.closed) {
|
|
42
|
-
return api_1.trace.setSpanContext(api_1.ROOT_CONTEXT, span.getContext());
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return api_1.context.active();
|
|
46
|
-
}
|
|
47
35
|
startSpan(name, options) {
|
|
36
|
+
// Use the tracer from the registered NodeTracerProvider
|
|
48
37
|
const tracer = api_1.trace.getTracer("blaxel");
|
|
38
|
+
// Prepare OpenTelemetry span options
|
|
49
39
|
const otelOptions = {
|
|
50
40
|
attributes: options?.attributes,
|
|
51
41
|
root: options?.isRoot,
|
|
52
42
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
// Handle parent context if provided
|
|
44
|
+
let ctx = api_1.context.active();
|
|
45
|
+
if (options?.parentContext) {
|
|
46
|
+
ctx = options.parentContext;
|
|
47
|
+
}
|
|
48
|
+
// Start the span
|
|
49
|
+
const span = tracer.startSpan(name, otelOptions, ctx);
|
|
50
|
+
return new OtelSpan(span);
|
|
57
51
|
}
|
|
58
52
|
async flush() {
|
|
59
53
|
await telemetry_1.blaxelTelemetry.flush();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/telemetry",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19-dev.159",
|
|
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.
|
|
74
|
+
"@blaxel/core": "0.2.19-dev.159"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@eslint/js": "^9.26.0",
|