newrelic / node-newrelic

New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com.
Apache License 2.0
966 stars 394 forks source link

Apollo Server GraphQL: Handling of Nested Resolvers #576

Open rr0214 opened 3 years ago

rr0214 commented 3 years ago

Apollo server plugin with their GraphQL Apollo Lambda function. Some feedback is that they are seeing 1000+ spans in some cases which are just related to GraphQL stuff all taking less than 1ms. Is there a way to dial back the instrumentation or control it more?

From Michael: "i've been thinking on the problem. i think i'd like to represent each unique resolve path in these situations once and then group the rest into a single segment/span that has attributes representing the individual invocation counts while still capturing individual metrics."


Ported from duplicate: https://github.com/newrelic/newrelic-node-apollo-server-plugin/issues/27

https://newrelic.slack.com/archives/G24GM9VRR/p1599855383012600

Setups with nested resolvers can result in resolvers being invoked per item returned at the highest level resolver. For larger datasets, that can result in a ton of data.

At a high level, here are some of the issues that may cause:

After doing some initial research, it seems likely the best approach would be to do some sort of merge of the segments/spans while keeping metrics unique. That being said, there's awkwardness there with starting/ending if there's any sort of repeat.

Other options possible to help with this issue or others, depending on what customer needs come up:

Will want to consider impacts to metrics to still allow for best possible tracking down of issues on a per-field resolver basis.

kmudduluru commented 1 month ago

still valid

workato-integration[bot] commented 1 month ago

https://new-relic.atlassian.net/browse/NR-292127