@paid-ai/paid-node 1.0.1-alpha9 → 1.0.1
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/cjs/Client.js +2 -2
- package/dist/cjs/tracing/index.d.ts +3 -2
- package/dist/cjs/tracing/index.js +2 -1
- package/dist/cjs/tracing/tracing.d.ts +7 -1
- package/dist/cjs/tracing/tracing.js +23 -8
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/tracing/index.d.mts +3 -2
- package/dist/esm/tracing/index.mjs +2 -2
- package/dist/esm/tracing/tracing.d.mts +7 -1
- package/dist/esm/tracing/tracing.mjs +22 -8
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/dist/cjs/Client.js
CHANGED
|
@@ -48,8 +48,8 @@ class PaidClient {
|
|
|
48
48
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
49
49
|
"X-Fern-Language": "JavaScript",
|
|
50
50
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
51
|
-
"X-Fern-SDK-Version": "1.0.1
|
|
52
|
-
"User-Agent": "@paid-ai/paid-node/1.0.1
|
|
51
|
+
"X-Fern-SDK-Version": "1.0.1",
|
|
52
|
+
"User-Agent": "@paid-ai/paid-node/1.0.1",
|
|
53
53
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
54
54
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
55
55
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.js";
|
|
1
|
+
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, createPaidSpanProcessors } from "./tracing.js";
|
|
2
2
|
import { signal } from "./signal.js";
|
|
3
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.js";
|
|
4
|
-
export {
|
|
4
|
+
export type { InitializeTracingOptions } from "./tracing.js";
|
|
5
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor, createPaidSpanProcessors };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AISDKSpanProcessor = exports.signal = exports.trace = exports.initializeTracing = exports.getPaidTracerProvider = exports.getPaidTracer = void 0;
|
|
3
|
+
exports.createPaidSpanProcessors = exports.AISDKSpanProcessor = exports.signal = exports.trace = exports.initializeTracing = exports.getPaidTracerProvider = exports.getPaidTracer = void 0;
|
|
4
4
|
const tracing_js_1 = require("./tracing.js");
|
|
5
5
|
Object.defineProperty(exports, "getPaidTracer", { enumerable: true, get: function () { return tracing_js_1.getPaidTracer; } });
|
|
6
6
|
Object.defineProperty(exports, "getPaidTracerProvider", { enumerable: true, get: function () { return tracing_js_1.getPaidTracerProvider; } });
|
|
7
7
|
Object.defineProperty(exports, "initializeTracing", { enumerable: true, get: function () { return tracing_js_1.initializeTracing; } });
|
|
8
8
|
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return tracing_js_1.trace; } });
|
|
9
|
+
Object.defineProperty(exports, "createPaidSpanProcessors", { enumerable: true, get: function () { return tracing_js_1.createPaidSpanProcessors; } });
|
|
9
10
|
const signal_js_1 = require("./signal.js");
|
|
10
11
|
Object.defineProperty(exports, "signal", { enumerable: true, get: function () { return signal_js_1.signal; } });
|
|
11
12
|
const aiSdkSpanProcessor_js_1 = require("./aiSdkSpanProcessor.js");
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Tracer } from "@opentelemetry/api";
|
|
2
|
+
import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
2
3
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
4
|
+
export interface InitializeTracingOptions {
|
|
5
|
+
collectorEndpoint?: string;
|
|
6
|
+
registerGlobal?: boolean;
|
|
7
|
+
}
|
|
3
8
|
export declare function getToken(): string | undefined;
|
|
4
9
|
export declare function getPaidTracerProvider(): NodeTracerProvider | undefined;
|
|
5
10
|
export declare function getPaidTracer(): Tracer | undefined;
|
|
6
|
-
export declare function
|
|
11
|
+
export declare function createPaidSpanProcessors(apiKey: string, collectorEndpoint?: string): SpanProcessor[];
|
|
12
|
+
export declare function initializeTracing(apiKey?: string, options?: InitializeTracingOptions): void;
|
|
7
13
|
export declare function trace<F extends (...args: any[]) => any>(options: {
|
|
8
14
|
externalCustomerId: string;
|
|
9
15
|
externalProductId?: string;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getToken = getToken;
|
|
13
13
|
exports.getPaidTracerProvider = getPaidTracerProvider;
|
|
14
14
|
exports.getPaidTracer = getPaidTracer;
|
|
15
|
+
exports.createPaidSpanProcessors = createPaidSpanProcessors;
|
|
15
16
|
exports.initializeTracing = initializeTracing;
|
|
16
17
|
exports.trace = trace;
|
|
17
18
|
const api_1 = require("@opentelemetry/api");
|
|
@@ -49,7 +50,12 @@ const setupGracefulShutdown = (shuttable) => {
|
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
};
|
|
52
|
-
function
|
|
53
|
+
function createPaidSpanProcessors(apiKey, collectorEndpoint) {
|
|
54
|
+
const url = collectorEndpoint || DEFAULT_COLLECTOR_ENDPOINT;
|
|
55
|
+
const exporter = new exporter_trace_otlp_http_1.OTLPTraceExporter({ url, headers: { Authorization: `Bearer ${apiKey}` } });
|
|
56
|
+
return [new spanProcessor_js_1.PaidSpanProcessor(), new aiSdkSpanProcessor_js_1.AISDKSpanProcessor(), new sdk_trace_node_1.SimpleSpanProcessor(exporter)];
|
|
57
|
+
}
|
|
58
|
+
function initializeTracing(apiKey, options) {
|
|
53
59
|
const paidEnabled = (process.env.PAID_ENABLED || "true") !== "false";
|
|
54
60
|
if (!paidEnabled) {
|
|
55
61
|
console.info("Paid tracing is disabled via PAID_ENABLED environment variable");
|
|
@@ -71,6 +77,7 @@ function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
71
77
|
else {
|
|
72
78
|
paidApiToken = apiKey;
|
|
73
79
|
}
|
|
80
|
+
const { collectorEndpoint, registerGlobal = false } = options || {};
|
|
74
81
|
const url = collectorEndpoint || DEFAULT_COLLECTOR_ENDPOINT;
|
|
75
82
|
const exporter = new exporter_trace_otlp_http_1.OTLPTraceExporter({ url, headers: { Authorization: `Bearer ${paidApiToken}` } });
|
|
76
83
|
const spanProcessor = new sdk_trace_node_1.SimpleSpanProcessor(exporter);
|
|
@@ -79,13 +86,21 @@ function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
79
86
|
paidTracerProvider = new sdk_trace_node_1.NodeTracerProvider({
|
|
80
87
|
spanProcessors: [new spanProcessor_js_1.PaidSpanProcessor(), new aiSdkSpanProcessor_js_1.AISDKSpanProcessor(), spanProcessor],
|
|
81
88
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
if (registerGlobal) {
|
|
90
|
+
// Register the provider globally so that any tracer (including the AI SDK's
|
|
91
|
+
// `trace.getTracer("ai")`) routes spans through our span processors.
|
|
92
|
+
// This also sets up an AsyncLocalStorageContextManager for context propagation.
|
|
93
|
+
paidTracerProvider.register();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// Set up context propagation without registering the provider globally.
|
|
97
|
+
// This gives us async parent-child linking via AsyncLocalStorage
|
|
98
|
+
// without polluting the global trace provider.
|
|
99
|
+
const contextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
|
|
100
|
+
contextManager.enable();
|
|
101
|
+
if (!api_1.context.setGlobalContextManager(contextManager)) {
|
|
102
|
+
contextManager.disable();
|
|
103
|
+
}
|
|
89
104
|
}
|
|
90
105
|
paidTracer = paidTracerProvider.getTracer("paid.node");
|
|
91
106
|
setupGracefulShutdown(spanProcessor);
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.1
|
|
1
|
+
export declare const SDK_VERSION = "1.0.1";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.mjs
CHANGED
|
@@ -12,8 +12,8 @@ export class PaidClient {
|
|
|
12
12
|
this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
|
|
13
13
|
"X-Fern-Language": "JavaScript",
|
|
14
14
|
"X-Fern-SDK-Name": "@paid-ai/paid-node",
|
|
15
|
-
"X-Fern-SDK-Version": "1.0.1
|
|
16
|
-
"User-Agent": "@paid-ai/paid-node/1.0.1
|
|
15
|
+
"X-Fern-SDK-Version": "1.0.1",
|
|
16
|
+
"User-Agent": "@paid-ai/paid-node/1.0.1",
|
|
17
17
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
18
18
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
19
19
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.mjs";
|
|
1
|
+
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, createPaidSpanProcessors } from "./tracing.mjs";
|
|
2
2
|
import { signal } from "./signal.mjs";
|
|
3
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.mjs";
|
|
4
|
-
export {
|
|
4
|
+
export type { InitializeTracingOptions } from "./tracing.mjs";
|
|
5
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor, createPaidSpanProcessors };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace } from "./tracing.mjs";
|
|
1
|
+
import { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, createPaidSpanProcessors } from "./tracing.mjs";
|
|
2
2
|
import { signal } from "./signal.mjs";
|
|
3
3
|
import { AISDKSpanProcessor } from "./aiSdkSpanProcessor.mjs";
|
|
4
|
-
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor };
|
|
4
|
+
export { getPaidTracer, getPaidTracerProvider, initializeTracing, trace, signal, AISDKSpanProcessor, createPaidSpanProcessors };
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Tracer } from "@opentelemetry/api";
|
|
2
|
+
import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
2
3
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
4
|
+
export interface InitializeTracingOptions {
|
|
5
|
+
collectorEndpoint?: string;
|
|
6
|
+
registerGlobal?: boolean;
|
|
7
|
+
}
|
|
3
8
|
export declare function getToken(): string | undefined;
|
|
4
9
|
export declare function getPaidTracerProvider(): NodeTracerProvider | undefined;
|
|
5
10
|
export declare function getPaidTracer(): Tracer | undefined;
|
|
6
|
-
export declare function
|
|
11
|
+
export declare function createPaidSpanProcessors(apiKey: string, collectorEndpoint?: string): SpanProcessor[];
|
|
12
|
+
export declare function initializeTracing(apiKey?: string, options?: InitializeTracingOptions): void;
|
|
7
13
|
export declare function trace<F extends (...args: any[]) => any>(options: {
|
|
8
14
|
externalCustomerId: string;
|
|
9
15
|
externalProductId?: string;
|
|
@@ -42,7 +42,12 @@ const setupGracefulShutdown = (shuttable) => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
};
|
|
45
|
-
export function
|
|
45
|
+
export function createPaidSpanProcessors(apiKey, collectorEndpoint) {
|
|
46
|
+
const url = collectorEndpoint || DEFAULT_COLLECTOR_ENDPOINT;
|
|
47
|
+
const exporter = new OTLPTraceExporter({ url, headers: { Authorization: `Bearer ${apiKey}` } });
|
|
48
|
+
return [new PaidSpanProcessor(), new AISDKSpanProcessor(), new SimpleSpanProcessor(exporter)];
|
|
49
|
+
}
|
|
50
|
+
export function initializeTracing(apiKey, options) {
|
|
46
51
|
const paidEnabled = (process.env.PAID_ENABLED || "true") !== "false";
|
|
47
52
|
if (!paidEnabled) {
|
|
48
53
|
console.info("Paid tracing is disabled via PAID_ENABLED environment variable");
|
|
@@ -64,6 +69,7 @@ export function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
64
69
|
else {
|
|
65
70
|
paidApiToken = apiKey;
|
|
66
71
|
}
|
|
72
|
+
const { collectorEndpoint, registerGlobal = false } = options || {};
|
|
67
73
|
const url = collectorEndpoint || DEFAULT_COLLECTOR_ENDPOINT;
|
|
68
74
|
const exporter = new OTLPTraceExporter({ url, headers: { Authorization: `Bearer ${paidApiToken}` } });
|
|
69
75
|
const spanProcessor = new SimpleSpanProcessor(exporter);
|
|
@@ -72,13 +78,21 @@ export function initializeTracing(apiKey, collectorEndpoint) {
|
|
|
72
78
|
paidTracerProvider = new NodeTracerProvider({
|
|
73
79
|
spanProcessors: [new PaidSpanProcessor(), new AISDKSpanProcessor(), spanProcessor],
|
|
74
80
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
if (registerGlobal) {
|
|
82
|
+
// Register the provider globally so that any tracer (including the AI SDK's
|
|
83
|
+
// `trace.getTracer("ai")`) routes spans through our span processors.
|
|
84
|
+
// This also sets up an AsyncLocalStorageContextManager for context propagation.
|
|
85
|
+
paidTracerProvider.register();
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// Set up context propagation without registering the provider globally.
|
|
89
|
+
// This gives us async parent-child linking via AsyncLocalStorage
|
|
90
|
+
// without polluting the global trace provider.
|
|
91
|
+
const contextManager = new AsyncLocalStorageContextManager();
|
|
92
|
+
contextManager.enable();
|
|
93
|
+
if (!context.setGlobalContextManager(contextManager)) {
|
|
94
|
+
contextManager.disable();
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
97
|
paidTracer = paidTracerProvider.getTracer("paid.node");
|
|
84
98
|
setupGracefulShutdown(spanProcessor);
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.1
|
|
1
|
+
export declare const SDK_VERSION = "1.0.1";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.1
|
|
1
|
+
export const SDK_VERSION = "1.0.1";
|