@blaxel/telemetry 0.2.16 → 0.2.17-dev.106

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.
@@ -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
  }
@@ -26,7 +25,6 @@ class OtelSpan {
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
- const ctx = this.retrieveActiveSpanContext();
54
- const span = new OtelSpan(tracer.startSpan(name, otelOptions, ctx));
55
- this.spans.push(span);
56
- return span;
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.16",
3
+ "version": "0.2.17-dev.106",
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.16"
74
+ "@blaxel/core": "0.2.17-dev.106"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@eslint/js": "^9.26.0",