@@ -86,6 +86,7 @@ func TestTracer(t *testing.T) {
86
86
attribute .Int ("graphql.operation.complexity.calculated" , 3 ),
87
87
},
88
88
},
89
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
89
90
},
90
91
},
91
92
{
@@ -136,6 +137,7 @@ func TestTracer(t *testing.T) {
136
137
attribute .Int ("graphql.operation.complexity.calculated" , 3 ),
137
138
},
138
139
},
140
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
139
141
},
140
142
},
141
143
{
@@ -187,6 +189,7 @@ func TestTracer(t *testing.T) {
187
189
attribute .Int ("graphql.operation.complexity.calculated" , 3 ),
188
190
},
189
191
},
192
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
190
193
},
191
194
},
192
195
{
@@ -241,6 +244,7 @@ func TestTracer(t *testing.T) {
241
244
attribute .Int ("graphql.operation.complexity.calculated" , 3 ),
242
245
},
243
246
},
247
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
244
248
},
245
249
},
246
250
{
@@ -281,8 +285,24 @@ func TestTracer(t *testing.T) {
281
285
Name : semconv .ExceptionEventName ,
282
286
Attributes : []attribute.KeyValue {
283
287
attribute .String ("graphql.errors.path" , "user" ),
284
- semconv .ExceptionTypeKey .String ("*gqlerror.Error" ),
285
- semconv .ExceptionMessageKey .String ("input: user forbidden" ),
288
+ semconv .ExceptionTypeKey .String ("github.com/aereal/otelgqlgen/test/resolvers.ForbiddenError" ),
289
+ semconv .ExceptionMessageKey .String ("forbidden" ),
290
+ attrStacktrace ,
291
+ },
292
+ },
293
+ },
294
+ },
295
+ {
296
+ Name : "http_handler" ,
297
+ SpanKind : trace .SpanKindInternal ,
298
+ Status : sdktrace.Status {Code : codes .Error , Description : "input: user forbidden\n " },
299
+ Events : []sdktrace.Event {
300
+ {
301
+ Name : semconv .ExceptionEventName ,
302
+ Attributes : []attribute.KeyValue {
303
+ attribute .String ("graphql.errors.path" , "user" ),
304
+ semconv .ExceptionTypeKey .String ("github.com/aereal/otelgqlgen/test/resolvers.ForbiddenError" ),
305
+ semconv .ExceptionMessageKey .String ("forbidden" ),
286
306
attrStacktrace ,
287
307
},
288
308
},
@@ -352,17 +372,42 @@ func TestTracer(t *testing.T) {
352
372
Name : semconv .ExceptionEventName ,
353
373
Attributes : []attribute.KeyValue {
354
374
attribute .String ("graphql.errors.path" , "user.name" ),
355
- semconv .ExceptionTypeKey .String ("*gqlerror.Error" ),
356
- semconv .ExceptionMessageKey .String ("input: user.name invalid name" ),
375
+ semconv .ExceptionTypeKey .String ("*errors.errorString" ),
376
+ semconv .ExceptionMessageKey .String ("invalid name" ),
377
+ attrStacktrace ,
378
+ },
379
+ },
380
+ {
381
+ Name : semconv .ExceptionEventName ,
382
+ Attributes : []attribute.KeyValue {
383
+ attribute .String ("graphql.errors.path" , "user.age" ),
384
+ semconv .ExceptionTypeKey .String ("*errors.errorString" ),
385
+ semconv .ExceptionMessageKey .String ("invalid age" ),
386
+ attrStacktrace ,
387
+ },
388
+ },
389
+ },
390
+ },
391
+ {
392
+ Name : "http_handler" ,
393
+ SpanKind : trace .SpanKindInternal ,
394
+ Status : sdktrace.Status {Code : codes .Error , Description : "input: user.name invalid name\n input: user.age invalid age\n " },
395
+ Events : []sdktrace.Event {
396
+ {
397
+ Name : semconv .ExceptionEventName ,
398
+ Attributes : []attribute.KeyValue {
399
+ attribute .String ("graphql.errors.path" , "user.name" ),
400
+ semconv .ExceptionTypeKey .String ("*errors.errorString" ),
401
+ semconv .ExceptionMessageKey .String ("invalid name" ),
357
402
attrStacktrace ,
358
403
},
359
404
},
360
405
{
361
406
Name : semconv .ExceptionEventName ,
362
407
Attributes : []attribute.KeyValue {
363
408
attribute .String ("graphql.errors.path" , "user.age" ),
364
- semconv .ExceptionTypeKey .String ("*gqlerror.Error " ),
365
- semconv .ExceptionMessageKey .String ("input: user.age invalid age" ),
409
+ semconv .ExceptionTypeKey .String ("*errors.errorString " ),
410
+ semconv .ExceptionMessageKey .String ("invalid age" ),
366
411
attrStacktrace ,
367
412
},
368
413
},
@@ -404,6 +449,7 @@ func TestTracer(t *testing.T) {
404
449
attribute .Int ("graphql.operation.complexity.calculated" , 1 ),
405
450
},
406
451
},
452
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
407
453
},
408
454
},
409
455
{
@@ -439,6 +485,7 @@ func TestTracer(t *testing.T) {
439
485
attribute .Int ("graphql.operation.complexity.calculated" , 1 ),
440
486
},
441
487
},
488
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
442
489
},
443
490
},
444
491
{
@@ -501,6 +548,7 @@ func TestTracer(t *testing.T) {
501
548
attribute .Int ("graphql.operation.complexity.calculated" , 3 ),
502
549
},
503
550
},
551
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
504
552
},
505
553
},
506
554
{
@@ -537,6 +585,7 @@ func TestTracer(t *testing.T) {
537
585
attribute .Int ("graphql.operation.complexity.calculated" , 1 ),
538
586
},
539
587
},
588
+ {Name : "http_handler" , SpanKind : trace .SpanKindInternal },
540
589
},
541
590
},
542
591
}
@@ -556,7 +605,12 @@ func TestTracer(t *testing.T) {
556
605
options = append (options , otelgqlgen .WithTracerProvider (tp ))
557
606
gqlsrv .Use (otelgqlgen .New (options ... ))
558
607
gqlsrv .Use (extension .FixedComplexityLimit (1000 ))
559
- srv := httptest .NewServer (gqlsrv )
608
+ testTracer := tp .Tracer ("test" )
609
+ srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
610
+ ctx , span := testTracer .Start (r .Context (), "http_handler" )
611
+ defer span .End ()
612
+ gqlsrv .ServeHTTP (w , r .WithContext (ctx ))
613
+ }))
560
614
defer srv .Close ()
561
615
body , err := json .Marshal (tc .params )
562
616
if err != nil {
0 commit comments