GraphQL opentelemetry instrumentation ignoreTrivialResolveSpans not working

I’m running an Apollo v4 server with @opentelemetry/instrumentation-graphql registered from the following initialisation:

new GraphQLInstrumentation({
      ignoreTrivialResolveSpans: true
    })

I then do a simple query for a single instance of a type with 4 requested fields, one of which is __typename, one of which has a non-default resolver and the remaining two have no explicitly assigned resolver.

Regardless of the setting of ignoreTrivialResolveSpans above, I always see 3 field-level graphql.resolve spans in my exported trace; the one for __typename is never present, but both non-default and defaulted resolved fields generate spans. My understanding was that fields for which I had not defined a resolver should not generate spans if ignoreTrivialResolveSpans is set true.

Has anyone managed to use this flag with Apollo Server v4 to suppress default resolve spans? Could calling makeExecutableSchema be adding “non-default” wrappers to my resolver functions and effectively rendering this flag useless?

(note that setting the depth option of GraphQLInstrumentation to 0 does work, but I would prefer a solution where it was possible to generate spans for “interesting” resolvers)

Hi @Alan_Boshier ,

were you able to fix this somehow? We are having the same issue. Our traces are full of useless resolve spans and ignoreTrivialResolveSpans does not do anything

Hi @Holalko - unfortunately I could not fix this, and had to resort to setting the depth option of GraphQLInstrumentation to 1 to avoid a flood of spans. Its not ideal as there are some resolvers below depth 1 I would really like to have traced.

My guess is still that the makeExecutableSchema function is wrapping default resolvers in such a way as to indicate to the telemetry code that they are no-longer “trivial”. But no-one from Apollo has responded to confirm this.