-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(blob|state): Blob submission metrics #4549
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
Closed
Closed
Changes from 19 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
3090cbf
add blob submission metrics
gupadhyaya b25c77f
fix tests
gupadhyaya c451259
fix build errors
gupadhyaya 931387a
fix api
gupadhyaya 43e6746
shorten
gupadhyaya b4f3dde
Merge branch 'main' into blob_submission_metrics
gupadhyaya 0487333
remove duplicates
gupadhyaya 6be3ead
fix format issue
gupadhyaya 17a30e2
Fix bitswap compilation issues and enable metrics in tastora framework
gupadhyaya 6bc2316
Remove HashOnRead method from BlockstoreWithMetrics
gupadhyaya 962f115
Update tastora framework to use local Docker image with metrics
gupadhyaya 7198aa5
Remove interface compliance check for BlockstoreWithMetrics
gupadhyaya 80e2a6a
fix coreaccessor with new metrics instead of nil, fx.invoke issue
gupadhyaya af3953a
fix blob metrics
gupadhyaya 2af16ef
go.mod changes
gupadhyaya 06e3513
Merge branch 'main' into blob_submission_metrics
gupadhyaya 4659fbe
go mod tidy
gupadhyaya 871bd90
blob metrics fixes
gupadhyaya ccbb3a3
fix
gupadhyaya e00d3c7
remove unnecessary method
gupadhyaya e98716f
remove debug stuff
gupadhyaya ab8d1b2
WithMetrics
gupadhyaya 0f2a3cf
remove passing nil metrics
gupadhyaya 5c1a2f6
private metrics, stop method
gupadhyaya 88ba0e0
cleanup
gupadhyaya 88e78ba
Merge branch 'main' into blob_submission_metrics
gupadhyaya 510b48c
blob metrics changes
gupadhyaya 0044277
remove nil checks
gupadhyaya ab99226
get rid of duplicate legacy state metrics
gupadhyaya 29c9a4e
optimizing metrics recording
gupadhyaya 1ba9c6c
error out if metrics fail
gupadhyaya c604d7b
named error
gupadhyaya 74a42d1
skip resp name
gupadhyaya 878d1bf
error as bool/enum to avoid cardinality explosion
gupadhyaya 9356b77
golangci-lint fix
gupadhyaya 06a3961
unify error counting
gupadhyaya b6f7a3d
remove magic strings
gupadhyaya 96b085a
golangci-lint fixes
gupadhyaya f110c2d
further fix golangci-lint
gupadhyaya 533f70e
fixing docker security issue
gupadhyaya 344da58
Revert "fixing docker security issue"
gupadhyaya f7d2d64
Merge origin/main into blob_submission_metrics
gupadhyaya 0de2e67
Fix compilation error after merge
gupadhyaya 380ea9e
Apply goimports-reviser formatting to fix import organization
gupadhyaya 5ac90dc
Fix import ordering in state/core_access.go
gupadhyaya b81bfc0
Fix remaining issues after merge
gupadhyaya 4495e04
minor
gupadhyaya 5006f04
go mod tidy
gupadhyaya 0d3d4e4
remove unnecessary metrics
gupadhyaya 70ad967
Merge branch 'main' into blob_submission_metrics
gupadhyaya c373bd9
Remove accidentally committed grafana and metrics files
gupadhyaya 5ac205d
Fix TestListenerWithWrongChainRPC cleanup issue
gupadhyaya 03d26e7
Merge remote-tracking branch 'origin/main' into blob_submission_metrics
gupadhyaya ace5b72
fix
gupadhyaya 24a6adc
minor fix
gupadhyaya 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| package blob | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "sync/atomic" | ||
| "time" | ||
|
|
||
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/attribute" | ||
| "go.opentelemetry.io/otel/metric" | ||
| "go.uber.org/fx" | ||
| ) | ||
|
|
||
| var meter = otel.Meter("blob") | ||
|
|
||
| // Metrics tracks blob-related metrics | ||
| type Metrics struct { | ||
| // Retrieval metrics | ||
| retrievalCounter metric.Int64Counter | ||
| retrievalDuration metric.Float64Histogram | ||
| retrievalErrors metric.Int64Counter | ||
| retrievalNotFound metric.Int64Counter | ||
|
|
||
| // Proof metrics | ||
| proofCounter metric.Int64Counter | ||
| proofDuration metric.Float64Histogram | ||
| proofErrors metric.Int64Counter | ||
|
|
||
| // Internal counters (thread-safe) | ||
| totalRetrievals atomic.Int64 | ||
| totalRetrievalErrors atomic.Int64 | ||
| totalProofs atomic.Int64 | ||
| totalProofErrors atomic.Int64 | ||
| } | ||
|
|
||
| // WithMetrics registers blob metrics | ||
| func WithMetrics(lc fx.Lifecycle) (*Metrics, error) { | ||
| // Retrieval metrics | ||
| retrievalCounter, err := meter.Int64Counter( | ||
| "blob_retrieval_total", | ||
| metric.WithDescription("Total number of blob retrieval operations"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| retrievalDuration, err := meter.Float64Histogram( | ||
| "blob_retrieval_duration_seconds", | ||
| metric.WithDescription("Duration of blob retrieval operations"), | ||
| metric.WithUnit("s"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| retrievalErrors, err := meter.Int64Counter( | ||
| "blob_retrieval_errors_total", | ||
| metric.WithDescription("Total number of blob retrieval errors"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| retrievalNotFound, err := meter.Int64Counter( | ||
| "blob_retrieval_not_found_total", | ||
| metric.WithDescription("Total number of blob not found errors"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Proof metrics | ||
| proofCounter, err := meter.Int64Counter( | ||
| "blob_proof_total", | ||
| metric.WithDescription("Total number of blob proof operations"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| proofDuration, err := meter.Float64Histogram( | ||
| "blob_proof_duration_seconds", | ||
| metric.WithDescription("Duration of blob proof operations"), | ||
| metric.WithUnit("s"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| proofErrors, err := meter.Int64Counter( | ||
| "blob_proof_errors_total", | ||
| metric.WithDescription("Total number of blob proof errors"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| metrics := &Metrics{ | ||
| retrievalCounter: retrievalCounter, | ||
| retrievalDuration: retrievalDuration, | ||
| retrievalErrors: retrievalErrors, | ||
| retrievalNotFound: retrievalNotFound, | ||
| proofCounter: proofCounter, | ||
| proofDuration: proofDuration, | ||
| proofErrors: proofErrors, | ||
| } | ||
|
|
||
| // Register observable metrics | ||
| retrievalTotal, err := meter.Int64ObservableCounter( | ||
| "blob_retrieval_total_observable", | ||
| metric.WithDescription("Observable total number of blob retrievals"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| proofTotal, err := meter.Int64ObservableCounter( | ||
| "blob_proof_total_observable", | ||
| metric.WithDescription("Observable total number of blob proofs"), | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| callback := func(_ context.Context, observer metric.Observer) error { | ||
| observer.ObserveInt64(retrievalTotal, metrics.totalRetrievals.Load()) | ||
| observer.ObserveInt64(proofTotal, metrics.totalProofs.Load()) | ||
| return nil | ||
| } | ||
|
|
||
| clientReg, err := meter.RegisterCallback(callback, retrievalTotal, proofTotal) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| lc.Append(fx.Hook{ | ||
| OnStop: func(context.Context) error { | ||
| return clientReg.Unregister() | ||
| }, | ||
| }) | ||
|
|
||
| return metrics, nil | ||
| } | ||
|
|
||
| // ObserveRetrieval records blob retrieval metrics | ||
| func (m *Metrics) ObserveRetrieval(ctx context.Context, duration time.Duration, err error) { | ||
| if m == nil { | ||
| return | ||
| } | ||
|
|
||
| // Update counters | ||
| m.totalRetrievals.Add(1) | ||
| if err != nil { | ||
| m.totalRetrievalErrors.Add(1) | ||
| } | ||
|
|
||
| // Record metrics | ||
| attrs := []attribute.KeyValue{} | ||
| if err != nil { | ||
| attrs = append(attrs, attribute.String("error", err.Error())) | ||
| if errors.Is(err, ErrBlobNotFound) { | ||
| m.retrievalNotFound.Add(ctx, 1, metric.WithAttributes(attrs...)) | ||
| } else { | ||
| m.retrievalErrors.Add(ctx, 1, metric.WithAttributes(attrs...)) | ||
| } | ||
| } else { | ||
| m.retrievalCounter.Add(ctx, 1, metric.WithAttributes(attrs...)) | ||
| } | ||
|
|
||
| m.retrievalDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) | ||
| } | ||
|
|
||
| // ObserveProof records blob proof metrics | ||
| func (m *Metrics) ObserveProof(ctx context.Context, duration time.Duration, err error) { | ||
| if m == nil { | ||
| return | ||
| } | ||
|
|
||
| // Update counters | ||
| m.totalProofs.Add(1) | ||
| if err != nil { | ||
| m.totalProofErrors.Add(1) | ||
| } | ||
|
|
||
| // Record metrics | ||
| attrs := []attribute.KeyValue{} | ||
| if err != nil { | ||
| attrs = append(attrs, attribute.String("error", err.Error())) | ||
| m.proofErrors.Add(ctx, 1, metric.WithAttributes(attrs...)) | ||
| } else { | ||
| m.proofCounter.Add(ctx, 1, metric.WithAttributes(attrs...)) | ||
| } | ||
|
|
||
| m.proofDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.