mirror of
https://github.com/cloudflare/cloudflared.git
synced 2026-06-23 04:10:20 +00:00
c0bc3bdbf0
Check / check (1.22.x, macos-latest) (push) Has been cancelled
Check / check (1.22.x, ubuntu-latest) (push) Has been cancelled
Check / check (1.22.x, windows-latest) (push) Has been cancelled
Semgrep config / semgrep/ci (push) Has been cancelled
33 lines
668 B
Go
33 lines
668 B
Go
package sentry
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// metricBatchProcessor batches metrics and sends them to Sentry.
|
|
type metricBatchProcessor struct {
|
|
*batchProcessor[Metric]
|
|
}
|
|
|
|
func newMetricBatchProcessor(client *Client) *metricBatchProcessor {
|
|
return &metricBatchProcessor{
|
|
batchProcessor: newBatchProcessor(func(items []Metric) {
|
|
if len(items) == 0 {
|
|
return
|
|
}
|
|
|
|
event := NewEvent()
|
|
event.Timestamp = time.Now()
|
|
event.EventID = EventID(uuid())
|
|
event.Type = traceMetricEvent.Type
|
|
event.Metrics = items
|
|
|
|
client.Transport.SendEvent(event)
|
|
}),
|
|
}
|
|
}
|
|
|
|
func (p *metricBatchProcessor) Send(metric *Metric) bool {
|
|
return p.batchProcessor.Send(*metric)
|
|
}
|