Rename OpenTelemetry traces based on operation name (named queries)

Hello Apollo community,

I have a federated Apollo Graph (using ApolloGateway) and a bunch of subgraph microservices. I’ve set them up to do distributed tracing via OpenTelemetry.
Now, it does produce a bunch of traces that I can see in my backend (Elastic APM). However, they are all named ‘graphql.execute’, ‘graphql.parse’, etc. It is not easy to look for a specific mutation or query to monitor.
What I want to do instead is to take the operation name from the named queries like:

query HeroNameAndFriends {
  hero {
    name
    friends {
      name
    }
  }
}

and rename the entire trace to HeroNameAndFriends.

  • Is that an acceptable, recommended thing to do?
  • How would I achieve that?
  • Do subgraphs have access to the name of the named queries? Can I start small from one of the microservices or do I have to modify the Gateway?

Thank you!