Skip to content

Commit

Permalink
maint: add collector_redistribute_traces_duration_ms metric (#1368)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

We are seeing the `collector` timing out its health check during high
volume traffic. I'm wondering if its the redistribution code taking too
long to run.

- #1348 

## Short description of the changes

- add `collector_redistribute_traces_duration_ms` metric in `collector`
  • Loading branch information
VinozzZ authored and TylerHelmuth committed Oct 16, 2024
1 parent 37c4c8b commit 75a8f31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion collect/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var inMemCollectorMetrics = []metrics.Metadata{
{Name: "dropped_from_stress", Type: metrics.Counter, Unit: metrics.Dimensionless, Description: "number of traces dropped due to stress relief"},
{Name: "trace_kept_sample_rate", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "sample rate of kept traces"},
{Name: "trace_aggregate_sample_rate", Type: metrics.Histogram, Unit: metrics.Dimensionless, Description: "aggregate sample rate of both kept and dropped traces"},
{Name: "collector_redistribute_traces_duration_ms", Type: metrics.Histogram, Unit: metrics.Milliseconds, Description: "duration of redistributing traces to peers"},
}

func (i *InMemCollector) Start() error {
Expand Down Expand Up @@ -403,7 +404,13 @@ func (i *InMemCollector) collect() {

func (i *InMemCollector) redistributeTraces() {
_, span := otelutil.StartSpan(context.Background(), i.Tracer, "redistributeTraces")
defer span.End()
redistrubutionStartTime := i.Clock.Now()

defer func() {
i.Metrics.Histogram("collector_redistribute_traces_duration_ms", i.Clock.Now().Sub(redistrubutionStartTime).Milliseconds())
span.End()
}()

// loop through eveything in the cache of live traces
// if it doesn't belong to this peer, we should forward it to the correct peer
peers, err := i.Peers.GetPeers()
Expand Down

0 comments on commit 75a8f31

Please sign in to comment.