1
- import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions" ;
2
1
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" ;
3
4
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions" ;
4
5
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
+ */
5
13
export const addOpenInferenceResourceAttributesToMastraSpan = (
6
14
span : ReadableSpan ,
7
15
) => {
8
16
const attributes = span . resource . attributes ;
9
17
if ( ATTR_SERVICE_NAME in attributes ) {
10
18
attributes [ SEMRESATTRS_PROJECT_NAME ] = attributes [ ATTR_SERVICE_NAME ] ;
11
19
}
12
- // eslint-disable-next-line no-console
13
- console . log ( "attributes" , attributes ) ;
14
20
} ;
15
21
16
22
/**
@@ -24,3 +30,17 @@ export const addOpenInferenceAttributesToMastraSpan = (
24
30
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25
31
span : ReadableSpan ,
26
32
) => { } ;
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