Java Metrics Plugin

The Stellate Plugin for GraphQL Java is a powerful tool designed to enhance the development experience by providing insights into the performance and usage of GraphQL queries within an application using GraphQL Java.

This Java library integrates Stellate with your existing application using GraphQL Java and allows you to log metrics about your requests to Stellate. It achieves this by exposing an [Instrumentation]( that can be used with GraphQL Java.

Benefits of the Java Metrics Plugin

  • Performance Monitoring: Track the execution time of each GraphQL query and mutation to identify bottlenecks and optimize response times.
  • Field Usage Tracking: Monitor the usage frequency of fields within your schema to inform deprecation strategies and schema evolution.
  • Error Tracking: Capture and log errors that occur during query execution to improve the reliability and stability of the GraphQL API.
  • Instrumentation Integration: Leverage GraphQL Java's instrumentation feature to plug in the metrics collector without invasive changes to your codebase.

Before You Begin

  • To get started with the Java Metrics Plugin for GraphQL Java, ensure that you have Java 11 or higher installed.
  • The Java library expects com.graphql-java:graphql-java to be installed in your project as well.

Install the Java Library

The Stellate Java library is published to the Maven Central Repository:

  • groupId: co.stellate
  • artifactId: stellate

You can check the Maven (MVN) Repository to validate that the artifact is indexed.

Add the Library to Gradle

Add the Java library to your list of dependencies in your build.gradle file:

repositories {
dependencies {
  implementation 'co.stellate:stellate'

Add the Dependency to Maven

Add the dependency, as shown in the following example, in your pom.xml file:


Set up your Java Plugin

When building your GraphQL object (from com.graphql-java), you can add the StellateInstrumentation exposed by this library as shown in the following example:

import co.stellate.stellate.StellateInstrumentation;

// The name of your Stellate service
String serviceName = "my-stellate-service";

// A logging token for the above Stellate service
String token = "stl8log_xyz";

GraphQL myGraphQL = GraphQL.newGraphQL(schema)
    .instrumentation(new StellateInstrumentation(serviceName, token))

By adding the StellateInstrumentation instrumentation to your GraphQL instance, the plugin will start collecting metrics automatically. You can access these metrics through the Stellate Dashboard.

Using the Plugin with Spring

If you use Spring for GraphQL then you can get access to the GraphQL object to add the StellateInstrumentation like so:

import org.springframework.boot.autoconfigure.graphql.GraphQlSourceBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import co.stellate.stellate.StellateInstrumentation;

@Configuration(proxyBeanMethods = false)
class GraphQlConfig {
    public GraphQlSourceBuilderCustomizer sourceBuilderCustomizer() {
        return (builder) -> builder.configureGraphQl(graphQlBuilder -> {
            graphQlBuilder.instrumentation(new StellateInstrumentation(

Discover more