Skip to content

Commit

Permalink
Merge pull request #786 from forta-network/revert-785-ali/forta-1076-…
Browse files Browse the repository at this point in the history
…add-subscription-info-to-combiner-metrics

Revert "Add subscription info to subscription action metrics"
  • Loading branch information
canercidam authored Jul 10, 2023
2 parents 54c7faa + 7663a50 commit 70f3627
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions services/components/botio/bot_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ func (bot *botClient) processTransaction(ctx context.Context, lg *log.Entry, req
// truncate findings
if len(resp.Findings) > MaxFindings {
dropped := len(resp.Findings) - MaxFindings
droppedMetric := metrics.CreateAgentMetric(botConfig, metrics.MetricFindingsDropped, float64(dropped), "")
droppedMetric := metrics.CreateAgentMetric(botConfig, metrics.MetricFindingsDropped, float64(dropped))
bot.msgClient.PublishProto(
messaging.SubjectMetricAgent,
&protocol.AgentMetricList{Metrics: []*protocol.AgentMetric{droppedMetric}},
Expand Down Expand Up @@ -572,7 +572,7 @@ func (bot *botClient) processBlock(ctx context.Context, lg *log.Entry, request *
if len(resp.Findings) > MaxFindings {
dropped := len(resp.Findings) - MaxFindings
droppedMetric := metrics.CreateAgentMetric(
botConfig, metrics.MetricFindingsDropped, float64(dropped), "",
botConfig, metrics.MetricFindingsDropped, float64(dropped),
)
bot.msgClient.PublishProto(
messaging.SubjectMetricAgent,
Expand Down Expand Up @@ -665,7 +665,7 @@ func (bot *botClient) processCombinationAlert(ctx context.Context, lg *log.Entry
// truncate findings
if len(resp.Findings) > MaxFindings {
dropped := len(resp.Findings) - MaxFindings
droppedMetric := metrics.CreateAgentMetric(botConfig, metrics.MetricFindingsDropped, float64(dropped), "")
droppedMetric := metrics.CreateAgentMetric(botConfig, metrics.MetricFindingsDropped, float64(dropped))
bot.msgClient.PublishProto(
messaging.SubjectMetricAgent, &protocol.AgentMetricList{Metrics: []*protocol.AgentMetric{droppedMetric}},
)
Expand Down
6 changes: 3 additions & 3 deletions services/components/botio/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (rs *requestSender) SendEvaluateTxRequest(req *protocol.EvaluateTxRequest)
}:
default: // do not try to send if the buffer is full
lg.WithField("bot", botConfig.ID).Debug("agent tx request buffer is full - skipping")
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricTxDrop, 1, ""))
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricTxDrop, 1))
}
lg.WithFields(log.Fields{
"bot": botConfig.ID,
Expand Down Expand Up @@ -164,7 +164,7 @@ func (rs *requestSender) SendEvaluateBlockRequest(req *protocol.EvaluateBlockReq
}:
default: // do not try to send if the buffer is full
lg.WithField("bot", botConfig.ID).Warn("agent block request buffer is full - skipping")
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricBlockDrop, 1, ""))
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricBlockDrop, 1))
}
lg.WithFields(
log.Fields{
Expand Down Expand Up @@ -249,7 +249,7 @@ func (rs *requestSender) SendEvaluateAlertRequest(req *protocol.EvaluateAlertReq
}:
default: // do not try to send if the buffer is full
lg.WithField("bot", botConfig.ID).Warn("agent alert request buffer is full - skipping")
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricCombinerDrop, 1, ""))
metricsList = append(metricsList, metrics.CreateAgentMetric(botConfig, metrics.MetricCombinerDrop, 1))
}

lg.WithFields(
Expand Down
2 changes: 1 addition & 1 deletion services/components/metrics/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (lc *lifecycle) HealthCheckError(err error, botConfigs ...config.AgentConfi

func fromBotSubscriptions(action string, subscriptions []domain.CombinerBotSubscription) (metrics []*protocol.AgentMetric) {
for _, botSub := range subscriptions {
metrics = append(metrics, CreateAgentMetric(config.AgentConfig{ID: botSub.Subscriber.BotID}, action, 1, fmt.Sprintf("botId=%s", botSub.Subscription.BotId)))
metrics = append(metrics, CreateAgentMetric(config.AgentConfig{ID: botSub.Subscriber.BotID}, action, 1))
}
return
}
Expand Down
3 changes: 1 addition & 2 deletions services/components/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ func SendAgentMetrics(client clients.MessageClient, ms []*protocol.AgentMetric)
}
}

func CreateAgentMetric(agt config.AgentConfig, metric string, value float64, details string) *protocol.AgentMetric {
func CreateAgentMetric(agt config.AgentConfig, metric string, value float64) *protocol.AgentMetric {
return &protocol.AgentMetric{
AgentId: agt.ID,
Timestamp: time.Now().Format(time.RFC3339),
Name: metric,
Value: value,
ShardId: agt.ShardID(),
Details: details,
}
}

Expand Down

0 comments on commit 70f3627

Please sign in to comment.