Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics for WriteRequest calls #2988

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions reporter/parca_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ type ParcaReporter struct {

// Metrics that we have seen via ReportMetrics
otelLibraryMetrics map[string]prometheus.Metric

// Our own metrics
sampleWriteRequestBytes prometheus.Counter
stacktraceWriteRequestBytes prometheus.Counter
}

// hashString is a helper function for LRUs that use string as a key.
Expand Down Expand Up @@ -354,7 +358,7 @@ func (r *ParcaReporter) ReportMetrics(_ uint32, ids []uint32, values []int64) {
Help: field.Desc,
})
r.reg.MustRegister(g)
m = g
m = g
case metrics.MetricTypeCounter:
c := prometheus.NewCounter(prometheus.CounterOpts{
Name: f,
Expand All @@ -367,7 +371,7 @@ func (r *ParcaReporter) ReportMetrics(_ uint32, ids []uint32, values []int64) {
log.Warnf("Unknown metric type: %d", field.Type)
continue
}
r.otelLibraryMetrics[f] = m
r.otelLibraryMetrics[f] = m
}
if counter, ok := m.(prometheus.Counter); ok {
counter.Add(float64(val))
Expand Down Expand Up @@ -465,6 +469,18 @@ func New(
return nil, err
}

sampleWriteRequestBytes := prometheus.NewCounter(prometheus.CounterOpts{
Name: "sample_write_request_bytes",
Help: "the total number of bytes written in WriteRequest calls for sample records",
})
stacktraceWriteRequestBytes := prometheus.NewCounter(prometheus.CounterOpts{
Name: "stacktrace_write_request_bytes",
Help: "the total number of bytes written in WriteRequest calls for stacktrace records",
})

reg.MustRegister(sampleWriteRequestBytes)
reg.MustRegister(stacktraceWriteRequestBytes)

r := &ParcaReporter{
stopSignal: make(chan libpf.Void),
client: nil,
Expand All @@ -488,8 +504,10 @@ func New(
cmp,
sysMeta,
},
reg: reg,
otelLibraryMetrics: make(map[string]prometheus.Metric),
reg: reg,
otelLibraryMetrics: make(map[string]prometheus.Metric),
sampleWriteRequestBytes: sampleWriteRequestBytes,
stacktraceWriteRequestBytes: stacktraceWriteRequestBytes,
}

r.client = client
Expand Down Expand Up @@ -588,6 +606,7 @@ func (r *ParcaReporter) reportDataToBackend(ctx context.Context, buf *bytes.Buff
}); err != nil {
return err
}
r.sampleWriteRequestBytes.Add(float64(buf.Len()))

log.Debugf("Sent profile with %d samples", record.NumRows())

Expand Down Expand Up @@ -662,6 +681,7 @@ func (r *ParcaReporter) reportDataToBackend(ctx context.Context, buf *bytes.Buff
}); err != nil {
return err
}
r.stacktraceWriteRequestBytes.Add(float64(buf.Len()))

return client.CloseSend()
}
Expand Down
Loading