-
Notifications
You must be signed in to change notification settings - Fork 704
Improve metastore observability #4580
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1130f42
Add basic tracing to metastore endpoints
aleks-p fcedfa2
Add tracing to Raft and boltdb
aleks-p 4091d3c
Add tracing to Raft and boltdb (part 2)
aleks-p 0a79851
Simplify tracing for Raft handlers
aleks-p c66ffc2
Fix linter errors
aleks-p 218aeb8
Add even more tracing
aleks-p a2df764
Minor touch ups
aleks-p 919117d
Make propagation safer
aleks-p 6f63b67
Add span events for FSM.Propose
aleks-p 8de5704
Tidy up some more
aleks-p ff73806
Fix tests
aleks-p d9ddb7d
Refactor context registry
aleks-p 2fd2481
Refactor metrics
aleks-p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package fsm | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/opentracing/opentracing-go" | ||
| "go.etcd.io/bbolt" | ||
| ) | ||
|
|
||
| // tracingTx wraps a BoltDB transaction to automatically trace transaction lifecycle. | ||
| // It holds a span that encompasses the entire transaction, providing visibility into | ||
| // transaction timing without requiring manual instrumentation. | ||
| // | ||
| // The span should be created by the caller and will be finished when the transaction | ||
| // is committed or rolled back. | ||
| type tracingTx struct { | ||
| *bbolt.Tx | ||
| span opentracing.Span | ||
| spanCtx context.Context // Context with the span, for child operations | ||
| } | ||
|
|
||
| // newTracingTx creates a tracing transaction wrapper. | ||
| // The span parameter can be nil if no tracing is desired (e.g., on follower nodes). | ||
| func newTracingTx(tx *bbolt.Tx, span opentracing.Span, spanCtx context.Context) *tracingTx { | ||
| return &tracingTx{ | ||
| Tx: tx, | ||
| span: span, | ||
| spanCtx: spanCtx, | ||
| } | ||
| } | ||
|
|
||
| // Commit commits the transaction and finishes the span. | ||
| func (t *tracingTx) Commit() error { | ||
| if t.span != nil { | ||
| defer t.span.Finish() | ||
| t.span.LogKV("operation", "commit") | ||
| } | ||
| return t.Tx.Commit() | ||
| } | ||
|
|
||
| // Rollback rolls back the transaction and finishes the span. | ||
| func (t *tracingTx) Rollback() error { | ||
| if t.span != nil { | ||
| defer t.span.Finish() | ||
| t.span.LogKV("operation", "rollback") | ||
| } | ||
| return t.Tx.Rollback() | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the extension field of the raft Log type, to carry the context identifiers
https://github.com/hashicorp/raft/blob/c4fb904a43d299a2b9ba1000ae18a5b3f60994ab/log.go#L94