Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Cannot disable tracing response with graphql-spring-boot-starter version 15 #976

Open
steam0 opened this issue Nov 13, 2023 · 4 comments
Open
Labels

Comments

@steam0
Copy link

steam0 commented Nov 13, 2023

Describe the bug

I am in the progress of upgrading to version 15 of the following dependency

<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>${graphql-java-kickstart.version}</version>
</dependency>

When I do that I get an extensions object in my response like the one below:

{
    "extensions": {
        "tracing": {
            "version": 1,
            "startTime": "2023-11-13T11:31:29.328819Z",
            "endTime": "2023-11-13T11:31:29.435707Z",
            "duration": 107035750,
            "parsing": {
                "startOffset": 2249667,
                "duration": 2161084
            },
            "validation": {
                "startOffset": 7496208,
                "duration": 5197250
            },
            "execution": {
                "resolvers": [
                   (...)
                ] 
            }
        }
    }

I would like to disable this part of the response as it is simply too much data for my clients to load every time. I am reading in the documentation here: https://github.com/graphql-java-kickstart/graphql-spring-boot#tracing-and-metrics

Apollo style tracing along with two levels of metrics based on them are currently configurable. Full tracing is based on the GraphQL java implementation, and can be enabled in the application.yml or application.properties file: the default value is false, with "metrics-only" being available. Metrics-only does not add the tracing extension to the response.

However even if I set the value to metrics-only the extensions object is included.

graphql:
  servlet:
    mapping: /api/graphql
    enabled: true
    exception-handlers-enabled: true
    actuator-metrics: true
    tracing-enabled: metrics-only

The only way to disable the "extensions" part of the reponse object is by disabling graphql.servlet.actuator-metrics: false all together which is not desirable as we wish to produce actuator metrics.

Expected behavior

When setting the config paramter graphql.servlet.tracing-enabled: metrics-only the response from the servlet should not include the "extensions" object.

If applicable, add screenshots to help explain your problem.
MacOS Sonoma
Java17
Intellij
Spring Boot 3.1.4

@steam0 steam0 added the bug label Nov 13, 2023
@bsara
Copy link

bsara commented Dec 6, 2023

this is fixed by this: 4c5a3e0

It hasn't been released yet though.

In the mean time, you can add these spring beans as a workaround:

@Bean
@ConditionalOnExpression(
  "'${graphql.servlet.tracing-enabled:false}' == 'metrics-only' "
  + "|| '${graphql.servlet.tracing-enabled:false}' == 'true'"
)
public TracingInstrumentation tracingInstrumentation() {
  return new TracingInstrumentation();
}

@Bean
@ConditionalOnProperty(value = "graphql.servlet.actuator-metrics", havingValue = "true")
public MetricsInstrumentation metricsInstrumentation(
  MeterRegistry meterRegistry,
  @Value("${graphql.servlet.tracing-enabled}") String isTracingEnabled
) {
  return new MetricsInstrumentation(meterRegistry, Boolean.TRUE.toString().equalsIgnoreCase(isTracingEnabled)) {
    @Override
    public @NotNull CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionResult executionResult, InstrumentationExecutionParameters parameters, InstrumentationState rawState) {
      return super.instrumentExecutionResult(executionResult, parameters);
    }
  };
}

@steam0
Copy link
Author

steam0 commented Dec 7, 2023

Thank you @bsara.

When do you think the new release will ship?

@bsara
Copy link

bsara commented Dec 7, 2023

I don't control that, so I have no idea. Sorry.

@oliemansm
Copy link
Member

I've released v15.1.0 today

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants