Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion metrics/ids.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions metrics/metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1937,5 +1937,26 @@
"name": "StackDeltaProviderSuccess",
"field": "agent.stack_delta_extraction.success",
"id": 271
},
{
"description": "Number of lost trace events in the communication between kernel and user space (trace_events)",
"type": "counter",
"name": "TraceEventLost",
"field": "agent.errors.trace_event_lost",
"id": 272
},
{
"description": "Number of times a trace event was received without data (trace_events)",
"type": "counter",
"name": "TraceEventNoData",
"field": "agent.errors.trace_event_no_data",
"id": 273
},
{
"description": "Number of times a trace event read failed (trace_events)",
"type": "counter",
"name": "TraceEventReadError",
"field": "agent.errors.trace_event_read_error",
"id": 274
}
]
16 changes: 10 additions & 6 deletions tracer/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func startPerfEventMonitor(ctx context.Context, perfEventMap *ebpf.Map,
// Returns a function that can be called to retrieve perf event array
// error counts.
func (t *Tracer) startTraceEventMonitor(ctx context.Context,
traceOutChan chan<- *host.Trace) func() (lost, noData, readError uint64) {
traceOutChan chan<- *host.Trace) func() []metrics.Metric {
eventsMap := t.ebpfMaps["trace_events"]
eventReader, err := perf.NewReader(eventsMap,
t.samplesPerSecond*int(unsafe.Sizeof(C.Trace{})))
Expand Down Expand Up @@ -224,11 +224,15 @@ func (t *Tracer) startTraceEventMonitor(ctx context.Context,
}
}()

return func() (lost, noData, readError uint64) {
lost = lostEventsCount.Swap(0)
noData = noDataCount.Swap(0)
readError = readErrorCount.Swap(0)
return
return func() []metrics.Metric {
lost := lostEventsCount.Swap(0)
noData := noDataCount.Swap(0)
readError := readErrorCount.Swap(0)
return []metrics.Metric{
{ID: metrics.IDTraceEventLost, Value: metrics.MetricValue(lost)},
{ID: metrics.IDTraceEventNoData, Value: metrics.MetricValue(noData)},
{ID: metrics.IDTraceEventReadError, Value: metrics.MetricValue(readError)},
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ func (t *Tracer) loadBpfTrace(raw []byte, cpu int) *host.Trace {
// maps for tracepoints, new traces, trace count updates and unknown PCs.
func (t *Tracer) StartMapMonitors(ctx context.Context, traceOutChan chan<- *host.Trace) error {
eventMetricCollector := t.startEventMonitor(ctx)
t.startTraceEventMonitor(ctx, traceOutChan)
traceEventMetricCollector := t.startTraceEventMonitor(ctx, traceOutChan)

pidEvents := make([]uint32, 0)
periodiccaller.StartWithManualTrigger(ctx, t.intervals.MonitorInterval(),
Expand Down Expand Up @@ -1162,6 +1162,7 @@ func (t *Tracer) StartMapMonitors(ctx context.Context, traceOutChan chan<- *host

periodiccaller.Start(ctx, t.intervals.MonitorInterval(), func() {
metrics.AddSlice(eventMetricCollector())
metrics.AddSlice(traceEventMetricCollector())
metrics.AddSlice(t.eBPFMetricsCollector(translateIDs, previousMetricValue))

metrics.AddSlice([]metrics.Metric{
Expand Down