@blaxel/core 0.2.4-dev.70 → 0.2.4-dev.72

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.
@@ -68,7 +68,9 @@ class BlJobWrapper {
68
68
  }
69
69
  const blStartJob = (func) => {
70
70
  const job = new BlJobWrapper();
71
- job.start(func).catch((error) => {
71
+ job.start(func).then(async () => {
72
+ await (0, telemetry_js_1.flush)();
73
+ }).catch((error) => {
72
74
  console.error('Job execution failed:', error);
73
75
  process.exit(1);
74
76
  });
@@ -32,6 +32,8 @@ export interface BlaxelSpan {
32
32
  export interface BlaxelTelemetryProvider {
33
33
  /** Create a new span */
34
34
  startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
35
+ /** Flush the telemetry provider */
36
+ flush(): Promise<void>;
35
37
  }
36
38
  /**
37
39
  * Registry for managing the global telemetry provider
@@ -55,5 +57,6 @@ export declare const telemetryRegistry: TelemetryRegistry;
55
57
  * Create a span with the registered provider
56
58
  */
57
59
  export declare function startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
58
- export declare function withSpan<T>(name: string, fn: () => T, options?: BlaxelSpanOptions): T;
60
+ export declare function withSpan<T>(name: string, fn: () => Promise<T>, options?: BlaxelSpanOptions): Promise<T>;
61
+ export declare function flush(): Promise<void>;
59
62
  export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.telemetryRegistry = void 0;
5
5
  exports.startSpan = startSpan;
6
6
  exports.withSpan = withSpan;
7
+ exports.flush = flush;
7
8
  /**
8
9
  * No-operation implementation of Span
9
10
  */
@@ -22,6 +23,9 @@ class NoopTelemetryProvider {
22
23
  startSpan() {
23
24
  return new NoopSpan();
24
25
  }
26
+ flush() {
27
+ return Promise.resolve();
28
+ }
25
29
  }
26
30
  /**
27
31
  * Registry for managing the global telemetry provider
@@ -58,10 +62,10 @@ exports.telemetryRegistry = TelemetryRegistry.getInstance();
58
62
  function startSpan(name, options) {
59
63
  return exports.telemetryRegistry.getProvider().startSpan(name, options);
60
64
  }
61
- function withSpan(name, fn, options) {
65
+ async function withSpan(name, fn, options) {
62
66
  const span = startSpan(name, options);
63
67
  try {
64
- const result = fn();
68
+ const result = await fn();
65
69
  span.end();
66
70
  return result;
67
71
  }
@@ -71,3 +75,6 @@ function withSpan(name, fn, options) {
71
75
  throw error;
72
76
  }
73
77
  }
78
+ async function flush() {
79
+ await exports.telemetryRegistry.getProvider().flush();
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.4-dev.70",
3
+ "version": "0.2.4-dev.72",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",