Repository navigation
add testctx for instrumenting integration tests with OTel - #7532
Conversation
fce3155 to
2a852b2
Compare
75362ad to
9ce94b7
Compare
e84863e to
67e63b7
Compare
c1ceeef to
2669559
Compare
|
Ah I hate to be the bearer of bad news - but it looks like the |
There was a problem hiding this comment.
Phew 🎉 Installing deps here was kinda bad.
|
@jedevc Yeah I'm not sure what's up with that. I saw the GHA jobs were slower yesterday for some reason, but if you look at the actual traces they complete faster than This PR:
There are conflicts now so I'll rebase and see if the weird GHA slowness happens again. |
* testing.T -> testctx.T
* parallel by default (currently no way _not_ to)
* carries around a context.Context
* supports middleware patterns, e.g. for OTel instrumentation
* embeds *testing.T, so fully compatible; if you need the concrete
type, just access the field
* tests now live on a Suite
Signed-off-by: Alex Suraci <[email protected]>
ended up timing out while waiting on t.Parallel Signed-off-by: Alex Suraci <[email protected]>
apparently the second column is number of hardlinks; we dont care Signed-off-by: Alex Suraci <[email protected]>
it expected t.Run to run in series Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
something is hiding race detector output. the new instrumentation replaces the need for prettified output and slowness reports, so let's just eliminate a variable. Signed-off-by: Alex Suraci <[email protected]>
failed twice, but looks like our infra is just slow Signed-off-by: Alex Suraci <[email protected]>
|
Happened again.
wat? Comparing span count:
A bit of a difference there but that's not surprising considering what the PR does. There doesn't seem to be much slowdown on the Cloud side; I was able to view the completed trace there while the GHA job was ongoing. Comparing the raw logs (PR vs. main, there is a pretty big difference: Guess I'll look into that next. |
just to see if it makes any difference Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
This reverts commit 8951032. Signed-off-by: Alex Suraci <[email protected]>
Rather than logging to the test span, log to the underlying test logger. When we log to the test span we're unconditionally sending what is in total a massive amount of log volume. Previously we only saw these logs on test failure, so this change brings us back to that by sending them to the underlying *testing.T logger instead. Signed-off-by: Alex Suraci <[email protected]>
|
@jedevc Figured it out. Previously we would send test client logs (i.e. But this PR changed that to send test logs to The thing is, those logs are completely redundant with the data already being sent over telemetry. I was already tempted to remove it because it made the output pretty verbose, although it was kind of cool to see the plain logs format side-by-side with the TUI. So, the latest commit changes the client Seems like it did the trick; now the tests finish in approximately the same amount of time as (Except the latest |
|
Woo thanks for diving into all this 🎉 Merged this now, just to avoid accidentally merging something before this that would have required more rebase hell for you 😢 |
Adds
testsctx, a little*testing.Tcompatible testing library that addsctxpropagation and middleware. Ideally we'd extract it for general use once it's fully baked so Go folks can use it and get pretty OTel integration in Cloud.Adds the following
testctxmiddleware to our integration test suite:t.Paralleleverywhere. Non-parallel tests have been adapted to work in parallel. (I think.)t.Name()or something (i.e. put "sync" in the test name), or we can just add a non-parallel suite that doesn't use the middleware and treat it like tracking tech debt.t.Logand friends log to the OTel span.The net result is a fully instrumented integration test suite, where you don't have to read
go testorgotestsumoutput; you can just see everything visualized in the TUI or Cloud.TODO (in future PRs):
testctxdesignFooSuitetype is mostly a convenient way to corral around a set of methods, but currently the value itself serves no purpose. Worse, it's tempting to put state there, butt.Runsub-tests will all capture the same var, causing race conditions.t.Parallel?t.Parallelas a primitive for compatibility withgo test- there's no way to access the-parallelflag value, so we have to just respect it. Don't want a custom CLI.Leaving these alone for now because they're hard and I'm tired of rebasing this PR. 😅