@blaxel/telemetry 0.2.0-dev1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Beamlit, Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { originalLogger } from "./logger";
2
+ import { blaxelTelemetry } from "./telemetry";
3
+ export { blaxelTelemetry, originalLogger };
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.originalLogger = exports.blaxelTelemetry = void 0;
4
+ const logger_1 = require("./logger");
5
+ Object.defineProperty(exports, "originalLogger", { enumerable: true, get: function () { return logger_1.originalLogger; } });
6
+ const telemetry_1 = require("./telemetry");
7
+ Object.defineProperty(exports, "blaxelTelemetry", { enumerable: true, get: function () { return telemetry_1.blaxelTelemetry; } });
8
+ telemetry_1.blaxelTelemetry.initialize();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // export type InstrumentationInfo = {
3
+ // modulePath: string;
4
+ // className: string;
5
+ // requiredPackages: string[]; // At least one package is required
6
+ // ignoreIfPackages?: string[];
7
+ // init?: (instrumentor: any) => void;
8
+ // };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ // export const instrumentationMap: Record<string, InstrumentationInfo> = {
11
+ // express: {
12
+ // modulePath: "@opentelemetry/instrumentation-express",
13
+ // className: "ExpressInstrumentation",
14
+ // requiredPackages: ["express"],
15
+ // ignoreIfPackages: ["fastify"],
16
+ // },
17
+ // fastify: {
18
+ // modulePath: "@opentelemetry/instrumentation-fastify",
19
+ // className: "FastifyInstrumentation",
20
+ // requiredPackages: ["fastify"],
21
+ // },
22
+ // anthropic: {
23
+ // modulePath: "@traceloop/instrumentation-anthropic",
24
+ // className: "AnthropicInstrumentation",
25
+ // requiredPackages: ["anthropic-ai/sdk"],
26
+ // },
27
+ // azure: {
28
+ // modulePath: "@traceloop/instrumentation-azure",
29
+ // className: "AzureInstrumentation",
30
+ // requiredPackages: ["azure/openai"],
31
+ // },
32
+ // bedrock: {
33
+ // modulePath: "@traceloop/instrumentation-bedrock",
34
+ // className: "BedrockInstrumentation",
35
+ // requiredPackages: ["aws-sdk/client-bedrock-runtime"],
36
+ // },
37
+ // chromadb: {
38
+ // modulePath: "@traceloop/instrumentation-chromadb",
39
+ // className: "ChromaDBInstrumentation",
40
+ // requiredPackages: ["chromadb"],
41
+ // },
42
+ // cohere: {
43
+ // modulePath: "@traceloop/instrumentation-cohere",
44
+ // className: "CohereInstrumentation",
45
+ // requiredPackages: ["cohere-js"],
46
+ // },
47
+ // langchain: {
48
+ // modulePath: "@traceloop/instrumentation-langchain",
49
+ // className: "LangChainInstrumentation",
50
+ // requiredPackages: [
51
+ // "langchain",
52
+ // "@langchain/core",
53
+ // "@langchain/community",
54
+ // "@langchain/langgraph",
55
+ // ],
56
+ // init: (instrumentor: any) => {
57
+ // // eslint-disable-next-line @typescript-eslint/no-require-imports
58
+ // const module = require("./langchain.js") as { [key: string]: any };
59
+ // // eslint-disable-next-line @typescript-eslint/no-unsafe-call
60
+ // module.langchain(instrumentor);
61
+ // },
62
+ // },
63
+ // llamaindex: {
64
+ // modulePath: "@traceloop/instrumentation-llamaindex",
65
+ // className: "LlamaIndexInstrumentation",
66
+ // requiredPackages: ["llamaindex"],
67
+ // },
68
+ // openai: {
69
+ // modulePath: "@traceloop/instrumentation-openai",
70
+ // className: "OpenAIInstrumentation",
71
+ // requiredPackages: ["openai"],
72
+ // },
73
+ // pinecone: {
74
+ // modulePath: "@traceloop/instrumentation-pinecone",
75
+ // className: "PineconeInstrumentation",
76
+ // requiredPackages: ["pinecone-database/pinecone"],
77
+ // },
78
+ // qdrant: {
79
+ // modulePath: "@traceloop/instrumentation-qdrant",
80
+ // className: "QdrantInstrumentation",
81
+ // requiredPackages: ["qdrant/js-client-rest"],
82
+ // },
83
+ // vertexai: {
84
+ // modulePath: "@traceloop/instrumentation-vertexai",
85
+ // className: "VertexAIInstrumentation",
86
+ // requiredPackages: ["google-cloud/aiplatform"],
87
+ // },
88
+ // };
@@ -0,0 +1 @@
1
+ export {};
package/dist/intex.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const telemetry_1 = __importDefault(require("./telemetry"));
7
+ telemetry_1.default.init();
@@ -0,0 +1,14 @@
1
+ export declare const originalLogger: {
2
+ info: (message?: any, ...optionalParams: any[]) => void;
3
+ error: (message?: any, ...optionalParams: any[]) => void;
4
+ warn: (message?: any, ...optionalParams: any[]) => void;
5
+ debug: (message?: any, ...optionalParams: any[]) => void;
6
+ log: (message?: any, ...optionalParams: any[]) => void;
7
+ };
8
+ /**
9
+ * Stringify an object with a limited depth
10
+ * @param obj The object to stringify
11
+ * @param maxDepth Maximum depth (default: 1)
12
+ * @param depth Current depth (internal use)
13
+ */
14
+ export declare function stringify<T>(obj: T, maxDepth?: number, depth?: number): string;
package/dist/logger.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.originalLogger = void 0;
4
+ exports.stringify = stringify;
5
+ /* eslint-disable no-console */
6
+ const api_logs_1 = require("@opentelemetry/api-logs");
7
+ const telemetry_1 = require("./telemetry");
8
+ exports.originalLogger = {
9
+ info: console.info,
10
+ error: console.error,
11
+ warn: console.warn,
12
+ debug: console.debug,
13
+ log: console.log,
14
+ };
15
+ /**
16
+ * Stringify an object with a limited depth
17
+ * @param obj The object to stringify
18
+ * @param maxDepth Maximum depth (default: 1)
19
+ * @param depth Current depth (internal use)
20
+ */
21
+ function stringify(obj, maxDepth = 1, depth = 0) {
22
+ if (obj instanceof Error)
23
+ return obj.stack || obj.message;
24
+ if (obj === null)
25
+ return 'null';
26
+ if (obj === undefined)
27
+ return 'undefined';
28
+ // If we've reached max depth or it's not an object
29
+ if (depth >= maxDepth || typeof obj !== 'object') {
30
+ return typeof obj === 'object' ? `[${Array.isArray(obj) ? 'Array' : 'object'}]` :
31
+ typeof obj === 'string' ? `"${obj}"` : String(obj);
32
+ }
33
+ // Handle arrays
34
+ if (Array.isArray(obj)) {
35
+ return `[${obj.map(item => stringify(item, maxDepth, depth + 1)).join(', ')}]`;
36
+ }
37
+ // Handle objects
38
+ const pairs = Object.entries(obj).map(([key, val]) => `"${key}": ${stringify(val, maxDepth, depth + 1)}`);
39
+ return `{${pairs.join(', ')}}`;
40
+ }
41
+ // Format a log message with appropriate color and prefix
42
+ function formatLogMessage(message, args) {
43
+ const messageStr = typeof message === "string" ? message : stringify(message, 2);
44
+ const argsStr = args.map(arg => typeof arg === "string" ? arg : stringify(arg, 2)).join(" ");
45
+ return `${messageStr}${argsStr ? " " + argsStr : ""}`;
46
+ }
47
+ async function emitLog(severityNumber, message) {
48
+ const loggerInstance = await telemetry_1.blaxelTelemetry.getLogger();
49
+ loggerInstance.emit({
50
+ severityNumber: severityNumber,
51
+ body: message,
52
+ });
53
+ }
54
+ function emitLogSync(severityNumber, message) {
55
+ emitLog(severityNumber, message).catch(() => { });
56
+ }
57
+ console.debug = (message, ...args) => {
58
+ const msg = formatLogMessage(message, args);
59
+ exports.originalLogger.log(msg);
60
+ emitLogSync(api_logs_1.SeverityNumber.DEBUG, msg);
61
+ };
62
+ console.log = (message, ...args) => {
63
+ const msg = formatLogMessage(message, args);
64
+ exports.originalLogger.log(msg);
65
+ emitLogSync(api_logs_1.SeverityNumber.INFO, msg);
66
+ };
67
+ console.info = (message, ...args) => {
68
+ const msg = formatLogMessage(message, args);
69
+ exports.originalLogger.log(msg);
70
+ emitLogSync(api_logs_1.SeverityNumber.INFO, msg);
71
+ };
72
+ console.error = (message, ...args) => {
73
+ const msg = formatLogMessage(message, args);
74
+ exports.originalLogger.log(msg);
75
+ emitLogSync(api_logs_1.SeverityNumber.ERROR, msg);
76
+ };
77
+ console.warn = (message, ...args) => {
78
+ const msg = formatLogMessage(message, args);
79
+ exports.originalLogger.log(msg);
80
+ emitLogSync(api_logs_1.SeverityNumber.WARN, msg);
81
+ };
@@ -0,0 +1,64 @@
1
+ import { Span } from "@opentelemetry/api";
2
+ import { Logger } from "@opentelemetry/api-logs";
3
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
4
+ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
5
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
6
+ import { RawResourceAttribute, Resource } from "@opentelemetry/resources";
7
+ import { SpanProcessor } from "@opentelemetry/sdk-trace-node";
8
+ export declare class BlaxelResource implements Resource {
9
+ attributes: Record<string, string>;
10
+ constructor(attributes: Record<string, string>);
11
+ merge(other: Resource | null): Resource;
12
+ getRawAttributes(): RawResourceAttribute[];
13
+ }
14
+ export declare class DefaultAttributesSpanProcessor implements SpanProcessor {
15
+ private defaultAttributes;
16
+ constructor(defaultAttributes: Record<string, string>);
17
+ onStart(span: Span): void;
18
+ onEnd(): void;
19
+ shutdown(): Promise<void>;
20
+ forceFlush(): Promise<void>;
21
+ }
22
+ export type TelemetryOptions = {
23
+ workspace: string | null;
24
+ name: string | null;
25
+ authorization: string | null;
26
+ type: string | null;
27
+ };
28
+ declare class TelemetryManager {
29
+ private nodeTracerProvider;
30
+ private meterProvider;
31
+ private loggerProvider;
32
+ private otelLogger;
33
+ private initialized;
34
+ private configured;
35
+ constructor();
36
+ initialize(): void;
37
+ setConfiguration(): Promise<void>;
38
+ get enabled(): boolean;
39
+ get authHeaders(): Record<string, string>;
40
+ sleep(ms: number): Promise<unknown>;
41
+ getLogger(): Promise<Logger>;
42
+ setupSignalHandler(): void;
43
+ /**
44
+ * Get resource attributes for OpenTelemetry.
45
+ */
46
+ getResourceAttributes(): Promise<Record<string, string>>;
47
+ /**
48
+ * Initialize and return the OTLP Metric Exporter.
49
+ */
50
+ getMetricExporter(): OTLPMetricExporter;
51
+ /**
52
+ * Initialize and return the OTLP Trace Exporter.
53
+ */
54
+ getTraceExporter(): OTLPTraceExporter;
55
+ /**
56
+ * Initialize and return the OTLP Log Exporter.
57
+ */
58
+ getLogExporter(): OTLPLogExporter;
59
+ instrumentApp(): void;
60
+ setExporters(): Promise<void>;
61
+ shutdownApp(): Promise<void>;
62
+ }
63
+ export declare const blaxelTelemetry: TelemetryManager;
64
+ export {};
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blaxelTelemetry = exports.DefaultAttributesSpanProcessor = exports.BlaxelResource = void 0;
4
+ /* eslint-disable no-console */
5
+ const core_1 = require("@blaxel/core");
6
+ const api_1 = require("@opentelemetry/api");
7
+ const api_logs_1 = require("@opentelemetry/api-logs");
8
+ const exporter_logs_otlp_http_1 = require("@opentelemetry/exporter-logs-otlp-http");
9
+ const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-otlp-http");
10
+ const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
11
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
12
+ const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
13
+ const resources_1 = require("@opentelemetry/resources");
14
+ const sdk_logs_1 = require("@opentelemetry/sdk-logs");
15
+ const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
16
+ const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
17
+ class BlaxelResource {
18
+ attributes;
19
+ constructor(attributes) {
20
+ this.attributes = attributes;
21
+ }
22
+ merge(other) {
23
+ if (other?.attributes) {
24
+ for (const [key, value] of Object.entries(other.attributes)) {
25
+ if (typeof value === "string") {
26
+ this.attributes[key] = value;
27
+ }
28
+ }
29
+ }
30
+ return this;
31
+ }
32
+ getRawAttributes() {
33
+ return Object.entries(this.attributes).map(([key, value]) => [key, value]);
34
+ }
35
+ }
36
+ exports.BlaxelResource = BlaxelResource;
37
+ class DefaultAttributesSpanProcessor {
38
+ defaultAttributes;
39
+ constructor(defaultAttributes) {
40
+ this.defaultAttributes = defaultAttributes;
41
+ }
42
+ onStart(span) {
43
+ Object.entries(this.defaultAttributes).forEach(([key, value]) => {
44
+ span.setAttribute(key, value);
45
+ });
46
+ }
47
+ onEnd() { }
48
+ shutdown() {
49
+ return Promise.resolve();
50
+ }
51
+ forceFlush() {
52
+ return Promise.resolve();
53
+ }
54
+ }
55
+ exports.DefaultAttributesSpanProcessor = DefaultAttributesSpanProcessor;
56
+ class HasBeenProcessedSpanProcessor extends sdk_trace_node_1.BatchSpanProcessor {
57
+ onEnd(span) {
58
+ super.onEnd(span);
59
+ }
60
+ }
61
+ class TelemetryManager {
62
+ nodeTracerProvider;
63
+ meterProvider;
64
+ loggerProvider;
65
+ otelLogger;
66
+ initialized;
67
+ configured;
68
+ constructor() {
69
+ this.nodeTracerProvider = null;
70
+ this.meterProvider = null;
71
+ this.loggerProvider = null;
72
+ this.otelLogger = null;
73
+ this.initialized = false;
74
+ this.configured = false;
75
+ }
76
+ // This method need to stay sync to avoid non booted instrumentations
77
+ initialize() {
78
+ if (!this.enabled || this.initialized) {
79
+ return;
80
+ }
81
+ this.instrumentApp();
82
+ this.setupSignalHandler();
83
+ this.initialized = true;
84
+ this.setConfiguration().catch((error) => {
85
+ console.error("Error setting configuration:", error);
86
+ });
87
+ }
88
+ async setConfiguration() {
89
+ if (!this.enabled || this.configured) {
90
+ return;
91
+ }
92
+ await (0, core_1.authenticate)();
93
+ await this.setExporters();
94
+ this.otelLogger = api_logs_1.logs.getLogger("blaxel");
95
+ console.debug("Telemetry ready");
96
+ this.configured = true;
97
+ }
98
+ get enabled() {
99
+ return core_1.env.BL_ENABLE_OPENTELEMETRY === "true";
100
+ }
101
+ get authHeaders() {
102
+ const headers = {};
103
+ if (core_1.settings.authorization) {
104
+ headers["x-blaxel-authorization"] = core_1.settings.authorization;
105
+ }
106
+ if (core_1.settings.workspace) {
107
+ headers["x-blaxel-workspace"] = core_1.settings.workspace;
108
+ }
109
+ return headers;
110
+ }
111
+ async sleep(ms) {
112
+ return new Promise((resolve) => setTimeout(resolve, ms));
113
+ }
114
+ async getLogger() {
115
+ if (!this.otelLogger) {
116
+ await this.sleep(100);
117
+ return this.getLogger();
118
+ }
119
+ return this.otelLogger;
120
+ }
121
+ setupSignalHandler() {
122
+ const signals = ["SIGINT", "SIGTERM", "uncaughtException", "exit"];
123
+ for (const signal of signals) {
124
+ process.on(signal, (error) => {
125
+ if (signal !== "exit") {
126
+ core_1.logger.error(error.stack);
127
+ }
128
+ this.shutdownApp().catch((error) => {
129
+ console.debug("Fatal error during shutdown:", error);
130
+ process.exit(0);
131
+ });
132
+ });
133
+ }
134
+ }
135
+ /**
136
+ * Get resource attributes for OpenTelemetry.
137
+ */
138
+ async getResourceAttributes() {
139
+ const resource = await resources_1.envDetector.detect();
140
+ const attributes = resource.attributes || {};
141
+ if (core_1.settings.name) {
142
+ attributes["service.name"] = core_1.settings.name;
143
+ attributes["workload.id"] = core_1.settings.name;
144
+ }
145
+ if (core_1.settings.workspace) {
146
+ attributes["workspace"] = core_1.settings.workspace;
147
+ }
148
+ if (core_1.settings.type) {
149
+ attributes["workload.type"] = core_1.settings.type + "s";
150
+ }
151
+ // Only keep string values
152
+ const stringAttrs = {};
153
+ for (const [k, v] of Object.entries(attributes)) {
154
+ if (typeof v === "string")
155
+ stringAttrs[k] = v;
156
+ }
157
+ return stringAttrs;
158
+ }
159
+ /**
160
+ * Initialize and return the OTLP Metric Exporter.
161
+ */
162
+ getMetricExporter() {
163
+ return new exporter_metrics_otlp_http_1.OTLPMetricExporter({
164
+ headers: this.authHeaders,
165
+ });
166
+ }
167
+ /**
168
+ * Initialize and return the OTLP Trace Exporter.
169
+ */
170
+ getTraceExporter() {
171
+ return new exporter_trace_otlp_http_1.OTLPTraceExporter({
172
+ headers: this.authHeaders,
173
+ });
174
+ }
175
+ /**
176
+ * Initialize and return the OTLP Log Exporter.
177
+ */
178
+ getLogExporter() {
179
+ return new exporter_logs_otlp_http_1.OTLPLogExporter({
180
+ headers: this.authHeaders,
181
+ });
182
+ }
183
+ instrumentApp() {
184
+ const httpInstrumentation = new instrumentation_http_1.HttpInstrumentation({
185
+ requireParentforOutgoingSpans: true,
186
+ });
187
+ (0, instrumentation_1.registerInstrumentations)({
188
+ instrumentations: [httpInstrumentation],
189
+ });
190
+ }
191
+ async setExporters() {
192
+ const resource = new BlaxelResource(await this.getResourceAttributes());
193
+ const logExporter = this.getLogExporter();
194
+ this.loggerProvider = new sdk_logs_1.LoggerProvider({
195
+ resource,
196
+ });
197
+ this.loggerProvider.addLogRecordProcessor(new sdk_logs_1.BatchLogRecordProcessor(logExporter));
198
+ api_logs_1.logs.setGlobalLoggerProvider(this.loggerProvider);
199
+ const traceExporter = this.getTraceExporter();
200
+ this.nodeTracerProvider = new sdk_trace_node_1.NodeTracerProvider({
201
+ resource,
202
+ sampler: new sdk_trace_node_1.AlwaysOnSampler(),
203
+ spanProcessors: [
204
+ new DefaultAttributesSpanProcessor({
205
+ "workload.id": core_1.settings.name || "",
206
+ "workload.type": core_1.settings.type ? core_1.settings.type + "s" : "",
207
+ workspace: core_1.settings.workspace || "",
208
+ }),
209
+ new sdk_trace_node_1.BatchSpanProcessor(traceExporter),
210
+ new HasBeenProcessedSpanProcessor(traceExporter),
211
+ ],
212
+ });
213
+ this.nodeTracerProvider.register();
214
+ const metricExporter = this.getMetricExporter();
215
+ this.meterProvider = new sdk_metrics_1.MeterProvider({
216
+ resource,
217
+ readers: [
218
+ new sdk_metrics_1.PeriodicExportingMetricReader({
219
+ exporter: metricExporter,
220
+ exportIntervalMillis: 60000,
221
+ }),
222
+ ],
223
+ });
224
+ api_1.metrics.setGlobalMeterProvider(this.meterProvider);
225
+ }
226
+ async shutdownApp() {
227
+ try {
228
+ const maxSleepTime = 5000;
229
+ const startTime = Date.now();
230
+ while (!this.configured && Date.now() - startTime < maxSleepTime) {
231
+ await this.sleep(100);
232
+ }
233
+ const shutdownPromises = [];
234
+ if (this.nodeTracerProvider) {
235
+ shutdownPromises.push(this.nodeTracerProvider
236
+ .shutdown()
237
+ .catch((error) => console.debug("Error shutting down tracer provider:", error)));
238
+ }
239
+ if (this.meterProvider) {
240
+ shutdownPromises.push(this.meterProvider
241
+ .shutdown()
242
+ .catch((error) => console.debug("Error shutting down meter provider:", error)));
243
+ }
244
+ if (this.loggerProvider) {
245
+ shutdownPromises.push(this.loggerProvider
246
+ .shutdown()
247
+ .catch((error) => console.debug("Error shutting down logger provider:", error)));
248
+ }
249
+ // Wait for all providers to shutdown with a timeout
250
+ await Promise.race([
251
+ Promise.all(shutdownPromises),
252
+ new Promise((resolve) => setTimeout(resolve, 5000)), // 5 second timeout
253
+ ]);
254
+ console.debug("Instrumentation shutdown complete");
255
+ process.exit(0);
256
+ }
257
+ catch (error) {
258
+ console.error("Error during shutdown:", error);
259
+ process.exit(1);
260
+ }
261
+ }
262
+ }
263
+ exports.blaxelTelemetry = new TelemetryManager();
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "@blaxel/telemetry",
3
+ "version": "0.2.0-dev1",
4
+ "description": "Blaxel SDK for TypeScript",
5
+ "license": "MIT",
6
+ "author": "Blaxel, INC (https://blaxel.ai)",
7
+ "homepage": "https://blaxel.ai",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/blaxel/toolkit/sdk-ts"
11
+ },
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "keywords": [
16
+ "blaxel",
17
+ "agent",
18
+ "mcp"
19
+ ],
20
+ "main": "dist/index.js",
21
+ "module": "./dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "require": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ }
33
+ },
34
+ "./*": {
35
+ "import": {
36
+ "types": "./dist/*.d.ts",
37
+ "default": "./dist/*.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/*.d.ts",
41
+ "default": "./dist/*.js"
42
+ }
43
+ }
44
+ },
45
+ "typesVersions": {
46
+ "*": {
47
+ "*": [
48
+ "./dist/*"
49
+ ]
50
+ }
51
+ },
52
+ "files": [
53
+ "dist"
54
+ ],
55
+ "dependencies": {
56
+ "@ai-sdk/anthropic": "^1.2.10",
57
+ "@ai-sdk/cerebras": "^0.2.13",
58
+ "@ai-sdk/google": "^1.2.14",
59
+ "@ai-sdk/groq": "^1.2.8",
60
+ "@ai-sdk/openai": "^1.3.21",
61
+ "@opentelemetry/api": "^1.9.0",
62
+ "@opentelemetry/api-logs": "^0.200.0",
63
+ "@opentelemetry/exporter-logs-otlp-http": "^0.200.0",
64
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.200.0",
65
+ "@opentelemetry/exporter-trace-otlp-http": "^0.200.0",
66
+ "@opentelemetry/instrumentation": "^0.200.0",
67
+ "@opentelemetry/instrumentation-http": "^0.200.0",
68
+ "@opentelemetry/resources": "^2.0.0",
69
+ "@opentelemetry/sdk-logs": "^0.200.0",
70
+ "@opentelemetry/sdk-metrics": "^2.0.0",
71
+ "@opentelemetry/sdk-trace-base": "^2.0.0",
72
+ "@opentelemetry/sdk-trace-node": "^2.0.0",
73
+ "ai": "^4.3.13",
74
+ "@blaxel/core": "0.2.0-dev1"
75
+ },
76
+ "devDependencies": {
77
+ "@eslint/js": "^9.26.0",
78
+ "@types/ws": "^8.18.1",
79
+ "typescript": "^5.0.0",
80
+ "typescript-eslint": "^8.31.1"
81
+ },
82
+ "scripts": {
83
+ "build": "tsc",
84
+ "lint": "eslint src/"
85
+ }
86
+ }