cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query details of GraphQL

nhutdangqn
Newcomer_

Hi team, 

I'm using Java, Netflix DGS, and WebFlux. I want to see what kind of query being made to /graphql (operation name in /graphql endpoint)

nhutdangqn_0-1692759958415.png

But on my test, it wasn’t shown. Could you guys help me?

Many thanks!

6 REPLIES 6

Julius_Loman
DynaMight Legend
DynaMight Legend

If you know where in your code or in the library code is the query used, you can configure request attributes capturing the method arguments. You can also use OpenTelemetry instrumentation for GraphQL and have Dynatrace capture the span attributes provided by the OpenTelemetry instrumentation, which is probably the easiest way.

Be sure to check the Observability clinic recording on GraphQL and Dynatrace and how to leverage OpenTelemetry to provide you with more insights into your GraphQL applications.  

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner
GraphQL is very a popular query language for APIs as it abstracts away the complexity of querying multiple API endpoints, merging and filtering the data to a single result set. The complexity comes in troubleshooting and operating systems at scale without the proper observability to diagnose and ...

Hi @Julius_Loman , 

Thank you for your reply.

 Observability clinic is talking GraphQL and Node but I'm using GraphQL in Java so It can't help me now. Could you have any documentation about GraphQL, Java, Netflix DGS, and WebFlux?

 

@nhutdangqn there is a section about other languages at https://www.youtube.com/watch?v=_-ZPhwOWzmw&t=1542s , basically mentioning you should use https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/graph... in your project. The docs seys a standalone instrumentation is supported, so you don't need OpenTelemetry Java Agent for it.

Also, be sure to have the OneAgent feature flag for Opentelemetry turned on (OpenTelemetry (Java) ), so Dynatrace can pick up the OpenTelemetry spans. 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner
GraphQL is very a popular query language for APIs as it abstracts away the complexity of querying multiple API endpoints, merging and filtering the data to a single result set. The complexity comes in troubleshooting and operating systems at scale without the proper observability to diagnose and ...

Maziz
Visitor

@Julius_Loman  and anyone,

does that mean dynatrace doesn't support graphql tracing besides nodejs out of the box?

We assumed it support graphql in general out of the box https://www.dynatrace.com/hub/detail/graphql/.

Thanks in advance.

Yes , that's correct. Only NodeJS is supported out of box as it is mentioned in the technology support page and also on the hub page. For traces from other languages you need to use either opentelemetry or create a custom instrumentation with the otel being a recommended approach.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Klapsa2503
Newcomer_

Our team has included operation name in the logs with following steps:

1. define global request attribute

 

1.png

2. inject custom attribute with one agent sdk

 

@Component
@RequiredArgsConstructor
public class DynatraceGraphQlInstrumentation extends SimplePerformantInstrumentation {

    private final OneAgentSDK oneAgentSDK;

    @Override
    public @NotNull ExecutionContext instrumentExecutionContext(
            ExecutionContext executionContext,
            InstrumentationExecutionParameters parameters,
            InstrumentationState state) {
        oneAgentSDK.addCustomRequestAttribute("graphqlOperationName", executionContext.getOperationDefinition().getName());
        return super.instrumentExecutionContext(executionContext, parameters, state);
    }

}

 

3. define global request naming rule with the API. This makes operation name became visible in the request name. Docs https://docs.dynatrace.com/docs/dynatrace-api/configuration-api/service-api/request-naming-api.

 

Final result:

2.png

 

Featured Posts