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

improvement: Igni/test span bump #359

Merged
merged 3 commits into from
Jan 26, 2022
Merged

improvement: Igni/test span bump #359

merged 3 commits into from
Jan 26, 2022

Conversation

o0Ignition0o
Copy link
Contributor

@o0Ignition0o o0Ignition0o commented Jan 24, 2022

🔧 improvement: Test_span: add more powerful filtering capabilities, to remove non determinism in tests.

This PR bumps test-span to version 0.2.0 which allows us to add log level filters according to our dependencies; eg:

#[test_span(tokio::test)]
#[target(reqwest=tracing::Level::INFO)]
#[target(reqwest_tracing=tracing::Level::INFO)]
#[target(hyper::client=tracing::Level::INFO)]

etc.

This allows us to remove some deps logs that are non deterministic at the moment.

@o0Ignition0o
Copy link
Contributor Author

ogod forgot to rebase 😭

…terminism in tests.

This PR bumps test-span to version 0.2.0 which allows us to add log level filters according to our dependencies; eg:

apollo_router=tracing::Level::DEBUG
reqwest=tracing::Level::WARN

etc.

This allows us to remove some deps logs that are non deterministic at the moment.
@o0Ignition0o o0Ignition0o changed the title Igni/test span bump improvement: Igni/test span bump Jan 24, 2022
Copy link
Contributor

@garypen garypen left a comment

Choose a reason for hiding this comment

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

I'm not sure if my comments are correct, but worth asking I guess.

Comment on lines 69 to 71
#[target(reqwest=tracing::Level::INFO)]
#[target(reqwest_tracing=tracing::Level::INFO)]
#[target(hyper::client=tracing::Level::INFO)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we actually want:

#[level(tracing::Level::ERROR)]
#[target(apollo_router=tracing::Level::DEBUG)]
#[target(apollo_router_core=tracing::Level::DEBUG)]

to reduce the prospect of interference?

The above should mean we only get messages at level ERROR from things which aren't apollo_router or apollo_router_core. I believe that's the goal, but I could be on the wrong track...

Copy link
Contributor Author

@o0Ignition0o o0Ignition0o Jan 25, 2022

Choose a reason for hiding this comment

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

Hmm that's a very interesting comment!

the default level for all logs in test_span is debug, unless specified otherwise, which means this tests kind of unfolds to:

#[level(tracing::Level::DEBUG)]
#[target(reqwest=tracing::Level::INFO)]
#[target(reqwest_tracing=tracing::Level::INFO)]
#[target(hyper::client=tracing::Level::INFO)]

which effectively means we're tracking spans and logs at the DEBUG level unless it's from reqwest, reqwest_tracing, and hyper.

What teases my mind is that your comment may call for a workspace level and a dependencies level, which I'll happily open an issue for in test_span, if it sounds good to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

The generally accepted default for log/tracing levels is INFO. That means it's a bit "surprising" (as in principle of least surprise) that test_span's default level is DEBUG.

That aside, I think that if we were going to vary from INFO as a default, then we should probably vary to ERROR, to make logging an (almost) "opt-in" decision and thus attempt to minimize random variability when new dependencies are added.

I'd probably prefer: default is INFO (so no surprises) and also recommend that people configure a default of ERROR (as I did) and opt-in for the stuff they want to capture rather than specifying what they want to exclude (which is more fragile and likely to break as crates are added/removed).

My second preference would be to set the default to ERROR and again require an opt-in for stuff you are interested in.

Copy link
Contributor Author

@o0Ignition0o o0Ignition0o Jan 25, 2022

Choose a reason for hiding this comment

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

I feel like defaulting to INFO would make a lot of sense indeed, I'm not quite sure ERROR would be a sensible default for a span / logs snapshots crate.

However when it comes to apollo_rs setting the log level to ERROR (or INFO) wouldn't show interesting spans, thus defeating the purpose of "having regression tests that prevents us from breaking the tracing spans layout we have in place when it comes to processing a graphql request".

I'm opening an issue!

Copy link
Contributor

Choose a reason for hiding this comment

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

But wouldn't you just add an entry for apollo_rs? e.g.:

#[target(apollo_rs=tracing::Level::DEBUG)]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that works as well!

#[target(apollo_router=tracing::Level::DEBUG)]

apollo-router/tests/integration_tests.rs Outdated Show resolved Hide resolved
@o0Ignition0o o0Ignition0o requested a review from garypen January 26, 2022 08:54
Copy link
Contributor

@garypen garypen left a comment

Choose a reason for hiding this comment

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

This looks great!

@o0Ignition0o o0Ignition0o merged commit 9c0281e into main Jan 26, 2022
@o0Ignition0o o0Ignition0o deleted the igni/test_span_bump branch January 26, 2022 09:08
@@ -77,7 +77,7 @@ mockall = "0.11.0"
reqwest = { version = "0.11.9", features = ["json", "stream"] }
serde_json_bytes = { version = "0.2.0", features = ["preserve_order"] }
test-log = { version = "0.2.8", default-features = false, features = ["trace"] }
test-span = "0.1.1"
test-span = "0.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

We write versions in full so we have a track of what was the last working version

Suggested change
test-span = "0.3"
test-span = "0.3.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will open a followup then!

@abernix
Copy link
Member

abernix commented Feb 3, 2022

Just creating a link to the upstream PR: apollographql/test-span#11

@o0Ignition0o o0Ignition0o self-assigned this Mar 25, 2022
tinnou pushed a commit to Netflix-Skunkworks/router that referenced this pull request Oct 16, 2023
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: apollo-bot2 <apollo-bot2@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants