Skip to content

Commit

Permalink
Chain id in Metrics (#300)
Browse files Browse the repository at this point in the history
* Add chain id to the MetricSummary and AgetMetric

Change chain id type to in64

* Add pre-defined metrics

* Add public method that checks if method is allowed to use as a metric
  • Loading branch information
dkeysil authored Jan 29, 2024
1 parent dad5459 commit af53540
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 18 deletions.
116 changes: 116 additions & 0 deletions domain/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,64 @@ func IsMetricAllowed(metric string) bool {

// Metric names that are allowed for processing by Forta
const (
MetricClientDial = "agent.client.dial"
MetricClientClose = "agent.client.close"

MetricStatusRunning = "agent.status.running"
MetricStatusAttached = "agent.status.attached"
MetricStatusInitialized = "agent.status.initialized"
MetricStatusStopping = "agent.status.stopping"
MetricStatusActive = "agent.status.active"
MetricStatusInactive = "agent.status.inactive"

MetricActionUpdate = "agent.action.update"
MetricActionRestart = "agent.action.restart"
MetricActionSubscribe = "agent.action.subscribe"
MetricActionUnsubscribe = "agent.action.unsubscribe"

MetricFailurePull = "agent.failure.pull"
MetricFailureLaunch = "agent.failure.launch"
MetricFailureStop = "agent.failure.stop"
MetricFailureDial = "agent.failure.dial"
MetricFailureInitialize = "agent.failure.initialize"
MetricFailureInitializeResponse = "agent.failure.initialize.response"
MetricFailureInitializeValidate = "agent.failure.initialize.validate"
MetricFailureTooManyErrs = "agent.failure.too-many-errs"

MetricHealthCheckAttempt = "agent.health.attempt"
MetricHealthCheckSuccess = "agent.health.success"
MetricHealthCheckError = "agent.health.error"

MetricFinding = "finding"
MetricTxRequest = "tx.request"
MetricTxLatency = "tx.latency"
MetricTxError = "tx.error"
MetricTxSuccess = "tx.success"
MetricTxDrop = "tx.drop"
MetricTxBlockAge = "tx.block.age"
MetricTxEventAge = "tx.event.age"
MetricBlockBlockAge = "block.block.age"
MetricBlockEventAge = "block.event.age"
MetricBlockRequest = "block.request"
MetricBlockLatency = "block.latency"
MetricBlockError = "block.error"
MetricBlockSuccess = "block.success"
MetricBlockDrop = "block.drop"

MetricJSONRPCLatency = "jsonrpc.latency"
MetricJSONRPCRequest = "jsonrpc.request"
MetricJSONRPCSuccess = "jsonrpc.success"
MetricJSONRPCThrottled = "jsonrpc.throttled"
MetricPublicAPIProxyLatency = "publicapi.latency"
MetricPublicAPIProxyRequest = "publicapi.request"
MetricPublicAPIProxySuccess = "publicapi.success"
MetricPublicAPIProxyThrottled = "publicapi.throttled"
MetricFindingsDropped = "findings.dropped"
MetricCombinerRequest = "combiner.request"
MetricCombinerLatency = "combiner.latency"
MetricCombinerError = "combiner.error"
MetricCombinerSuccess = "combiner.success"
MetricCombinerDrop = "combiner.drop"
MetricDockerEventPull = "docker.image.pull"
MetricDockerEventContainerCreate = "docker.container.create"
MetricDockerEventContainerDestroy = "docker.container.destroy"
Expand All @@ -24,6 +82,64 @@ const (

var (
allMetrics = map[string]interface{}{
MetricClientDial: nil,
MetricClientClose: nil,

MetricStatusRunning: nil,
MetricStatusAttached: nil,
MetricStatusInitialized: nil,
MetricStatusStopping: nil,
MetricStatusActive: nil,
MetricStatusInactive: nil,

MetricActionUpdate: nil,
MetricActionRestart: nil,
MetricActionSubscribe: nil,
MetricActionUnsubscribe: nil,

MetricFailurePull: nil,
MetricFailureLaunch: nil,
MetricFailureStop: nil,
MetricFailureDial: nil,
MetricFailureInitialize: nil,
MetricFailureInitializeResponse: nil,
MetricFailureInitializeValidate: nil,
MetricFailureTooManyErrs: nil,

MetricHealthCheckAttempt: nil,
MetricHealthCheckSuccess: nil,
MetricHealthCheckError: nil,

MetricFinding: nil,
MetricTxRequest: nil,
MetricTxLatency: nil,
MetricTxError: nil,
MetricTxSuccess: nil,
MetricTxDrop: nil,
MetricTxBlockAge: nil,
MetricTxEventAge: nil,
MetricBlockBlockAge: nil,
MetricBlockEventAge: nil,
MetricBlockRequest: nil,
MetricBlockLatency: nil,
MetricBlockError: nil,
MetricBlockSuccess: nil,
MetricBlockDrop: nil,

MetricJSONRPCLatency: nil,
MetricJSONRPCRequest: nil,
MetricJSONRPCSuccess: nil,
MetricJSONRPCThrottled: nil,
MetricPublicAPIProxyLatency: nil,
MetricPublicAPIProxyRequest: nil,
MetricPublicAPIProxySuccess: nil,
MetricPublicAPIProxyThrottled: nil,
MetricFindingsDropped: nil,
MetricCombinerRequest: nil,
MetricCombinerLatency: nil,
MetricCombinerError: nil,
MetricCombinerSuccess: nil,
MetricCombinerDrop: nil,
MetricDockerEventPull: nil,
MetricDockerEventContainerCreate: nil,
MetricDockerEventContainerDestroy: nil,
Expand Down
55 changes: 37 additions & 18 deletions protocol/bot_metrics.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions protocol/bot_metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ message MetricSummary {
double p95 = 6;
string details = 7;
int32 shardId = 8;
int64 chainId = 9;
}

message AgentMetric {
Expand All @@ -28,6 +29,7 @@ message AgentMetric {
double value = 4;
string details = 5;
int32 shardId = 6;
int64 chainId = 7;
}

message AgentMetricList {
Expand Down

0 comments on commit af53540

Please sign in to comment.