@blaxel/telemetry 0.2.2-preview3 → 0.2.2
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/index.js +3 -8
- package/dist/json_logger.js +4 -18
- package/package.json +2 -2
- package/dist/instrumentationMap.d.ts +0 -1
- package/dist/instrumentationMap.js +0 -88
- package/dist/intex.d.ts +0 -1
- package/dist/intex.js +0 -7
- package/dist/logger.d.ts +0 -15
- package/dist/logger.js +0 -84
package/dist/index.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blaxelTelemetry = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// import { settings } from "@blaxel/core";
|
|
5
|
+
// import { setJsonLogger } from "./json_logger";
|
|
6
6
|
const legacy_logger_1 = require("./legacy_logger");
|
|
7
7
|
const telemetry_1 = require("./telemetry");
|
|
8
8
|
Object.defineProperty(exports, "blaxelTelemetry", { enumerable: true, get: function () { return telemetry_1.blaxelTelemetry; } });
|
|
9
9
|
telemetry_1.blaxelTelemetry.initialize();
|
|
10
|
-
|
|
11
|
-
(0, legacy_logger_1.setLegacyLogger)();
|
|
12
|
-
}
|
|
13
|
-
else if (core_1.settings.loggerType === "json") {
|
|
14
|
-
(0, json_logger_1.setJsonLogger)();
|
|
15
|
-
}
|
|
10
|
+
(0, legacy_logger_1.setLegacyLogger)();
|
package/dist/json_logger.js
CHANGED
|
@@ -34,15 +34,6 @@ exports.originalLogger = {
|
|
|
34
34
|
debug: console.debug,
|
|
35
35
|
log: console.log,
|
|
36
36
|
};
|
|
37
|
-
const traceIdName = core_1.env.BL_LOGGER_TRACE_ID || 'trace_id';
|
|
38
|
-
const spanIdName = core_1.env.BL_LOGGER_SPAN_ID || 'span_id';
|
|
39
|
-
const labelsName = core_1.env.BL_LOGGER_LABELS || 'labels';
|
|
40
|
-
const traceIdPrefix = core_1.env.BL_LOGGER_TRACE_ID_PREFIX || '';
|
|
41
|
-
const spanIdPrefix = core_1.env.BL_LOGGER_SPAN_ID_PREFIX || '';
|
|
42
|
-
const taskIndex = core_1.env.BL_TASK_KEY || 'TASK_INDEX';
|
|
43
|
-
const taskPrefix = core_1.env.BL_TASK_PREFIX || '';
|
|
44
|
-
const executionKey = core_1.env.BL_EXECUTION_KEY || 'BL_EXECUTION_ID';
|
|
45
|
-
const executionPrefix = core_1.env.BL_EXECUTION_PREFIX || '';
|
|
46
37
|
// Format a log message with appropriate color and prefix
|
|
47
38
|
function formatLogMessage(severity, message, args) {
|
|
48
39
|
const messageStr = typeof message === "string" ? message : (0, core_1.stringify)(message, 2);
|
|
@@ -52,20 +43,15 @@ function formatLogMessage(severity, message, args) {
|
|
|
52
43
|
message: msg,
|
|
53
44
|
severity
|
|
54
45
|
};
|
|
55
|
-
logEntry[labelsName] = {};
|
|
56
46
|
const currentSpan = api_1.trace.getActiveSpan();
|
|
57
47
|
if (currentSpan) {
|
|
58
48
|
const { traceId, spanId } = currentSpan.spanContext();
|
|
49
|
+
const traceIdName = core_1.env.BL_LOGGER_TRACE_ID || 'trace_id';
|
|
50
|
+
const spanIdName = core_1.env.BL_LOGGER_SPAN_ID || 'span_id';
|
|
51
|
+
const traceIdPrefix = core_1.env.BL_LOGGER_TRACE_ID_PREFIX || '';
|
|
52
|
+
const spanIdPrefix = core_1.env.BL_LOGGER_SPAN_ID_PREFIX || '';
|
|
59
53
|
logEntry[traceIdName] = `${traceIdPrefix}${traceId}`;
|
|
60
54
|
logEntry[spanIdName] = `${spanIdPrefix}${spanId}`;
|
|
61
55
|
}
|
|
62
|
-
const taskId = core_1.env[taskIndex] || null;
|
|
63
|
-
if (taskId) {
|
|
64
|
-
logEntry[labelsName]['blaxel-task'] = `${taskPrefix}${taskId}`;
|
|
65
|
-
}
|
|
66
|
-
const executionId = core_1.env[executionKey] || null;
|
|
67
|
-
if (executionId) {
|
|
68
|
-
logEntry[labelsName]['blaxel-execution'] = `${executionPrefix}${executionId.split('-').pop()}`;
|
|
69
|
-
}
|
|
70
56
|
return JSON.stringify(logEntry);
|
|
71
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/telemetry",
|
|
3
|
-
"version": "0.2.2
|
|
3
|
+
"version": "0.2.2",
|
|
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.2
|
|
74
|
+
"@blaxel/core": "0.2.2"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@eslint/js": "^9.26.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
-
// };
|
package/dist/intex.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/intex.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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();
|
package/dist/logger.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function overrideConsole(): void;
|
|
2
|
-
export declare const originalLogger: {
|
|
3
|
-
info: (message?: any, ...optionalParams: any[]) => void;
|
|
4
|
-
error: (message?: any, ...optionalParams: any[]) => void;
|
|
5
|
-
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
6
|
-
debug: (message?: any, ...optionalParams: any[]) => void;
|
|
7
|
-
log: (message?: any, ...optionalParams: any[]) => void;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Stringify an object with a limited depth
|
|
11
|
-
* @param obj The object to stringify
|
|
12
|
-
* @param maxDepth Maximum depth (default: 1)
|
|
13
|
-
* @param depth Current depth (internal use)
|
|
14
|
-
*/
|
|
15
|
-
export declare function stringify<T>(obj: T, maxDepth?: number, depth?: number): string;
|
package/dist/logger.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.originalLogger = void 0;
|
|
4
|
-
exports.overrideConsole = overrideConsole;
|
|
5
|
-
exports.stringify = stringify;
|
|
6
|
-
/* eslint-disable no-console */
|
|
7
|
-
const api_logs_1 = require("@opentelemetry/api-logs");
|
|
8
|
-
const telemetry_1 = require("./telemetry");
|
|
9
|
-
function overrideConsole() {
|
|
10
|
-
console.debug = (message, ...args) => {
|
|
11
|
-
const msg = formatLogMessage(message, args);
|
|
12
|
-
exports.originalLogger.log(msg);
|
|
13
|
-
emitLogSync(api_logs_1.SeverityNumber.DEBUG, msg);
|
|
14
|
-
};
|
|
15
|
-
console.log = (message, ...args) => {
|
|
16
|
-
const msg = formatLogMessage(message, args);
|
|
17
|
-
exports.originalLogger.log(msg);
|
|
18
|
-
emitLogSync(api_logs_1.SeverityNumber.INFO, msg);
|
|
19
|
-
};
|
|
20
|
-
console.info = (message, ...args) => {
|
|
21
|
-
const msg = formatLogMessage(message, args);
|
|
22
|
-
exports.originalLogger.log(msg);
|
|
23
|
-
emitLogSync(api_logs_1.SeverityNumber.INFO, msg);
|
|
24
|
-
};
|
|
25
|
-
console.error = (message, ...args) => {
|
|
26
|
-
const msg = formatLogMessage(message, args);
|
|
27
|
-
exports.originalLogger.log(msg);
|
|
28
|
-
emitLogSync(api_logs_1.SeverityNumber.ERROR, msg);
|
|
29
|
-
};
|
|
30
|
-
console.warn = (message, ...args) => {
|
|
31
|
-
const msg = formatLogMessage(message, args);
|
|
32
|
-
exports.originalLogger.log(msg);
|
|
33
|
-
emitLogSync(api_logs_1.SeverityNumber.WARN, msg);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.originalLogger = {
|
|
37
|
-
info: console.info,
|
|
38
|
-
error: console.error,
|
|
39
|
-
warn: console.warn,
|
|
40
|
-
debug: console.debug,
|
|
41
|
-
log: console.log,
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Stringify an object with a limited depth
|
|
45
|
-
* @param obj The object to stringify
|
|
46
|
-
* @param maxDepth Maximum depth (default: 1)
|
|
47
|
-
* @param depth Current depth (internal use)
|
|
48
|
-
*/
|
|
49
|
-
function stringify(obj, maxDepth = 1, depth = 0) {
|
|
50
|
-
if (obj instanceof Error)
|
|
51
|
-
return obj.stack || obj.message;
|
|
52
|
-
if (obj === null)
|
|
53
|
-
return 'null';
|
|
54
|
-
if (obj === undefined)
|
|
55
|
-
return 'undefined';
|
|
56
|
-
// If we've reached max depth or it's not an object
|
|
57
|
-
if (depth >= maxDepth || typeof obj !== 'object') {
|
|
58
|
-
return typeof obj === 'object' ? `[${Array.isArray(obj) ? 'Array' : 'object'}]` :
|
|
59
|
-
typeof obj === 'string' ? `"${obj}"` : String(obj);
|
|
60
|
-
}
|
|
61
|
-
// Handle arrays
|
|
62
|
-
if (Array.isArray(obj)) {
|
|
63
|
-
return `[${obj.map(item => stringify(item, maxDepth, depth + 1)).join(', ')}]`;
|
|
64
|
-
}
|
|
65
|
-
// Handle objects
|
|
66
|
-
const pairs = Object.entries(obj).map(([key, val]) => `"${key}": ${stringify(val, maxDepth, depth + 1)}`);
|
|
67
|
-
return `{${pairs.join(', ')}}`;
|
|
68
|
-
}
|
|
69
|
-
// Format a log message with appropriate color and prefix
|
|
70
|
-
function formatLogMessage(message, args) {
|
|
71
|
-
const messageStr = typeof message === "string" ? message : stringify(message, 2);
|
|
72
|
-
const argsStr = args.map(arg => typeof arg === "string" ? arg : stringify(arg, 2)).join(" ");
|
|
73
|
-
return `${messageStr}${argsStr ? " " + argsStr : ""}`;
|
|
74
|
-
}
|
|
75
|
-
async function emitLog(severityNumber, message) {
|
|
76
|
-
const loggerInstance = await telemetry_1.blaxelTelemetry.getLogger();
|
|
77
|
-
loggerInstance.emit({
|
|
78
|
-
severityNumber: severityNumber,
|
|
79
|
-
body: message,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function emitLogSync(severityNumber, message) {
|
|
83
|
-
emitLog(severityNumber, message).catch(() => { });
|
|
84
|
-
}
|