Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add operation name to operationWrapper of querystring in GraphQLRequestSerializer #590

Closed
idegroot opened this issue Mar 16, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@idegroot
Copy link

I would like to trace the timing of resolving the distinct query operations in my graphql project. The metrics are added to the Spring Actuator when the operationName is present in the query, otherwise the operationName is set to "unknown" (see also [https://github.com/graphql-java-kickstart/graphql-java-servlet/issues/264] and [https://spectrum.chat/graphql-java/general/reading-operationname-from-query-text~30cc09d5-0a55-4406-88da-7e8d0b91141a]).

In GraphQLRequestSerializer only the operationType is added to the serialized form. It would be very helpful if also the operationName would be added.

So the serialized query request should be changed from:
"query { MyOperationName: MyOperationName(...) {....} }"

to:
"query MyOperationName { MyOperationName: MyOperationName(...) {....} }"

The reporting will then change from

# TYPE graphql_timer_query_seconds_max gauge
graphql_timer_query_seconds_max{application="my-service",operation="execution",operationName="unknown",} 0.834386921
graphql_timer_query_seconds_max{application="my-service",operation="validation",operationName="unknown",} 0.011841088
graphql_timer_query_seconds_max{application="my-service",operation="parsing",operationName="unknown",} 0.005506738

to

# TYPE graphql_timer_query_seconds_max gauge
graphql_timer_query_seconds_max{application="my-service",operation="execution",operationName="MyOperationName1",} 0.536624579
graphql_timer_query_seconds_max{application="my-service",operation="execution",operationName="MyOperationName2",} 0.265046921
graphql_timer_query_seconds_max{application="my-service",operation="parsing",operationName="MyOperationName2",} 7.57737E-4
graphql_timer_query_seconds_max{application="my-service",operation="parsing",operationName="MyOperationName1",} 0.003428935
graphql_timer_query_seconds_max{application="my-service",operation="validation",operationName="MyOperationName1",} 0.011300205
graphql_timer_query_seconds_max{application="my-service",operation="validation",operationName="MyOperationName2",} 0.001935768
@jxnu-liguobin
Copy link
Collaborator

jxnu-liguobin commented Mar 16, 2021

Similar to this issue #559, it is an improvement to query.
This is an optional field for the graphql specification, so it depends on whether the author accepts it or not. 😄

@idegroot
Copy link
Author

I tried the new version in the pull request and it works exactly as I would like. Thank you so much.

When is this expected to be released?

@kobylynskyi
Copy link
Owner

@idegroot 4.1.6 was released today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants