Skip to content

Commit

Permalink
Count filterprocessor metric data points dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
MacroPower committed Dec 18, 2023
1 parent fda6172 commit 17baacc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions processor/filterprocessor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (fmp *filterMetricProcessor) processMetrics(ctx context.Context, md pmetric
return md, nil
}

metricCountBeforeFilters := md.MetricCount()
metricDataPointCountBeforeFilters := md.DataPointCount()

var errors error
md.ResourceMetrics().RemoveIf(func(rmetrics pmetric.ResourceMetrics) bool {
Expand Down Expand Up @@ -172,8 +172,8 @@ func (fmp *filterMetricProcessor) processMetrics(ctx context.Context, md pmetric
return rmetrics.ScopeMetrics().Len() == 0
})

metricCountAfterFilters := md.MetricCount()
fmp.telemetry.record(triggerMetricsDropped, int64(metricCountBeforeFilters-metricCountAfterFilters))
metricDataPointCountAfterFilters := md.DataPointCount()
fmp.telemetry.record(triggerMetricDataPointsDropped, int64(metricDataPointCountBeforeFilters-metricDataPointCountAfterFilters))

if errors != nil {
fmp.logger.Error("failed processing metrics", zap.Error(errors))
Expand Down
22 changes: 11 additions & 11 deletions processor/filterprocessor/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ import (
type trigger int

const (
triggerMetricsDropped trigger = iota
triggerMetricDataPointsDropped trigger = iota
triggerLogsDropped
triggerSpansDropped
)

var (
typeStr = metadata.Type
processorTagKey = tag.MustNewKey(typeStr)
statMetricsFiltered = stats.Int64("metrics.filtered", "Number of metrics dropped by the filter processor", stats.UnitDimensionless)
statLogsFiltered = stats.Int64("logs.filtered", "Number of logs dropped by the filter processor", stats.UnitDimensionless)
statSpansFiltered = stats.Int64("spans.filtered", "Number of spans dropped by the filter processor", stats.UnitDimensionless)
typeStr = metadata.Type
processorTagKey = tag.MustNewKey(typeStr)
statMetricDataPointsFiltered = stats.Int64("metrics.filtered", "Number of metric data points dropped by the filter processor", stats.UnitDimensionless)
statLogsFiltered = stats.Int64("logs.filtered", "Number of logs dropped by the filter processor", stats.UnitDimensionless)
statSpansFiltered = stats.Int64("spans.filtered", "Number of spans dropped by the filter processor", stats.UnitDimensionless)
)

func init() {
Expand All @@ -42,9 +42,9 @@ func metricViews() []*view.View {

return []*view.View{
{
Name: processorhelper.BuildCustomMetricName(typeStr, statMetricsFiltered.Name()),
Measure: statMetricsFiltered,
Description: statMetricsFiltered.Description(),
Name: processorhelper.BuildCustomMetricName(typeStr, statMetricDataPointsFiltered.Name()),
Measure: statMetricDataPointsFiltered,
Description: statMetricDataPointsFiltered.Description(),
Aggregation: view.Sum(),
TagKeys: processorTagKeys,
},
Expand Down Expand Up @@ -89,8 +89,8 @@ func newfilterProcessorTelemetry(set processor.CreateSettings) (*filterProcessor
func (fpt *filterProcessorTelemetry) record(trigger trigger, dropped int64) {
var triggerMeasure *stats.Int64Measure
switch trigger {
case triggerMetricsDropped:
triggerMeasure = statMetricsFiltered
case triggerMetricDataPointsDropped:
triggerMeasure = statMetricDataPointsFiltered
case triggerLogsDropped:
triggerMeasure = statLogsFiltered
case triggerSpansDropped:
Expand Down

0 comments on commit 17baacc

Please sign in to comment.