Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/instrumentation-graphql

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/instrumentation-graphql

OpenTelemetry instrumentation for `graphql` gql query language and runtime for GraphQL

  • 0.44.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-41.02%
Maintainers
3
Weekly downloads
 
Created

What is @opentelemetry/instrumentation-graphql?

@opentelemetry/instrumentation-graphql is an npm package that provides automatic tracing and monitoring for GraphQL operations using OpenTelemetry. It helps in capturing performance metrics, tracing GraphQL queries, mutations, and resolvers, and integrating these metrics with various observability backends.

What are @opentelemetry/instrumentation-graphql's main functionalities?

Automatic Tracing of GraphQL Operations

This feature allows you to automatically trace GraphQL operations such as queries and mutations. The code sample demonstrates how to set up the GraphQL instrumentation with OpenTelemetry's NodeTracerProvider.

const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new GraphQLInstrumentation({
      // Configuration options
    })
  ],
  tracerProvider: provider,
});

Custom Span Naming

This feature allows you to customize the names of the spans created for GraphQL operations. The code sample shows how to rename the root span based on the operation name.

const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');

const graphqlInstrumentation = new GraphQLInstrumentation({
  mergeItems: true,
  renameRootSpan: (operation) => `graphql-${operation.operationName}`,
});

Capture Resolver Spans

This feature enables capturing spans for individual resolvers within a GraphQL operation. The code sample demonstrates how to configure the instrumentation to capture resolver spans up to a certain depth.

const { GraphQLInstrumentation } = require('@opentelemetry/instrumentation-graphql');

const graphqlInstrumentation = new GraphQLInstrumentation({
  allowValues: true,
  depth: 2,
});

Other packages similar to @opentelemetry/instrumentation-graphql

Keywords

FAQs

Package last updated on 25 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc