Skip to content

Add graphql queries error codes metrics #12833

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

Merged
merged 4 commits into from
Jun 24, 2025

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Jun 24, 2025

Context

Added to the existing useGraphQLErrorHandlerHook yoga hook to increment metrics after all query executions based on their error codes. I originally wanted to create a new useMetrics hook but most of the error handling was done in useGraphQLErrorHandlerHook so we decided to keep it there for now.

Screenshot 2025-06-24 at 15 58 26

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added GraphQL query error metrics tracking through MetricsService integration with the existing useGraphQLErrorHandlerHook, enabling monitoring of operation outcomes using HTTP status codes.

  • Implemented error code metrics tracking in core-modules/graphql/hooks/use-graphql-error-handler.hook.ts by mapping GraphQL errors to HTTP status codes (200, 400, 401, etc.)
  • Added six new metric keys in metrics-keys.type.ts following existing naming patterns for tracking different response codes
  • Modified MetricsService to handle optional eventIds, improving flexibility in metrics collection
  • Integrated MetricsModule across the application through changes in app.module.ts and metadata-related modules
  • Maintained existing error handling while adding comprehensive metrics collection for system observability

7 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Comment on lines +40 to 41
metricsService: metricsService,
exceptionHandlerService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: metricsService should be placed after exceptionHandlerService to maintain consistent property ordering with the function parameters

@Weiko Weiko enabled auto-merge (squash) June 24, 2025 14:11
@charlesBochet charlesBochet disabled auto-merge June 24, 2025 14:13
@charlesBochet charlesBochet merged commit ed11cac into main Jun 24, 2025
41 checks passed
@charlesBochet charlesBochet deleted the c--add-graphql-metrics-error-codes branch June 24, 2025 14:13
Copy link
Contributor

github-actions bot commented Jun 24, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:65356

This environment will automatically shut down when the PR is closed or after 5 hours.

abdulrahmancodes pushed a commit to abdulrahmancodes/twenty that referenced this pull request Jun 26, 2025
## Context
Added to the existing useGraphQLErrorHandlerHook yoga hook to increment
metrics after all query executions based on their error codes. I
originally wanted to create a new useMetrics hook but most of the error
handling was done in useGraphQLErrorHandlerHook so we decided to keep it
there for now.

<img width="1310" alt="Screenshot 2025-06-24 at 15 58 26"
src="https://github.com/user-attachments/assets/498d3754-851a-4051-a5c2-23ac8253aa6a"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants