Skip to content

Conversation

@aleks-p
Copy link
Contributor

@aleks-p aleks-p commented Oct 29, 2025

Adds tracing to the metastore public endpoints. This should help troubleshooting cases where the metastore latency goes up. Fixes https://github.com/grafana/pyroscope-squad/issues/603.

Here is an example for the IndexService.AddBlock RPC:

Screenshot 2025-10-29 at 14 27 42

//
// The registry is only used on the leader node where Propose() is called. Followers will
// not have contexts available and will use context.Background() instead.
type ContextRegistry struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will add some memory overhead but I think it is worth it for gaining more visibility. If anyone has alternative ideas, I'd be happy to rework this part.

}

ctx := context.Background()
if ctxID := string(cmd.Extensions); ctxID != "" {
Copy link
Contributor Author

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


future := n.raft.ApplyLog(raft.Log{
Data: raw,
Extensions: []byte(ctxID),
Copy link
Contributor Author

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 (writing point)

https://github.com/hashicorp/raft/blob/c4fb904a43d299a2b9ba1000ae18a5b3f60994ab/log.go#L94

@aleks-p aleks-p force-pushed the metastore-tracing-spans branch 2 times, most recently from 6fe7d52 to 6429ad7 Compare October 30, 2025 11:27
@aleks-p aleks-p force-pushed the metastore-tracing-spans branch from 6429ad7 to 2fd2481 Compare October 30, 2025 12:11
Copy link
Contributor

@korniltsev-grafanista korniltsev-grafanista left a comment

Choose a reason for hiding this comment

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

lgtm

@aleks-p aleks-p merged commit 9ebcb61 into main Nov 4, 2025
20 checks passed
@aleks-p aleks-p deleted the metastore-tracing-spans branch November 4, 2025 12:47
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.

2 participants