arvo-core 1.0.24 → 1.0.26
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/CHANGELOG.md +5 -1
- package/dist/ArvoEvent/helpers.js +2 -2
- package/dist/ArvoEventFactory/index.js +3 -3
- package/dist/OpenTelemetry/ArvoExecution/index.d.ts +6 -0
- package/dist/OpenTelemetry/ArvoExecution/index.js +12 -0
- package/dist/OpenTelemetry/ArvoExecution/types.d.ts +4 -0
- package/dist/OpenTelemetry/ArvoExecution/types.js +8 -0
- package/dist/OpenTelemetry/OpenInference/index.d.ts +62 -0
- package/dist/OpenTelemetry/OpenInference/index.js +85 -0
- package/dist/OpenTelemetry/OpenInference/types.d.ts +14 -0
- package/dist/OpenTelemetry/OpenInference/types.js +18 -0
- package/dist/OpenTelemetry/index.d.ts +13 -8
- package/dist/OpenTelemetry/index.js +27 -13
- package/dist/index.d.ts +5 -1
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -40,7 +40,11 @@
|
|
40
40
|
|
41
41
|
- Fix a type bug in ArvoEvent creation
|
42
42
|
|
43
|
-
## [1.0.
|
43
|
+
## [1.0.25] - 2024-09-08
|
44
44
|
|
45
45
|
- Updated OpenTelemetry propagation and fixed propagation in the event factory
|
46
46
|
|
47
|
+
## [1.0.26] - 2024-09-08
|
48
|
+
|
49
|
+
- Added OpenTelemetry attributes for Arvo and OpenInference
|
50
|
+
|
@@ -52,7 +52,7 @@ var createArvoEvent = function (event, extensions) {
|
|
52
52
|
if (event.datacontenttype &&
|
53
53
|
event.datacontenttype !== schema_1.ArvoDataContentType) {
|
54
54
|
var warning = (0, utils_1.cleanString)("\n Warning! The provided datacontenttype(=".concat(event.datacontenttype, ")\n is not ArvoEvent compatible (=").concat(schema_1.ArvoDataContentType, "). There may \n be some limited functionality.\n "));
|
55
|
-
(0, OpenTelemetry_1.logToSpan)(
|
55
|
+
(0, OpenTelemetry_1.logToSpan)({
|
56
56
|
level: 'WARNING',
|
57
57
|
message: warning,
|
58
58
|
});
|
@@ -75,7 +75,7 @@ var createArvoEvent = function (event, extensions) {
|
|
75
75
|
}, event.data, extensions);
|
76
76
|
}
|
77
77
|
catch (error) {
|
78
|
-
(0, OpenTelemetry_1.exceptionToSpan)(
|
78
|
+
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
79
79
|
span.setStatus({
|
80
80
|
code: api_1.SpanStatusCode.ERROR,
|
81
81
|
message: error.message,
|
@@ -65,7 +65,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
65
65
|
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { type: _this.contract.accepts.type, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
66
66
|
}
|
67
67
|
catch (error) {
|
68
|
-
(0, OpenTelemetry_1.exceptionToSpan)(
|
68
|
+
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
69
69
|
span.setStatus({
|
70
70
|
code: api_1.SpanStatusCode.ERROR,
|
71
71
|
message: error.message,
|
@@ -100,7 +100,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
100
100
|
return (0, helpers_1.createArvoEvent)(__assign(__assign({}, event), { datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri, data: validationResult.data }), extensions);
|
101
101
|
}
|
102
102
|
catch (error) {
|
103
|
-
(0, OpenTelemetry_1.exceptionToSpan)(
|
103
|
+
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
104
104
|
span.setStatus({
|
105
105
|
code: api_1.SpanStatusCode.ERROR,
|
106
106
|
message: error.message,
|
@@ -134,7 +134,7 @@ var ArvoEventFactory = /** @class */ (function () {
|
|
134
134
|
}, datacontenttype: schema_1.ArvoDataContentType, dataschema: _this.contract.uri }), extensions);
|
135
135
|
}
|
136
136
|
catch (error) {
|
137
|
-
(0, OpenTelemetry_1.exceptionToSpan)(
|
137
|
+
(0, OpenTelemetry_1.exceptionToSpan)(error);
|
138
138
|
span.setStatus({
|
139
139
|
code: api_1.SpanStatusCode.ERROR,
|
140
140
|
message: error.message,
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* ArvoExection class containing attribute constants for OpenTelemetry.
|
5
|
+
*/
|
6
|
+
var ArvoExecution = /** @class */ (function () {
|
7
|
+
function ArvoExecution() {
|
8
|
+
}
|
9
|
+
ArvoExecution.ATTR_SPAN_KIND = "arvo.span.kind";
|
10
|
+
return ArvoExecution;
|
11
|
+
}());
|
12
|
+
exports.default = ArvoExecution;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ArvoExecutionSpanKind = void 0;
|
4
|
+
var ArvoExecutionSpanKind;
|
5
|
+
(function (ArvoExecutionSpanKind) {
|
6
|
+
ArvoExecutionSpanKind["EVENT_HANDLER"] = "EVENT_HANDLER";
|
7
|
+
ArvoExecutionSpanKind["COMMANDER"] = "COMMANDER";
|
8
|
+
})(ArvoExecutionSpanKind || (exports.ArvoExecutionSpanKind = ArvoExecutionSpanKind = {}));
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/**
|
2
|
+
* OpenInference class containing attribute constants for OpenTelemetry OpenInference.
|
3
|
+
* These attribute names are defined as per the OpenInference specification:
|
4
|
+
* @see https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
|
5
|
+
*/
|
6
|
+
export default class OpenInference {
|
7
|
+
static readonly ATTR_SPAN_KIND = "openinference.span.kind";
|
8
|
+
static readonly ATTR_DOCUMENT_CONTENT = "document.content";
|
9
|
+
static readonly ATTR_DOCUMENT_ID = "document.id";
|
10
|
+
static readonly ATTR_DOCUMENT_METADATA = "document.metadata";
|
11
|
+
static readonly ATTR_DOCUMENT_SCORE = "document.score";
|
12
|
+
static readonly ATTR_EMBEDDING_EMBEDDINGS = "embedding.embeddings";
|
13
|
+
static readonly ATTR_EMBEDDING_MODEL_NAME = "embedding.model_name";
|
14
|
+
static readonly ATTR_EMBEDDING_TEXT = "embedding.text";
|
15
|
+
static readonly ATTR_EMBEDDING_VECTOR = "embedding.vector";
|
16
|
+
static readonly ATTR_EXCEPTION_ESCAPED = "exception.escaped";
|
17
|
+
static readonly ATTR_EXCEPTION_MESSAGE = "exception.message";
|
18
|
+
static readonly ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
19
|
+
static readonly ATTR_EXCEPTION_TYPE = "exception.type";
|
20
|
+
static readonly ATTR_IMAGE_URL = "image.url";
|
21
|
+
static readonly ATTR_INPUT_MIME_TYPE = "input.mime_type";
|
22
|
+
static readonly ATTR_INPUT_VALUE = "input.value";
|
23
|
+
static readonly ATTR_LLM_FUNCTION_CALL = "llm.function_call";
|
24
|
+
static readonly ATTR_LLM_INPUT_MESSAGES = "llm.input_messages";
|
25
|
+
static readonly ATTR_LLM_INVOCATION_PARAMETERS = "llm.invocation_parameters";
|
26
|
+
static readonly ATTR_LLM_MODEL_NAME = "llm.model_name";
|
27
|
+
static readonly ATTR_LLM_OUTPUT_MESSAGES = "llm.output_messages";
|
28
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_TEMPLATE = "llm.prompt_template.template";
|
29
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_VARIABLES = "llm.prompt_template.variables";
|
30
|
+
static readonly ATTR_LLM_PROMPT_TEMPLATE_VERSION = "llm.prompt_template.version";
|
31
|
+
static readonly ATTR_LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion";
|
32
|
+
static readonly ATTR_LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt";
|
33
|
+
static readonly ATTR_LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total";
|
34
|
+
static readonly ATTR_LLM_TOOLS = "llm.tools";
|
35
|
+
static readonly ATTR_MESSAGE_CONTENT = "message.content";
|
36
|
+
static readonly ATTR_MESSAGE_CONTENTS = "message.contents";
|
37
|
+
static readonly ATTR_MESSAGE_FUNCTION_CALL_ARGUMENTS_JSON = "message.function_call_arguments_json";
|
38
|
+
static readonly ATTR_MESSAGE_FUNCTION_CALL_NAME = "message.function_call_name";
|
39
|
+
static readonly ATTR_MESSAGE_ROLE = "message.role";
|
40
|
+
static readonly ATTR_MESSAGE_TOOL_CALLS = "message.tool_calls";
|
41
|
+
static readonly ATTR_MESSAGE_CONTENT_TYPE = "messagecontent.type";
|
42
|
+
static readonly ATTR_MESSAGE_CONTENT_TEXT = "messagecontent.text";
|
43
|
+
static readonly ATTR_MESSAGE_CONTENT_IMAGE = "messagecontent.image";
|
44
|
+
static readonly ATTR_METADATA = "metadata";
|
45
|
+
static readonly ATTR_OUTPUT_MIME_TYPE = "output.mime_type";
|
46
|
+
static readonly ATTR_OUTPUT_VALUE = "output.value";
|
47
|
+
static readonly ATTR_RERANKER_INPUT_DOCUMENTS = "reranker.input_documents";
|
48
|
+
static readonly ATTR_RERANKER_MODEL_NAME = "reranker.model_name";
|
49
|
+
static readonly ATTR_RERANKER_OUTPUT_DOCUMENTS = "reranker.output_documents";
|
50
|
+
static readonly ATTR_RERANKER_QUERY = "reranker.query";
|
51
|
+
static readonly ATTR_RERANKER_TOP_K = "reranker.top_k";
|
52
|
+
static readonly ATTR_RETRIEVAL_DOCUMENTS = "retrieval.documents";
|
53
|
+
static readonly ATTR_SESSION_ID = "session.id";
|
54
|
+
static readonly ATTR_TAG_TAGS = "tag.tags";
|
55
|
+
static readonly ATTR_TOOL_DESCRIPTION = "tool.description";
|
56
|
+
static readonly ATTR_TOOL_JSON_SCHEMA = "tool.json_schema";
|
57
|
+
static readonly ATTR_TOOL_NAME = "tool.name";
|
58
|
+
static readonly ATTR_TOOL_PARAMETERS = "tool.parameters";
|
59
|
+
static readonly ATTR_TOOL_CALL_FUNCTION_ARGUMENTS = "tool_call.function.arguments";
|
60
|
+
static readonly ATTR_TOOL_CALL_FUNCTION_NAME = "tool_call.function.name";
|
61
|
+
static readonly ATTR_USER_ID = "user.id";
|
62
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* OpenInference class containing attribute constants for OpenTelemetry OpenInference.
|
5
|
+
* These attribute names are defined as per the OpenInference specification:
|
6
|
+
* @see https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
|
7
|
+
*/
|
8
|
+
var OpenInference = /** @class */ (function () {
|
9
|
+
function OpenInference() {
|
10
|
+
}
|
11
|
+
OpenInference.ATTR_SPAN_KIND = "openinference.span.kind";
|
12
|
+
// Document attributes
|
13
|
+
OpenInference.ATTR_DOCUMENT_CONTENT = "document.content";
|
14
|
+
OpenInference.ATTR_DOCUMENT_ID = "document.id";
|
15
|
+
OpenInference.ATTR_DOCUMENT_METADATA = "document.metadata";
|
16
|
+
OpenInference.ATTR_DOCUMENT_SCORE = "document.score";
|
17
|
+
// Embedding attributes
|
18
|
+
OpenInference.ATTR_EMBEDDING_EMBEDDINGS = "embedding.embeddings";
|
19
|
+
OpenInference.ATTR_EMBEDDING_MODEL_NAME = "embedding.model_name";
|
20
|
+
OpenInference.ATTR_EMBEDDING_TEXT = "embedding.text";
|
21
|
+
OpenInference.ATTR_EMBEDDING_VECTOR = "embedding.vector";
|
22
|
+
// Exception attributes
|
23
|
+
OpenInference.ATTR_EXCEPTION_ESCAPED = "exception.escaped";
|
24
|
+
OpenInference.ATTR_EXCEPTION_MESSAGE = "exception.message";
|
25
|
+
OpenInference.ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
26
|
+
OpenInference.ATTR_EXCEPTION_TYPE = "exception.type";
|
27
|
+
// Image attribute
|
28
|
+
OpenInference.ATTR_IMAGE_URL = "image.url";
|
29
|
+
// Input attributes
|
30
|
+
OpenInference.ATTR_INPUT_MIME_TYPE = "input.mime_type";
|
31
|
+
OpenInference.ATTR_INPUT_VALUE = "input.value";
|
32
|
+
// LLM attributes
|
33
|
+
OpenInference.ATTR_LLM_FUNCTION_CALL = "llm.function_call";
|
34
|
+
OpenInference.ATTR_LLM_INPUT_MESSAGES = "llm.input_messages";
|
35
|
+
OpenInference.ATTR_LLM_INVOCATION_PARAMETERS = "llm.invocation_parameters";
|
36
|
+
OpenInference.ATTR_LLM_MODEL_NAME = "llm.model_name";
|
37
|
+
OpenInference.ATTR_LLM_OUTPUT_MESSAGES = "llm.output_messages";
|
38
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_TEMPLATE = "llm.prompt_template.template";
|
39
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_VARIABLES = "llm.prompt_template.variables";
|
40
|
+
OpenInference.ATTR_LLM_PROMPT_TEMPLATE_VERSION = "llm.prompt_template.version";
|
41
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion";
|
42
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt";
|
43
|
+
OpenInference.ATTR_LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total";
|
44
|
+
OpenInference.ATTR_LLM_TOOLS = "llm.tools";
|
45
|
+
// Message attributes
|
46
|
+
OpenInference.ATTR_MESSAGE_CONTENT = "message.content";
|
47
|
+
OpenInference.ATTR_MESSAGE_CONTENTS = "message.contents";
|
48
|
+
OpenInference.ATTR_MESSAGE_FUNCTION_CALL_ARGUMENTS_JSON = "message.function_call_arguments_json";
|
49
|
+
OpenInference.ATTR_MESSAGE_FUNCTION_CALL_NAME = "message.function_call_name";
|
50
|
+
OpenInference.ATTR_MESSAGE_ROLE = "message.role";
|
51
|
+
OpenInference.ATTR_MESSAGE_TOOL_CALLS = "message.tool_calls";
|
52
|
+
// Message content attributes
|
53
|
+
OpenInference.ATTR_MESSAGE_CONTENT_TYPE = "messagecontent.type";
|
54
|
+
OpenInference.ATTR_MESSAGE_CONTENT_TEXT = "messagecontent.text";
|
55
|
+
OpenInference.ATTR_MESSAGE_CONTENT_IMAGE = "messagecontent.image";
|
56
|
+
// Metadata attribute
|
57
|
+
OpenInference.ATTR_METADATA = "metadata";
|
58
|
+
// Output attributes
|
59
|
+
OpenInference.ATTR_OUTPUT_MIME_TYPE = "output.mime_type";
|
60
|
+
OpenInference.ATTR_OUTPUT_VALUE = "output.value";
|
61
|
+
// Reranker attributes
|
62
|
+
OpenInference.ATTR_RERANKER_INPUT_DOCUMENTS = "reranker.input_documents";
|
63
|
+
OpenInference.ATTR_RERANKER_MODEL_NAME = "reranker.model_name";
|
64
|
+
OpenInference.ATTR_RERANKER_OUTPUT_DOCUMENTS = "reranker.output_documents";
|
65
|
+
OpenInference.ATTR_RERANKER_QUERY = "reranker.query";
|
66
|
+
OpenInference.ATTR_RERANKER_TOP_K = "reranker.top_k";
|
67
|
+
// Retrieval attribute
|
68
|
+
OpenInference.ATTR_RETRIEVAL_DOCUMENTS = "retrieval.documents";
|
69
|
+
// Session attribute
|
70
|
+
OpenInference.ATTR_SESSION_ID = "session.id";
|
71
|
+
// Tag attribute
|
72
|
+
OpenInference.ATTR_TAG_TAGS = "tag.tags";
|
73
|
+
// Tool attributes
|
74
|
+
OpenInference.ATTR_TOOL_DESCRIPTION = "tool.description";
|
75
|
+
OpenInference.ATTR_TOOL_JSON_SCHEMA = "tool.json_schema";
|
76
|
+
OpenInference.ATTR_TOOL_NAME = "tool.name";
|
77
|
+
OpenInference.ATTR_TOOL_PARAMETERS = "tool.parameters";
|
78
|
+
// Tool call attributes
|
79
|
+
OpenInference.ATTR_TOOL_CALL_FUNCTION_ARGUMENTS = "tool_call.function.arguments";
|
80
|
+
OpenInference.ATTR_TOOL_CALL_FUNCTION_NAME = "tool_call.function.name";
|
81
|
+
// User attribute
|
82
|
+
OpenInference.ATTR_USER_ID = "user.id";
|
83
|
+
return OpenInference;
|
84
|
+
}());
|
85
|
+
exports.default = OpenInference;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* The open inference span kind as per
|
3
|
+
* https://github.com/Arize-ai/openinference/blob/main/spec/traces.md#span-kind
|
4
|
+
*/
|
5
|
+
export declare enum OpenInferenceSpanKind {
|
6
|
+
CHAIN = "CHAIN",
|
7
|
+
RETRIEVER = "RETRIEVER",
|
8
|
+
RERANKER = "RERANKER",
|
9
|
+
LLM = "LLM",
|
10
|
+
EMBEDDING = "EMBEDDING",
|
11
|
+
TOOL = "TOOL",
|
12
|
+
GUARDRAIL = "GUARDRAIL",
|
13
|
+
EVALUATOR = "EVALUATOR"
|
14
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.OpenInferenceSpanKind = void 0;
|
4
|
+
/**
|
5
|
+
* The open inference span kind as per
|
6
|
+
* https://github.com/Arize-ai/openinference/blob/main/spec/traces.md#span-kind
|
7
|
+
*/
|
8
|
+
var OpenInferenceSpanKind;
|
9
|
+
(function (OpenInferenceSpanKind) {
|
10
|
+
OpenInferenceSpanKind["CHAIN"] = "CHAIN";
|
11
|
+
OpenInferenceSpanKind["RETRIEVER"] = "RETRIEVER";
|
12
|
+
OpenInferenceSpanKind["RERANKER"] = "RERANKER";
|
13
|
+
OpenInferenceSpanKind["LLM"] = "LLM";
|
14
|
+
OpenInferenceSpanKind["EMBEDDING"] = "EMBEDDING";
|
15
|
+
OpenInferenceSpanKind["TOOL"] = "TOOL";
|
16
|
+
OpenInferenceSpanKind["GUARDRAIL"] = "GUARDRAIL";
|
17
|
+
OpenInferenceSpanKind["EVALUATOR"] = "EVALUATOR";
|
18
|
+
})(OpenInferenceSpanKind || (exports.OpenInferenceSpanKind = OpenInferenceSpanKind = {}));
|
@@ -6,22 +6,27 @@ import { TelemetryLogLevel, OpenTelemetryHeaders } from './types';
|
|
6
6
|
export declare const ArvoCoreTracer: import("@opentelemetry/api").Tracer;
|
7
7
|
/**
|
8
8
|
* Logs a message to a span with additional parameters.
|
9
|
-
* @param span - The span to log the message to.
|
10
9
|
* @param params - The parameters for the log message.
|
11
|
-
* @param params.level - The log level.
|
12
|
-
* @param params.message - The log message.
|
10
|
+
* @param params.level - The log level of the message.
|
11
|
+
* @param params.message - The main content of the log message.
|
12
|
+
* @param span - The span to log the message to. If not provided, the active span is used.
|
13
|
+
* If no active span is available, the message is logged to the console.
|
13
14
|
*/
|
14
|
-
export declare const logToSpan: (
|
15
|
+
export declare const logToSpan: (params: {
|
16
|
+
/** The log level */
|
15
17
|
level: TelemetryLogLevel;
|
18
|
+
/** The log message */
|
16
19
|
message: string;
|
17
|
-
|
20
|
+
/** Other log parameters */
|
21
|
+
[key: string]: string;
|
22
|
+
}, span?: Span | undefined) => void;
|
18
23
|
/**
|
19
24
|
* Logs an exception to a span and sets exception-related attributes.
|
20
|
-
* @param span - The span to log the exception to.
|
21
|
-
* @param level - The log level for the exception.
|
22
25
|
* @param error - The error object to be logged.
|
26
|
+
* @param span - The span to log the exception to. If not provided, the active span is used.
|
27
|
+
* If no active span is available, the error is logged to the console.
|
23
28
|
*/
|
24
|
-
export declare const exceptionToSpan: (
|
29
|
+
export declare const exceptionToSpan: (error: Error, span?: Span | undefined) => void;
|
25
30
|
/**
|
26
31
|
* A constant representing a null or not applicable value in OpenTelemetry context.
|
27
32
|
*/
|
@@ -23,27 +23,41 @@ var pkg = (0, utils_1.getPackageInfo)();
|
|
23
23
|
exports.ArvoCoreTracer = api_1.trace.getTracer(pkg.name, pkg.version);
|
24
24
|
/**
|
25
25
|
* Logs a message to a span with additional parameters.
|
26
|
-
* @param span - The span to log the message to.
|
27
26
|
* @param params - The parameters for the log message.
|
28
|
-
* @param params.level - The log level.
|
29
|
-
* @param params.message - The log message.
|
27
|
+
* @param params.level - The log level of the message.
|
28
|
+
* @param params.message - The main content of the log message.
|
29
|
+
* @param span - The span to log the message to. If not provided, the active span is used.
|
30
|
+
* If no active span is available, the message is logged to the console.
|
30
31
|
*/
|
31
|
-
var logToSpan = function (
|
32
|
-
|
32
|
+
var logToSpan = function (params, span) {
|
33
|
+
if (span === void 0) { span = api_1.trace.getActiveSpan(); }
|
34
|
+
var toLog = __assign(__assign({}, params), { timestamp: performance.now() });
|
35
|
+
if (span) {
|
36
|
+
span.addEvent('log_message', toLog);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
console.log(JSON.stringify(toLog, null, 2));
|
40
|
+
}
|
33
41
|
};
|
34
42
|
exports.logToSpan = logToSpan;
|
35
43
|
/**
|
36
44
|
* Logs an exception to a span and sets exception-related attributes.
|
37
|
-
* @param span - The span to log the exception to.
|
38
|
-
* @param level - The log level for the exception.
|
39
45
|
* @param error - The error object to be logged.
|
46
|
+
* @param span - The span to log the exception to. If not provided, the active span is used.
|
47
|
+
* If no active span is available, the error is logged to the console.
|
40
48
|
*/
|
41
|
-
var exceptionToSpan = function (
|
42
|
-
span.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
var exceptionToSpan = function (error, span) {
|
50
|
+
if (span === void 0) { span = api_1.trace.getActiveSpan(); }
|
51
|
+
if (span) {
|
52
|
+
span.setAttributes({
|
53
|
+
'exception.type': error.name,
|
54
|
+
'exception.message': error.message,
|
55
|
+
});
|
56
|
+
span.recordException(error);
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
console.error(error);
|
60
|
+
}
|
47
61
|
};
|
48
62
|
exports.exceptionToSpan = exceptionToSpan;
|
49
63
|
/**
|
package/dist/index.d.ts
CHANGED
@@ -14,6 +14,10 @@ import { createArvoContractLibrary } from './ArvoContractLibrary/helpers';
|
|
14
14
|
import ArvoEventFactory from './ArvoEventFactory';
|
15
15
|
import { createArvoEventFactory } from './ArvoEventFactory/helpers';
|
16
16
|
import { ArvoErrorSchema } from './schema';
|
17
|
+
import OpenInference from './OpenTelemetry/OpenInference';
|
18
|
+
import ArvoExecution from './OpenTelemetry/ArvoExecution';
|
19
|
+
import { ArvoExecutionSpanKind } from './OpenTelemetry/ArvoExecution/types';
|
20
|
+
import { OpenInferenceSpanKind } from './OpenTelemetry/OpenInference/types';
|
17
21
|
/**
|
18
22
|
* Collection of Zod schemas for validating various aspects of Arvo events.
|
19
23
|
* @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
|
@@ -80,4 +84,4 @@ declare const ArvoEventSchemas: {
|
|
80
84
|
tracestate: string | null;
|
81
85
|
}>;
|
82
86
|
};
|
83
|
-
export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, InferArvoContract, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, };
|
87
|
+
export { ArvoEvent, createArvoEvent, ArvoDataContentType, ArvoEventData, CloudEventExtension, ArvoEventSchemas, CloudEventContext, ArvoExtension, OpenTelemetryExtension, CreateArvoEvent, exceptionToSpan, logToSpan, OpenTelemetryHeaders, TelemetryLogLevel, OTelNull, validateURI, cleanString, ArvoContract, createArvoContract, ArvoContractValidators, ArvoContractRecord, InferArvoContract, IArvoContract, ResolveArvoContractRecord, ArvoContractLibrary, createArvoContractLibrary, ArvoEventFactory, createArvoEventFactory, ArvoErrorSchema, currentOpenTelemetryHeaders, OpenInference, OpenInferenceSpanKind, ArvoExecution, ArvoExecutionSpanKind, };
|
package/dist/index.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.currentOpenTelemetryHeaders = exports.ArvoErrorSchema = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.createArvoContractLibrary = exports.ArvoContractLibrary = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchemas = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
|
6
|
+
exports.ArvoExecutionSpanKind = exports.ArvoExecution = exports.OpenInferenceSpanKind = exports.OpenInference = exports.currentOpenTelemetryHeaders = exports.ArvoErrorSchema = exports.createArvoEventFactory = exports.ArvoEventFactory = exports.createArvoContractLibrary = exports.ArvoContractLibrary = exports.ArvoContractValidators = exports.createArvoContract = exports.ArvoContract = exports.cleanString = exports.validateURI = exports.OTelNull = exports.logToSpan = exports.exceptionToSpan = exports.ArvoEventSchemas = exports.ArvoDataContentType = exports.createArvoEvent = exports.ArvoEvent = void 0;
|
7
7
|
var ArvoEvent_1 = __importDefault(require("./ArvoEvent"));
|
8
8
|
exports.ArvoEvent = ArvoEvent_1.default;
|
9
9
|
var schema_1 = require("./ArvoEvent/schema");
|
@@ -34,6 +34,14 @@ var helpers_4 = require("./ArvoEventFactory/helpers");
|
|
34
34
|
Object.defineProperty(exports, "createArvoEventFactory", { enumerable: true, get: function () { return helpers_4.createArvoEventFactory; } });
|
35
35
|
var schema_2 = require("./schema");
|
36
36
|
Object.defineProperty(exports, "ArvoErrorSchema", { enumerable: true, get: function () { return schema_2.ArvoErrorSchema; } });
|
37
|
+
var OpenInference_1 = __importDefault(require("./OpenTelemetry/OpenInference"));
|
38
|
+
exports.OpenInference = OpenInference_1.default;
|
39
|
+
var ArvoExecution_1 = __importDefault(require("./OpenTelemetry/ArvoExecution"));
|
40
|
+
exports.ArvoExecution = ArvoExecution_1.default;
|
41
|
+
var types_1 = require("./OpenTelemetry/ArvoExecution/types");
|
42
|
+
Object.defineProperty(exports, "ArvoExecutionSpanKind", { enumerable: true, get: function () { return types_1.ArvoExecutionSpanKind; } });
|
43
|
+
var types_2 = require("./OpenTelemetry/OpenInference/types");
|
44
|
+
Object.defineProperty(exports, "OpenInferenceSpanKind", { enumerable: true, get: function () { return types_2.OpenInferenceSpanKind; } });
|
37
45
|
/**
|
38
46
|
* Collection of Zod schemas for validating various aspects of Arvo events.
|
39
47
|
* @property {z.ZodObject} CloudEventContextSchema - Schema for core CloudEvent properties.
|