Skip to content

Commit 62bf54d

Browse files
committed
fix(tracing): upgrade to otel 2.0+
1 parent ea7cfe8 commit 62bf54d

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

genkit-tools/common/src/types/trace.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,16 @@ export const LinkSchema = z.object({
9797
});
9898

9999
/**
100-
* Zod schema for instrumentation library.
100+
* Zod schema for instrumentation scope.
101+
*/
102+
export const InstrumentationScopeSchema = z.object({
103+
name: z.string().readonly(),
104+
version: z.string().optional().readonly(),
105+
schemaUrl: z.string().optional().readonly(),
106+
});
107+
108+
/**
109+
* Zod schema for legacy instrumentation library.
101110
*/
102111
export const InstrumentationLibrarySchema = z.object({
103112
name: z.string().readonly(),
@@ -118,7 +127,8 @@ export const SpanDataSchema = z
118127
attributes: z.record(z.string(), z.unknown()),
119128
displayName: z.string(),
120129
links: z.array(LinkSchema).optional(),
121-
instrumentationLibrary: InstrumentationLibrarySchema,
130+
instrumentationLibrary: InstrumentationLibrarySchema.optional(),
131+
instrumentationScope: InstrumentationScopeSchema.optional(),
122132
spanKind: z.string(),
123133
sameProcessAsParentSpan: z.object({ value: z.boolean() }).optional(),
124134
status: SpanStatusSchema.optional(),

genkit-tools/genkit-schema.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,24 @@
14041404
],
14051405
"additionalProperties": false
14061406
},
1407+
"InstrumentationScope": {
1408+
"type": "object",
1409+
"properties": {
1410+
"name": {
1411+
"type": "string"
1412+
},
1413+
"version": {
1414+
"type": "string"
1415+
},
1416+
"schemaUrl": {
1417+
"type": "string"
1418+
}
1419+
},
1420+
"required": [
1421+
"name"
1422+
],
1423+
"additionalProperties": false
1424+
},
14071425
"Link": {
14081426
"type": "object",
14091427
"properties": {
@@ -1500,6 +1518,9 @@
15001518
"instrumentationLibrary": {
15011519
"$ref": "#/$defs/InstrumentationLibrary"
15021520
},
1521+
"instrumentationScope": {
1522+
"$ref": "#/$defs/InstrumentationScope"
1523+
},
15031524
"spanKind": {
15041525
"type": "string"
15051526
},
@@ -1541,7 +1562,6 @@
15411562
"endTime",
15421563
"attributes",
15431564
"displayName",
1544-
"instrumentationLibrary",
15451565
"spanKind"
15461566
],
15471567
"additionalProperties": false

genkit-tools/telemetry-server/src/utils/otlp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function toSpanData(span: OtlpSpan, scope: OtlpScopeSpan['scope']): SpanData {
120120
endTime: toMillis(span.endTimeUnixNano),
121121
displayName: span.name,
122122
attributes,
123-
instrumentationLibrary: {
123+
instrumentationScope: {
124124
name: scope.name,
125125
version: scope.version,
126126
},

js/core/src/tracing/types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export const LinkSchema = z.object({
7474
droppedAttributesCount: z.number().optional(),
7575
});
7676

77+
export const InstrumentationLibrarySchema = z.object({
78+
name: z.string().readonly(),
79+
version: z.string().optional().readonly(),
80+
schemaUrl: z.string().optional().readonly(),
81+
});
82+
7783
export const InstrumentationScopeSchema = z.object({
7884
name: z.string().readonly(),
7985
version: z.string().optional().readonly(),
@@ -89,7 +95,8 @@ export const SpanDataSchema = z.object({
8995
attributes: z.record(z.string(), z.any()),
9096
displayName: z.string(),
9197
links: z.array(LinkSchema).optional(),
92-
instrumentationScope: InstrumentationScopeSchema,
98+
instrumentationLibrary: InstrumentationLibrarySchema.optional(),
99+
instrumentationScope: InstrumentationScopeSchema.optional(),
93100
spanKind: z.string(),
94101
sameProcessAsParentSpan: z.object({ value: z.boolean() }).optional(),
95102
status: SpanStatusSchema.optional(),

0 commit comments

Comments
 (0)