Skip to content

Commit 785b833

Browse files
[tracer] add tag response data
1 parent df66357 commit 785b833

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

graphql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
172172

173173
validationFinish := s.validationTracer.TraceValidation()
174174
errs := validation.Validate(s.schema, doc, variables, s.maxDepth)
175-
validationFinish(errs)
175+
validationFinish(nil, errs)
176176
if len(errs) != 0 {
177177
return &Response{Errors: errs}
178178
}
@@ -229,7 +229,7 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
229229
}
230230
traceCtx, finish := s.tracer.TraceQuery(ctx, queryString, operationName, variables, varTypes)
231231
data, errs := r.Execute(traceCtx, res, op)
232-
finish(errs)
232+
finish(data, errs)
233233

234234
return &Response{
235235
Data: data,

internal/exec/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func execFieldSelection(ctx context.Context, r *Request, s *resolvable.Schema, f
183183

184184
traceCtx, finish := r.Tracer.TraceField(ctx, f.field.TraceLabel, f.field.TypeName, f.field.Name, !f.field.Async, f.field.Args)
185185
defer func() {
186-
finish(err)
186+
finish(f.out.Bytes(), err)
187187
}()
188188

189189
err = func() (err *errors.QueryError) {

subscriptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (s *Schema) subscribe(ctx context.Context, queryString string, operationNam
3838

3939
validationFinish := s.validationTracer.TraceValidation()
4040
errs := validation.Validate(s.schema, doc, variables, s.maxDepth)
41-
validationFinish(errs)
41+
validationFinish(nil, errs)
4242
if len(errs) != 0 {
4343
return sendAndReturnClosed(&Response{Errors: errs})
4444
}

trace/trace.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/opentracing/opentracing-go/log"
1212
)
1313

14-
type TraceQueryFinishFunc func([]*errors.QueryError)
15-
type TraceFieldFinishFunc func(*errors.QueryError)
14+
type TraceQueryFinishFunc func([]byte, []*errors.QueryError)
15+
type TraceFieldFinishFunc func([]byte, *errors.QueryError)
1616

1717
type Tracer interface {
1818
TraceQuery(ctx context.Context, queryString string, operationName string, variables map[string]interface{}, varTypes map[string]*introspection.Type) (context.Context, TraceQueryFinishFunc)
@@ -33,7 +33,7 @@ func (OpenTracingTracer) TraceQuery(ctx context.Context, queryString string, ope
3333
span.LogFields(log.Object("graphql.variables", variables))
3434
}
3535

36-
return spanCtx, func(errs []*errors.QueryError) {
36+
return spanCtx, func(data []byte, errs []*errors.QueryError) {
3737
if len(errs) > 0 {
3838
msg := errs[0].Error()
3939
if len(errs) > 1 {
@@ -58,7 +58,7 @@ func (OpenTracingTracer) TraceField(ctx context.Context, label, typeName, fieldN
5858
span.SetTag("graphql.args."+name, value)
5959
}
6060

61-
return spanCtx, func(err *errors.QueryError) {
61+
return spanCtx, func(data []byte, err *errors.QueryError) {
6262
if err != nil {
6363
ext.Error.Set(span, true)
6464
span.SetTag("graphql.error", err.Error())
@@ -67,14 +67,14 @@ func (OpenTracingTracer) TraceField(ctx context.Context, label, typeName, fieldN
6767
}
6868
}
6969

70-
func noop(*errors.QueryError) {}
70+
func noop([]byte, *errors.QueryError) {}
7171

7272
type NoopTracer struct{}
7373

7474
func (NoopTracer) TraceQuery(ctx context.Context, queryString string, operationName string, variables map[string]interface{}, varTypes map[string]*introspection.Type) (context.Context, TraceQueryFinishFunc) {
75-
return ctx, func(errs []*errors.QueryError) {}
75+
return ctx, func(data []byte, errs []*errors.QueryError) {}
7676
}
7777

7878
func (NoopTracer) TraceField(ctx context.Context, label, typeName, fieldName string, trivial bool, args map[string]interface{}) (context.Context, TraceFieldFinishFunc) {
79-
return ctx, func(err *errors.QueryError) {}
79+
return ctx, func(data []byte, err *errors.QueryError) {}
8080
}

trace/validation_trace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ type ValidationTracer interface {
1313
type NoopValidationTracer struct{}
1414

1515
func (NoopValidationTracer) TraceValidation() TraceValidationFinishFunc {
16-
return func(errs []*errors.QueryError) {}
16+
return func(data []byte, errs []*errors.QueryError) {}
1717
}

0 commit comments

Comments
 (0)