-
Notifications
You must be signed in to change notification settings - Fork 878
feat(metrics): migrate app/legacyabci, loadtest, utils/logging, wasmbinding to OpenTelemetry #3446
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package legacyabci | ||
|
|
||
| import ( | ||
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/metric" | ||
| ) | ||
|
|
||
| var ( | ||
| meter = otel.Meter("legacyabci") | ||
|
|
||
| // finerGrainedBuckets units are in seconds | ||
| finerGrainedBuckets = metric.WithExplicitBucketBoundaries( | ||
| 0.000025, 0.000050, 0.0001, 0.0005, 0.001, 0.0025, 0.005, 0.010, 0.020, 0.050, 0.075, 0.1, 0.25, 0.5, 1, 10, | ||
| ) | ||
|
|
||
| legacyAbciMetrics = struct { | ||
| totalBeginBlockDuration metric.Float64Histogram | ||
| ibcBeginBlockerDuration metric.Float64Histogram | ||
| txDuration metric.Float64Histogram | ||
| }{ | ||
| totalBeginBlockDuration: must(meter.Float64Histogram( | ||
| "begin_blocker_duration", | ||
| metric.WithDescription("Total duration of begin-block execution in seconds"), | ||
| finerGrainedBuckets, | ||
| metric.WithUnit("s"), | ||
| )), | ||
| ibcBeginBlockerDuration: must(meter.Float64Histogram( | ||
| "ibc_begin_blocker_duration", | ||
| metric.WithDescription("Duration of IBC begin-blocker execution in seconds"), | ||
| finerGrainedBuckets, | ||
| metric.WithUnit("s"), | ||
| )), | ||
| txDuration: must(meter.Float64Histogram( | ||
| "tx_duration", | ||
| metric.WithDescription("Duration of tx processing by mode (check, recheck, deliver)"), | ||
| finerGrainedBuckets, | ||
| metric.WithUnit("s"), | ||
| )), | ||
| } | ||
| ) | ||
|
|
||
| func must[V any](v V, err error) V { | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| return v | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package logging | ||
|
|
||
| import ( | ||
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/metric" | ||
| ) | ||
|
|
||
| var ( | ||
| meter = otel.Meter("utils_logging") | ||
|
|
||
| loggingMetrics = struct { | ||
| logNotDoneAfter metric.Int64Counter | ||
| }{ | ||
| logNotDoneAfter: must(meter.Int64Counter( | ||
| "log_not_done_after", | ||
| metric.WithDescription("Number of times an operation was still not finished after the expected duration by label"), | ||
| metric.WithUnit("{count}"), | ||
| )), | ||
| } | ||
| ) | ||
|
|
||
| func must[V any](v V, err error) V { | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| return v | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| package logging | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
|
|
||
| "github.com/sei-protocol/sei-chain/utils/metrics" | ||
| "github.com/sei-protocol/seilog" | ||
| "go.opentelemetry.io/otel/attribute" | ||
| otelmetric "go.opentelemetry.io/otel/metric" | ||
| ) | ||
|
|
||
| var logger = seilog.NewLogger("utils", "logging") | ||
|
|
@@ -37,7 +39,7 @@ func LogIfNotDoneAfter[R any](task func() (R, error), after time.Duration, label | |
| // reraise panic in main goroutine | ||
| panic(err) | ||
| case <-time.After(after): | ||
| metrics.IncrLogIfNotDoneAfter(label) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function |
||
| loggingMetrics.logNotDoneAfter.Add(context.Background(), 1, otelmetric.WithAttributes(attribute.String("label", label))) | ||
| logger.Error("operation still not finished", "label", label, "after", after) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,20 +149,6 @@ func IncrFailedConcurrentDeliverTxCounter() { | |
| ) | ||
| } | ||
|
|
||
| // Counts the number of operations that failed due to operation timeout | ||
| // Metric Names: | ||
| // | ||
| // sei_log_not_done_after_counter | ||
| func IncrLogIfNotDoneAfter(label string) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed functions that were only used in tests. |
||
| SafeMetricsIncrCounterWithLabels( | ||
| []string{"sei", "log", "not", "done", "after"}, | ||
| 1, | ||
| []metrics.Label{ | ||
| telemetry.NewLabel("label", label), | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
|
cursor[bot] marked this conversation as resolved.
|
||
| // Measures the time taken to execute a sudo msg | ||
| // Metric Names: | ||
| // | ||
|
|
@@ -256,18 +242,6 @@ func IncrPriceUpdateDenom(denom string) { | |
| ) | ||
| } | ||
|
|
||
| // Measures throughput per message type | ||
| // Metric Name: | ||
| // | ||
| // sei_throughput_<metric_name> | ||
| func SetThroughputMetricByType(metricName string, value float32, msgType string) { | ||
| telemetry.SetGaugeWithLabels( | ||
| []string{"sei", "loadtest", "tps", metricName}, | ||
| value, | ||
| []metrics.Label{telemetry.NewLabel("msg_type", msgType)}, | ||
| ) | ||
| } | ||
|
|
||
| // Measures the number of times the total block gas wanted in the proposal exceeds the max | ||
| // Metric Name: | ||
| // | ||
|
|
@@ -445,32 +419,6 @@ func IncrementPendingNonce(event string) { | |
| ) | ||
| } | ||
|
|
||
| // IncrProducerEventCount increments the counter for events produced. | ||
| // This metric counts the number of events produced by the system. | ||
| // Metric Name: | ||
| // | ||
| // sei_loadtest_produce_count | ||
| func IncrProducerEventCount(msgType string) { | ||
| SafeTelemetryIncrCounterWithLabels( | ||
| []string{"sei", "loadtest", "produce", "count"}, | ||
| 1, | ||
| []metrics.Label{telemetry.NewLabel("msg_type", msgType)}, | ||
| ) | ||
| } | ||
|
|
||
| // IncrConsumerEventCount increments the counter for events consumed. | ||
| // This metric counts the number of events consumed by the system. | ||
| // Metric Name: | ||
| // | ||
| // sei_loadtest_consume_count | ||
| func IncrConsumerEventCount(msgType string) { | ||
| SafeTelemetryIncrCounterWithLabels( | ||
| []string{"sei", "loadtest", "consume", "count"}, | ||
| 1, | ||
| []metrics.Label{telemetry.NewLabel("msg_type", msgType)}, | ||
| ) | ||
| } | ||
|
|
||
| func AddHistogramMetric(key []string, value float32) { | ||
| metrics.AddSample(key, value) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,6 @@ import ( | |
| "runtime/debug" | ||
| "strings" | ||
|
|
||
| "github.com/armon/go-metrics" | ||
| "github.com/sei-protocol/sei-chain/sei-cosmos/telemetry" | ||
| sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types" | ||
| "github.com/sei-protocol/seilog" | ||
| ) | ||
|
|
@@ -35,23 +33,6 @@ func LogPanicCallback(ctx sdk.Context, r any) func(any) { | |
| } | ||
| } | ||
|
|
||
| func MetricsPanicCallback(err any, ctx sdk.Context, key string) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused function. |
||
| logger.Error("panic occurred during order matching for key", "key", key, "err", err) | ||
| defer func() { | ||
| if e := recover(); e != nil { | ||
| return | ||
| } | ||
| }() | ||
| telemetry.IncrCounterWithLabels( | ||
| []string{"panic"}, | ||
| 1, | ||
| []metrics.Label{ | ||
| telemetry.NewLabel("error", fmt.Sprintf("%s", err)), | ||
| telemetry.NewLabel("module", key), | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| func DecorateHardFailError(err error) error { | ||
| return fmt.Errorf("%s:%s", HardFailPrefix, err.Error()) | ||
| } | ||
|
|
||
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.
For
loadtest, replaced the metrics as it is only for test and no need to emit dual metrics.