@hebo-ai/gateway 0.10.3 → 0.10.4
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/lifecycle.js +2 -1
- package/dist/telemetry/span.d.ts +1 -1
- package/dist/telemetry/span.js +6 -4
- package/package.json +1 -1
package/dist/lifecycle.js
CHANGED
|
@@ -53,7 +53,8 @@ export const winterCgHandler = (run, config) => {
|
|
|
53
53
|
requestId: ctx.requestId,
|
|
54
54
|
err: reason ?? ctx.request.signal.reason,
|
|
55
55
|
});
|
|
56
|
-
|
|
56
|
+
const isUpstreamError = reason instanceof GatewayError && reason.code.startsWith("UPSTREAM_");
|
|
57
|
+
span.recordError(reason, realStatus >= 500 || isUpstreamError);
|
|
57
58
|
}
|
|
58
59
|
span.setAttributes({ "http.response.status_code_effective": realStatus });
|
|
59
60
|
if (ctx.operation === "chat" ||
|
package/dist/telemetry/span.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const setSpanTracer: (tracer?: Tracer) => void;
|
|
|
4
4
|
export declare const setSpanEventsEnabled: (level?: TelemetrySignalLevel) => void;
|
|
5
5
|
export declare const startSpan: (name: string, options?: SpanOptions) => import("@opentelemetry/api").Span & {
|
|
6
6
|
runWithContext: <T>(fn: () => Promise<T> | T) => T | Promise<T>;
|
|
7
|
-
recordError: (_error: unknown) => void;
|
|
7
|
+
recordError: (_error: unknown, _setError: boolean) => void;
|
|
8
8
|
finish: () => void;
|
|
9
9
|
isExisting: boolean;
|
|
10
10
|
};
|
package/dist/telemetry/span.js
CHANGED
|
@@ -4,7 +4,7 @@ let spanTracer;
|
|
|
4
4
|
let spanEventsEnabled = false;
|
|
5
5
|
const NOOP_SPAN = {
|
|
6
6
|
runWithContext: (fn) => fn(),
|
|
7
|
-
recordError: (_error) => { },
|
|
7
|
+
recordError: (_error, _setError) => { },
|
|
8
8
|
finish: () => { },
|
|
9
9
|
isExisting: true,
|
|
10
10
|
};
|
|
@@ -22,10 +22,12 @@ export const startSpan = (name, options) => {
|
|
|
22
22
|
const activeSpan = trace.getActiveSpan();
|
|
23
23
|
const span = spanTracer.startSpan(name, { kind: activeSpan ? SpanKind.INTERNAL : SpanKind.SERVER, ...options }, parentContext);
|
|
24
24
|
const runWithContext = (fn) => context.with(trace.setSpan(parentContext, span), fn);
|
|
25
|
-
const recordError = (error) => {
|
|
25
|
+
const recordError = (error, setError) => {
|
|
26
26
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
27
27
|
span.recordException(err);
|
|
28
|
-
|
|
28
|
+
if (setError) {
|
|
29
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
30
|
+
}
|
|
29
31
|
};
|
|
30
32
|
const finish = () => {
|
|
31
33
|
span.end();
|
|
@@ -41,7 +43,7 @@ export const withSpan = async (name, run, options) => {
|
|
|
41
43
|
return await started.runWithContext(run);
|
|
42
44
|
}
|
|
43
45
|
catch (error) {
|
|
44
|
-
started.recordError(error);
|
|
46
|
+
started.recordError(error, true);
|
|
45
47
|
throw error;
|
|
46
48
|
}
|
|
47
49
|
finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebo-ai/gateway",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "AI gateway as a framework. For full control over models, routing & lifecycle. OpenAI /chat/completions, OpenResponses /responses & Anthropic /messages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|