dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

Add option to skip Introspection tracing

Open liamzhang40 opened this issue 11 months ago • 4 comments

Thanks for creating this tracer for gqlgen contrib/99designs/gqlgen.

I find it unnecessary to trace the Introspection Query since it creates a huge amount of spans. Can there be an option to disable the tracing of it? Specifically the field spans

We currently wrap around gqlTracer and create a new tracer that looks at the OperationName from gql context and just skips if it is a Introspection query

func (t *wrapperGQLTracer) InterceptField(ctx context.Context, next graphql.Resolver) (any, error) {
	opCtx := graphql.GetOperationContext(ctx)
	if opCtx.OperationName == "IntrospectionQuery" {
		res, err := next(ctx)
		return res, err
	}

	if t, ok := t.baseTracer.(graphql.FieldInterceptor); ok {
		return t.InterceptField(ctx, next)
	}

	res, err := next(ctx)
	return res, err
}

Similar to this https://github.com/DataDog/dd-trace-js/issues/1046

liamzhang40 avatar Mar 12 '24 19:03 liamzhang40

@liamzhang40 We reviewed it, and we wanted to share it's accepted. If you want to contribute, we'll be glad to review and merge your contribution.

darccio avatar Apr 30 '24 14:04 darccio

@liamzhang40, I assume #2695 covers what you were looking for?

samsullivan avatar May 15 '24 17:05 samsullivan

@liamzhang40, I assume #2695 covers what you were looking for?

Yup! and skipping the trivial is icing on the cake

liamzhang40 avatar May 16 '24 20:05 liamzhang40

Glad skipping trivial doesn't just apply to our use case! :tada:

samsullivan avatar May 16 '24 20:05 samsullivan

👋 This option has been implemented in #2695 and it should be included in v1.66.0 (it is expected to be released in July).

rarguelloF avatar Jul 09 '24 10:07 rarguelloF