7
7
* -e HIVE_ORGANIZATION_ACCESS_TOKEN="<organization_access_key>"
8
8
* -e HIVE_TARGET_REF="<target_ref>"
9
9
* -e DEBUG=1
10
- * ghcr.io/graphql-hive/gateway supergraph \
10
+ * ghcr.io/graphql-hive/gateway:1.14.3-alpha-cf354599f0bca73b6f8b010a6747e42a17ef20d7 supergraph \
11
11
* "http://host.docker.internal:3001/artifacts/v1/<target_id>" \
12
12
* --hive-cdn-key '<cdn_key>'
13
13
* ````
@@ -27,6 +27,12 @@ const useOnFetchTracer = (): GatewayPlugin => {
27
27
onFetch ( { url, options } ) {
28
28
upstreamCallHeaders . push ( { url, headers : options . headers } ) ;
29
29
} ,
30
+ // onSubgraphExecute({ executionRequest, requestId, subgraphName, ...res }) {
31
+ // return async function onSubgraphExecuteDone({ result }) {
32
+ // const span = trace.getSpan(executionRequest.context.opentelemetry.activeContext());
33
+ // console.log('DUDUDUDUDUDUDUD', span);
34
+ // };
35
+ // },
30
36
onRequest ( { request, url, endResponse, fetchAPI } ) {
31
37
if ( url . pathname === '/upstream-fetch' && request . method === 'GET' ) {
32
38
endResponse ( fetchAPI . Response . json ( upstreamCallHeaders ) ) ;
@@ -71,6 +77,8 @@ class HiveTracingSpanProcessor implements SpanProcessor {
71
77
const traceId = spanContext . traceId ;
72
78
const spanId = spanContext . spanId ;
73
79
80
+ console . log ( traceId , spanId ) ;
81
+
74
82
// Initialize trace data structures if needed
75
83
if ( ! this . activeSpans . has ( traceId ) ) {
76
84
this . activeSpans . set ( traceId , new Map ( ) ) ;
@@ -82,7 +90,8 @@ class HiveTracingSpanProcessor implements SpanProcessor {
82
90
this . activeSpans . get ( traceId ) ! . set ( spanId , span ) ;
83
91
84
92
// If this is a root span (no parent), mark it as the root span for this trace
85
- if ( ! span . parentSpanId ) {
93
+ // if (!span.parentSpanId) {
94
+ if ( ! span . parentSpanContext ?. spanId ) {
86
95
this . rootSpanIds . set ( traceId , spanId ) ;
87
96
}
88
97
@@ -128,9 +137,7 @@ class HiveTracingSpanProcessor implements SpanProcessor {
128
137
rootSpan . setAttribute ( 'hive.graphql.operation.type' , operationType ) ;
129
138
rootSpan . setAttribute ( 'hive.graphql.operation.name' , operationName ?? '' ) ;
130
139
rootSpan . setAttribute ( 'hive.graphql.operation.document' , document ) ;
131
-
132
- if ( errorCount !== undefined )
133
- rootSpan . setAttribute ( 'hive.graphql.error.count' , errorCount ) ;
140
+ rootSpan . setAttribute ( 'hive.graphql.error.count' , String ( errorCount ?? 0 ) ) ;
134
141
135
142
// Add the subgraph names as a comma-separated list
136
143
if ( subgraphNamesForTrace && subgraphNamesForTrace . size > 0 ) {
@@ -147,6 +154,7 @@ class HiveTracingSpanProcessor implements SpanProcessor {
147
154
// For any subgraph span that's ending, make sure we capture its name
148
155
if ( span . name && span . name . startsWith ( 'subgraph.execute' ) ) {
149
156
const subgraphName = span . attributes [ 'gateway.upstream.subgraph.name' ] ;
157
+
150
158
if ( subgraphName && typeof subgraphName === 'string' && subgraphNamesForTrace ) {
151
159
subgraphNamesForTrace . add ( subgraphName ) ;
152
160
@@ -161,6 +169,20 @@ class HiveTracingSpanProcessor implements SpanProcessor {
161
169
}
162
170
}
163
171
}
172
+
173
+ // add hive branded attributes
174
+ //
175
+ span . attributes [ 'hive.graphql.subgraph.name' ] =
176
+ span . attributes [ 'gateway.upstream.subgraph.name' ] ;
177
+ span . attributes [ 'hive.graphql.operation.document' ] = span . attributes [ 'graphql.document' ] ;
178
+ span . attributes [ 'hive.graphql.operation.name' ] = span . attributes [ 'graphql.operation.name' ] ;
179
+ span . attributes [ 'hive.graphql.operation.type' ] = span . attributes [ 'graphql.operation.type' ] ;
180
+ // TODO: attributes for error codes
181
+ // hive.graphql.error.count
182
+ span . attributes [ 'hive.graphql.error.count' ] = '0' ;
183
+ // hive.graphql.error.codes
184
+ // span.setAttribute('hive.graphql.error.codes', '');
185
+ //
164
186
}
165
187
166
188
// Clean up the span reference
@@ -195,6 +217,7 @@ async function createHiveTracingSpanProcessor(): Promise<HiveTracingSpanProcesso
195
217
196
218
export const gatewayConfig = defineConfig ( {
197
219
openTelemetry : {
220
+ contextManager : false ,
198
221
exporters : [
199
222
createHiveTracingSpanProcessor ( ) ,
200
223
createOtlpHttpExporter (
0 commit comments