op-devstack,op-service: context-logging, better test contexts, and log filters#16098
Merged
protolambda merged 2 commits intodevelopfrom May 23, 2025
Merged
op-devstack,op-service: context-logging, better test contexts, and log filters#16098protolambda merged 2 commits intodevelopfrom
protolambda merged 2 commits intodevelopfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #16098 +/- ##
============================================
- Coverage 82.34% 58.39% -23.95%
============================================
Files 161 63 -98
Lines 8812 4927 -3885
============================================
- Hits 7256 2877 -4379
- Misses 1416 1905 +489
- Partials 140 145 +5
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
614a315 to
d45ac20
Compare
Contributor
Author
|
I'll rebase this PR once #16050 is merged. There's a new log env variable that we'd like to be compatible. Probably best applied as a default preset option in this new log-level setting. Edit: done, ready for review. |
d45ac20 to
9862f7e
Compare
teddyknox
reviewed
May 23, 2025
teddyknox
reviewed
May 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This depends on op-geth PR - ethereum-optimism/op-geth#611
Do not merge this monorepo PR until we update theDone.go.modto point to the squash-merge commit once ready.The lack of context info and log-filters per service was making debugging this week terrible, so I made changes so we can productively debug again, with configurable logging and all the annotated context at all times.
Features
Context-logging
Support for context-logging: attach a ctx to a log, and the log-handler can inspect it to adapt what happens, and track execution events.
And any log without context will get the default context from the logger, so test-scopes, services, etc. are always tagged by default.
This removes a log-wrapper hack we used to have in devstack. The logger is the native logger again now.
This also updates the testlogger to support the new extended logging interface.
Log handler composition
Log handler composition: allow for wrapping/unwrapping. So the different log handler utils we have all become compatible.
I updated the existing handler utils (the dynamic log level handler, the trace handler, and the log-capturer) to support this.
Log filtering
Efficient log filtering, at the
slog.Handler.Enabledlevel where it's intended to be filtered.Based on log context the calls can now be filtered, or adjusted in other ways. E.g. escalating the log-level of something that you're particularly interested in for the purposes of a test.
devtest context wrapping
To make contexts useful, we need to annotate them. The
devtest.Tanddevtest.Pnow have aWithCtxto wrap with those annotations.devtest test-scope context key
Test-scopes are tracked with a context key. See
devtest.TestScopeanddevtest.AddTestScope.devstack shim contexts
Each shim, and by extension each DSL object around it, now has context annotations. Like service-kind and chain ID.
More annotations can be added later.
devstack logging presets
presets.WithLogFiltersReset/presets.WithLogFilters/presets.WithPkgLogFilters/presets.WithTestLogFiltersallow for log-filters to be applied.These are devstack options; they can be applied globally to the package, to adjust the log level of all shared services, and set up the default log filters for individual test scopes.
Tests
Additional context
Metadata