-
Notifications
You must be signed in to change notification settings - Fork 289
WIP introduce an event metrics plugin with a general schema #4781
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Nikolaos Moraitis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new events metrics plugin with a general schema for capturing and storing event data. The implementation adds an eventsPlugin alongside existing metrics plugins to collect events with structured metadata including level, source, locator, and message information.
Key changes:
- Created a new events plugin with a general event schema supporting Info, Warning, and Error levels
- Integrated the events plugin into the MetricsAgent lifecycle (initialization, recording, and flushing)
- Refactored the flush method to use map literal initialization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/metrics/events.go | Implements the new events plugin with event schema definitions and plugin interface methods |
| pkg/metrics/metrics.go | Integrates the events plugin into MetricsAgent for event recording and output |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
|
|
||
| func NewEvent(level EventLevel, locator EventLocator, message EventMessage, source string, from, to time.Time) *Event { | ||
| return &Event{Level: level, Source: source, From: from, To: to, Locator: locator, Message: message} |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Timestamp field is not set in the NewEvent constructor. The Event struct includes a Timestamp field (line 29) which remains zero-valued when events are created through this constructor. Consider either setting it in the constructor or documenting that callers must use SetTimestamp separately.
| return &Event{Level: level, Source: source, From: from, To: to, Locator: locator, Message: message} | |
| return &Event{ | |
| Level: level, | |
| Source: source, | |
| From: from, | |
| To: to, | |
| Locator: locator, | |
| Message: message, | |
| Timestamp: time.Now(), | |
| } |
| } | ||
|
|
||
| func (p *eventsPlugin) Events() []MetricsEvent { | ||
| return p.events |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Events() method returns the slice without mutex protection, which could lead to race conditions if called concurrently with Record(). Consider acquiring the mutex before returning the slice or returning a copy to ensure thread safety.
| return p.events | |
| p.mu.Lock() | |
| defer p.mu.Unlock() | |
| eventsCopy := make([]MetricsEvent, len(p.events)) | |
| copy(eventsCopy, p.events) | |
| return eventsCopy |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: droslean The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@droslean: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
/cc @openshift/test-platform