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

fix for issue-1711-: Metrics not getting update correctly for eventlistener_event_count #1755

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ The following pipeline metrics are available on the `eventlistener` Service on p
| Name | Type | Labels/Tags | Status |
| ---------- | ----------- | :-: | ----------- |
| `eventlistener_triggered_resources` | Counter | `kind`=<kind> | experimental |
| `eventlistener_event_count` | Counter | `status`=<status> | experimental |
| `eventlistener_event_received_count` | Counter | `status`=<status> | experimental |
savitaashture marked this conversation as resolved.
Show resolved Hide resolved
| `eventlistener_http_duration_seconds_[bucket, sum, count]` | Histogram | - | experimental |

Several kinds of exporters can be configured for an `EventListener`, including Prometheus, Google Stackdriver, and many others.
Expand Down
10 changes: 5 additions & 5 deletions pkg/sink/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
"The eventlistener HTTP request duration",
stats.UnitDimensionless)
elDistribution = view.Distribution(metrics.BucketsNBy10(0.001, 5)...)
eventCount = stats.Float64("event_count",
eventRcdCount = stats.Float64("event_received_count",
"number of events received by sink",
stats.UnitDimensionless)
triggeredResources = stats.Int64("triggered_resources", "Count of the number of triggered eventlistener resources", stats.UnitDimensionless)
Expand Down Expand Up @@ -65,8 +65,8 @@ func NewRecorder() (*Recorder, error) {
TagKeys: []tag.Key{r.kind},
},
&view.View{
Description: eventCount.Description(),
Measure: eventCount,
Description: eventRcdCount.Description(),
Measure: eventRcdCount,
Aggregation: view.Count(),
TagKeys: []tag.Key{r.status},
},
Expand Down Expand Up @@ -119,11 +119,11 @@ func (s *Sink) recordCountMetrics(status string) {
)

if err != nil {
s.Logger.Warnf("failed to create tag for metric event_count: %w", err)
s.Logger.Warnf("failed to create tag for metric event_received_count: %w", err)
return
}

metrics.Record(ctx, eventCount.M(1))
metrics.Record(ctx, eventRcdCount.M(1))
}

func (s *Sink) recordResourceCreation(resources []json.RawMessage) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/sink/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestRecordRecordDurationMetrics(t *testing.T) {
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
defer metricstest.Unregister("event_count", "http_duration_seconds")
defer metricstest.Unregister("event_received_count", "http_duration_seconds")
logger := zaptest.NewLogger(t).Sugar()
metrics.FlushExporter()
err := metrics.UpdateExporter(context.TODO(), metrics.ExporterOptions{
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestRecordRecordCountMetrics(t *testing.T) {
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
defer metricstest.Unregister("event_count", "http_duration_seconds")
defer metricstest.Unregister("event_received_count", "http_duration_seconds")
logger := zaptest.NewLogger(t).Sugar()
metrics.FlushExporter()
err := metrics.UpdateExporter(context.TODO(), metrics.ExporterOptions{
Expand All @@ -165,7 +165,7 @@ func TestRecordRecordCountMetrics(t *testing.T) {
Logger: logger,
}
s.recordCountMetrics(failTag)
metricstest.CheckCountData(t, "event_count", test.expectedTags, test.expectedCount)
metricstest.CheckCountData(t, "event_received_count", test.expectedTags, test.expectedCount)
})
}
}