CodexBloom - Programming Q&A Platform

Trouble with missing traces in Jaeger when using GraphQL with Apollo Server

👀 Views: 2 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-07
graphql apollo-server jaeger observability JavaScript

After trying multiple solutions online, I still can't figure this out. I need help solving Hey everyone, I'm running into an issue that's driving me crazy... I'm currently implementing observability for a Node.js application that uses Apollo Server with GraphQL, and I'm facing issues with missing traces in Jaeger. I'm using the `opentracing` library along with the `jaeger-client` version 0.14.0 to handle tracing. I've set up the Apollo Server with middleware for tracing, but I'm not seeing the traces for some of the resolvers. Here's the code I'm using for setting up the Apollo Server with tracing: ```javascript const { ApolloServer } = require('apollo-server'); const { initTracer } = require('jaeger-client'); const { ApolloServerPluginLandingPageLocalDefault } = require('apollo-server-core'); const config = { serviceName: 'my-service', }; const tracer = initTracer(config); const server = new ApolloServer({ typeDefs, resolvers, plugins: [ApolloServerPluginLandingPageLocalDefault()], context: ({ req }) => { const span = tracer.startSpan('graphql_request'); return { span }; }, }); server.listen().then(({ url }) => { console.log(`🚀 Server ready at ${url}`); }); ``` While the traces seem to work for some queries, others, especially those that involve nested resolvers, do not show up in Jaeger. I've also ensured that the spans are finished, but I still don't see them. I'm using the following approach in my resolvers: ```javascript const resolvers = { Query: { async getUser(_, { id }, { span }) { const userSpan = tracer.startSpan('getUser', { childOf: span }); try { const user = await User.findById(id); return user; } finally { userSpan.finish(); } }, }, }; ``` I tried enabling logging in the Jaeger client to see if there were any issues with the span reporting, but the logs didn't indicate any errors. The traces that do show up seem to have incomplete data, and I'm concerned that the middleware might not be properly wrapping all resolvers. I've also checked that the GraphQL operations are being executed as expected by logging the requests. Does anyone have experience with similar setups? How can I ensure all my resolvers properly create and finish spans so that they appear in Jaeger? For context: I'm using Javascript on Windows. My development environment is Linux. Any suggestions would be helpful. What are your experiences with this?