Skip to content

Commit c02d7ab

Browse files
committed
Restructure exports
1 parent e59c534 commit c02d7ab

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

js/packages/openinference-mastra/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"exports": {
1616
".": {
1717
"import": "./dist/esm/index.js"
18+
},
19+
"./utils": {
20+
"import": "./dist/esm/utils.js"
1821
}
1922
},
2023
"files": [
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./OpenInferenceTraceExporter.js";
2+
export { isOpenInferenceSpan } from "./utils.js";

js/packages/openinference-mastra/src/utils.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";
21
import type { ReadableSpan } from "@opentelemetry/sdk-trace-base";
2+
import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";
3+
import { isOpenInferenceSpan as isOpenInferenceSpanVercel } from "@arizeai/openinference-vercel/utils";
34
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
45

6+
/**
7+
* Augments a Mastra span with OpenInference resource attributes.
8+
*
9+
* This function will add additional attributes to the span, based on the Mastra span's resource attributes.
10+
*
11+
* @param span - The Mastra span to augment.
12+
*/
513
export const addOpenInferenceResourceAttributesToMastraSpan = (
614
span: ReadableSpan,
715
) => {
816
const attributes = span.resource.attributes;
917
if (ATTR_SERVICE_NAME in attributes) {
1018
attributes[SEMRESATTRS_PROJECT_NAME] = attributes[ATTR_SERVICE_NAME];
1119
}
12-
// eslint-disable-next-line no-console
13-
console.log("attributes", attributes);
1420
};
1521

1622
/**
@@ -24,3 +30,17 @@ export const addOpenInferenceAttributesToMastraSpan = (
2430
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2531
span: ReadableSpan,
2632
) => {};
33+
34+
/**
35+
* Checks if a span is an OpenInference span.
36+
*
37+
* This function will check if the span is an OpenInference annotated span.
38+
*
39+
* It can be used as a span filter for the OpenInferenceTraceExporter, to ensure that only OpenInference annotated spans are exported.
40+
*
41+
* @param span - The span to check.
42+
*/
43+
export const isOpenInferenceSpan = (span: ReadableSpan) => {
44+
// TODO: Implement Mastra span check in addition to Vercel span check
45+
return isOpenInferenceSpanVercel(span);
46+
};

0 commit comments

Comments
 (0)