Skip to content

Commit

Permalink
Add Metric.Emit
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jul 20, 2021
1 parent 5837466 commit f8a815b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/executor/ramping_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,7 @@ func (varr RampingArrivalRate) Run(
// Since there aren't any free VUs available, consider this iteration
// dropped - we aren't going to try to recover it, but

stats.PushIfNotDone(parentCtx, out, stats.Sample{
Value: 1, Metric: droppedIterationMetric,
Tags: metricTags, Time: time.Now(),
})
stats.PushIfNotDone(parentCtx, out, droppedIterationMetric.Emit(time.Now(), metricTags, 1))

// We'll try to start allocating another VU in the background,
// non-blockingly, if we have remainingUnplannedVUs...
Expand Down
10 changes: 10 additions & 0 deletions stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,16 @@ type Metric struct {
Sink Sink `json:"-"`
}

// Emit a sample for the metric at the given time, with the provided tags and values
func (m *Metric) Emit(t time.Time, tags *SampleTags, value float64) Sample {
return Sample{
Time: t,
Tags: tags,
Value: value,
Metric: m,
}
}

func New(name string, typ MetricType, t ...ValueType) *Metric {
vt := Default
if len(t) > 0 {
Expand Down

0 comments on commit f8a815b

Please sign in to comment.