Skip to content

Commit

Permalink
Use status.code as attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelbirkner committed Sep 13, 2023
1 parent 2487539 commit 82537b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/telemetrygen/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func Run(c *Config, exp sdkmetric.Exporter, logger *zap.Logger) error {
index: i,
}

go w.simulateMetrics(res, exp, c.GetAttributes())
go w.simulateMetrics(res, exp)
}
if c.TotalDuration > 0 {
time.Sleep(c.TotalDuration)
Expand Down
11 changes: 7 additions & 4 deletions cmd/telemetrygen/internal/metrics/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ type worker struct {
index int // worker index
}

func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Exporter, attributes []attribute.KeyValue) {
func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Exporter) {
limiter := rate.NewLimiter(w.limitPerSecond, 1)

var i int64
value := 24.42
attrs := attribute.NewSet(attributes...)
attrs := attribute.NewSet(attribute.KeyValue{
Key: attribute.Key("status.code"),
Value: attribute.StringValue("STATUS_CODE_OK"),
})

for w.running.Load() {
rm := metricdata.ResourceMetrics{
Expand All @@ -46,8 +49,8 @@ func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Expor
DataPoints: []metricdata.DataPoint[int64]{
{
Attributes: attrs,
Time: time.Now(),
Value: i,
Time: time.Now(),
Value: i,
},
},
},
Expand Down

0 comments on commit 82537b4

Please sign in to comment.