
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
graphql-middleware-jaeger
Advanced tools
The easiest way to add tracing support to your GraphQL service
Based on the OpenCensus project, this minimal library provides an easy solution to add basic tracing to your services. Recorded traces are exported to a supplied Jaeger instance automatically.
First of all, install this middleware from your package registry by running the following:
yarn add graphql-middleware-jaeger
# or using npm
npm i graphql-middleware-jaeger
After this is done, you can simply add the middleware to your existing service, it could look like the following snippet
import { graphqlJaegerMiddleware } from 'graphql-middleware-jaeger';
import { makeExecutableSchema } from 'graphql-tools';
import { applyMiddleware } from 'graphql-middleware';
import { gql, ApolloServer } from 'apollo-server';
import { Request, Response } from 'express';
...
const tracingMiddleware = graphqlJaegerMiddleware<IContext>(
{ logLevel: 3, samplingRate: 1 },
{ host: 'tracing', serviceName: 'example-service' },
{ rootSpanOptions: { name: 'graphqlRequest' } },
{
preResolve: [
({ context, rootSpan }) => {
const { req } = context;
rootSpan.addAttribute('ip', req.ip);
}
]
}
);
const withTracing = {
Query: tracingMiddleware,
Mutation: tracingMiddleware
};
const schema = applyMiddleware(
makeExecutableSchema({ typeDefs, resolvers }),
withTracing
);
The core principle of this package is to stay as unopinionated as possible towards the actual usage, which is why you can configure every aspect, except the run-time behaviour of resolving the middleware.
You can configure the OpenCensus tracer, as well as the Jaeger exporter. For more details, head over to the OpenCensus Node.js repository.
Since there's contextual data that you might want to add to your span, this middleware allows you to define a number of hooks triggered at specific execution points. An example of the usage of hooks is included in the example code above.
Available hooks are: preResolve
, postResolve
, resolveError
FAQs
GraphQL Jaeger tracing middleware based on OpenCensus
We found that graphql-middleware-jaeger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.