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

enable graphql tracing & machine readable logging option #220

Merged
merged 2 commits into from
Mar 22, 2022
Merged

Conversation

Voxelot
Copy link
Member

@Voxelot Voxelot commented Mar 22, 2022

This PR enables API error logging via tracing middleware both at the axum and the async_graphql layer.

Now when a bad request is made, the error will appear in the fuel-core logs like this:

Mar 21 18:57:05.682  INFO fuel_core::service::graph_api: Binding GraphQL provider to 127.0.0.1:4000
Mar 21 18:57:54.568 ERROR request:execute:field{path=dryRun parent_type=Mutation return_type=[Receipt!]!}: async_graphql::graphql: error=unexpected block execution error TransactionIdCollision(0x656da2b4912aa59d2beee8a36fa352e98efdd89a063a556b910ef4b1531d7733)

It also adds the HUMAN_LOGGING env var, which allows for json structured logging in deployed environments. This will make it easier to search & filter logs using elastic search for example.

HUMAN_LOGGING=false cargo run -p fuel-core

{"timestamp":"Mar 21 21:22:15.564","level":"INFO","fields":{"message":"Binding GraphQL provider to 127.0.0.1:4000"},"target":"fuel_core::service::graph_api"}

@Voxelot Voxelot requested review from adlerjohn and vlopes11 March 22, 2022 02:11
@Voxelot Voxelot requested a review from rfuelsh March 22, 2022 03:36
@Voxelot Voxelot changed the title enable tracing on axum and async_graphql enable graphql tracing & machine readable logging option Mar 22, 2022
Copy link
Contributor

@vlopes11 vlopes11 left a comment

Choose a reason for hiding this comment

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

LGTM.

We should consider also to always log to stderr

@Voxelot
Copy link
Member Author

Voxelot commented Mar 22, 2022

I think that's how it currently works in all cases due to

.with_writer(std::io::stderr)

@adlerjohn adlerjohn added the enhancement New feature or request label Mar 22, 2022
@rfuelsh
Copy link
Member

rfuelsh commented Mar 22, 2022

lgtm!

@Voxelot Voxelot merged commit 68f1208 into master Mar 22, 2022
@Voxelot Voxelot deleted the api-tracing branch March 22, 2022 20:27
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
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants