Skip to content

Commit

Permalink
fix for issue-1711-: Metrics not getting update correctly for eventl…
Browse files Browse the repository at this point in the history
…istener_event_count
  • Loading branch information
sudhishmk authored and tekton-robot committed Aug 21, 2024
1 parent b7a7987 commit a3d41eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,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 |
| `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)
})
}
}

0 comments on commit a3d41eb

Please sign in to comment.