Skip to content

feat: Add event_id(UUID) to events info in agent message to backend#160

Merged
ambermingxin merged 1 commit intomainfrom
GPUHEALTH-1778
Apr 13, 2026
Merged

feat: Add event_id(UUID) to events info in agent message to backend#160
ambermingxin merged 1 commit intomainfrom
GPUHEALTH-1778

Conversation

@ambermingxin
Copy link
Copy Markdown
Collaborator

@ambermingxin ambermingxin commented Apr 10, 2026

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Events now include a stable unique identifier; exported messages (including agent exports and OTLP logs) carry this identifier for better tracing and correlation.
  • Tests

    • Added tests verifying identifier generation, format (UUID), preservation when provided, and presence in exported data formats.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

Added UUID-based EventID generation and propagation: new GenerateEventID() populates event.EventID during collection; the Event type and its conversion now carry EventID; OTLP conversion emits an event_id attribute on log records; tests updated/added to validate UUID behavior.

Changes

Cohort / File(s) Summary
Collector & tests
internal/exporter/collector/collector.go, internal/exporter/collector/collector_test.go
Added GenerateEventID() (uses github.com/google/uuid). collectEvents sets eventstore.Event.EventID (prefers existing value, otherwise generates one). Added TestGenerateEventID and updated tests to assert EventID is present and UUID-parseable.
OTLP converter & tests
internal/exporter/converter/otlp.go, internal/exporter/converter/otlp_test.go
OTLP log records for events now include an event_id attribute sourced from event.EventID. Tests updated to assert the event_id attribute equals the expected UUID.
Event model & conversion
third_party/fleet-intelligence-sdk/pkg/eventstore/types.go, third_party/fleet-intelligence-sdk/api/v1/types.go, third_party/fleet-intelligence-sdk/pkg/eventstore/types_test.go
Added exported EventID string to Event and propagated it in (*Event).ToEvent() to the API Event.EventID. Added tests verifying EventID is preserved when set and empty when absent; API type includes json:"event_id,omitempty".

Sequence Diagram

sequenceDiagram
    participant Client as Collector
    participant Store as EventStore
    participant Converter as OTLP Converter
    participant Exporter as OTLP Exporter

    Client->>Client: collectEvents() iterates events
    alt event has EventID
        Client->>Store: append event with existing EventID
    else no EventID
        Client->>Client: GenerateEventID() -> UUID
        Client->>Store: append event with generated EventID
    end
    Converter->>Store: retrieve stored event
    Converter->>Converter: build OTLP log record (include event_id = Event.EventID)
    Converter->>Exporter: export OTLP log record
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble bytes and seed a tide,

A tiny UUID hops beside,
Each event now wears a name so neat,
From collector burrow to OTLP seat,
Hooray—unique tracks for every feat! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Add event_id(UUID) to events info in agent message to backend' directly and specifically describes the main change: adding an event_id field (UUID) to events.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch GPUHEALTH-1778

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 155d5d0159

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/exporter/collector/collector.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/exporter/converter/otlp.go (1)

290-295: Consider omitting event_id when empty.

Right now blank event_id values are exported for events without IDs. Skipping empty values keeps payload cleaner and avoids low-value attributes.

Optional refactor
-			{
-				Key: "event_id",
-				Value: &commonv1.AnyValue{
-					Value: &commonv1.AnyValue_StringValue{StringValue: event.EventID},
-				},
-			},
+			// event_id is added only when present
 			attributes := []*commonv1.KeyValue{
 				{
 					Key: "component",
@@
 				{
 					Key: "log_type",
@@
 				},
 			}
+			if event.EventID != "" {
+				attributes = append(attributes, &commonv1.KeyValue{
+					Key: "event_id",
+					Value: &commonv1.AnyValue{
+						Value: &commonv1.AnyValue_StringValue{StringValue: event.EventID},
+					},
+				})
+			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/exporter/converter/otlp.go` around lines 290 - 295, The code
currently always adds an "event_id" attribute with event.EventID even when it's
empty; update the builder in internal/exporter/converter/otlp.go so it only
appends the attribute when event.EventID is non-empty (e.g., guard the block
that creates the commonv1.AnyValue for event_id with if event.EventID != ""),
leaving all other attribute creation unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@third_party/fleet-intelligence-sdk/pkg/eventstore/types.go`:
- Around line 30-31: The EventID field on the local Event struct is never
propagated when converting to the API type; update the converter function
(*Event).ToEvent() to carry e.EventID into the outgoing apiv1.Event (either into
an explicit event_id field if present or into a stable metadata/attributes key
such as "event_id") so the identifier is not lost during serialization; locate
the ToEvent method and add logic to set apiv1.Event.Metadata["event_id"] =
e.EventID (or the equivalent field) only when e.EventID is non-empty, ensuring
round-trip preservation until apiv1.Event gains a first-class event_id.

---

Nitpick comments:
In `@internal/exporter/converter/otlp.go`:
- Around line 290-295: The code currently always adds an "event_id" attribute
with event.EventID even when it's empty; update the builder in
internal/exporter/converter/otlp.go so it only appends the attribute when
event.EventID is non-empty (e.g., guard the block that creates the
commonv1.AnyValue for event_id with if event.EventID != ""), leaving all other
attribute creation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff900a34-8c75-4894-ac66-b164f2ed8d43

📥 Commits

Reviewing files that changed from the base of the PR and between 5047437 and 56a754a.

📒 Files selected for processing (5)
  • internal/exporter/collector/collector.go
  • internal/exporter/collector/collector_test.go
  • internal/exporter/converter/otlp.go
  • internal/exporter/converter/otlp_test.go
  • third_party/fleet-intelligence-sdk/pkg/eventstore/types.go

Comment thread third_party/fleet-intelligence-sdk/pkg/eventstore/types.go
Signed-off-by: Amber Xue <ambermingxin@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/exporter/collector/collector.go (1)

249-252: Validate non-empty incoming event_id before forwarding.

Right now only empty IDs are replaced. A malformed non-empty ID will still be emitted, which can break the “UUID” contract downstream.

Suggested patch
 			eventID := event.EventID
 			if eventID == "" {
 				eventID = GenerateEventID()
+			} else if _, err := uuid.Parse(eventID); err != nil {
+				log.Logger.Warnw("Invalid event ID from component, regenerating",
+					"component", componentName, "event_id", eventID, "error", err)
+				eventID = GenerateEventID()
 			}

Also applies to: 256-256

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/exporter/collector/collector.go` around lines 249 - 252, Validate
that incoming event.EventID is both non-empty and a well-formed UUID before
forwarding: replace the current unconditional assignment block that only checks
for empty string (where eventID := event.EventID / if eventID == "" { eventID =
GenerateEventID() }) with a validation that attempts to parse event.EventID as a
UUID (or use the project’s UUID validation helper) and only accept it if parsing
succeeds; otherwise call GenerateEventID() and use that value. Apply the same
validation logic to the other occurrence referenced in the comment (the second
place around the existing check at the later occurrence).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/exporter/collector/collector.go`:
- Around line 249-252: Validate that incoming event.EventID is both non-empty
and a well-formed UUID before forwarding: replace the current unconditional
assignment block that only checks for empty string (where eventID :=
event.EventID / if eventID == "" { eventID = GenerateEventID() }) with a
validation that attempts to parse event.EventID as a UUID (or use the project’s
UUID validation helper) and only accept it if parsing succeeds; otherwise call
GenerateEventID() and use that value. Apply the same validation logic to the
other occurrence referenced in the comment (the second place around the existing
check at the later occurrence).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c65de2d0-c18c-44b4-8ec0-687e7c45b37d

📥 Commits

Reviewing files that changed from the base of the PR and between 56a754a and 3b32cc6.

📒 Files selected for processing (7)
  • internal/exporter/collector/collector.go
  • internal/exporter/collector/collector_test.go
  • internal/exporter/converter/otlp.go
  • internal/exporter/converter/otlp_test.go
  • third_party/fleet-intelligence-sdk/api/v1/types.go
  • third_party/fleet-intelligence-sdk/pkg/eventstore/types.go
  • third_party/fleet-intelligence-sdk/pkg/eventstore/types_test.go
✅ Files skipped from review due to trivial changes (1)
  • third_party/fleet-intelligence-sdk/pkg/eventstore/types_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/exporter/converter/otlp.go
  • internal/exporter/converter/otlp_test.go
  • internal/exporter/collector/collector_test.go
  • third_party/fleet-intelligence-sdk/pkg/eventstore/types.go

@jingxiang-z
Copy link
Copy Markdown
Collaborator

Please remove the ticket number from PR title and add a semantic prefix like feat:

Comment thread third_party/fleet-intelligence-sdk/pkg/eventstore/types.go
@ambermingxin ambermingxin changed the title [GPUHEALTH-1778] Add event_id(UUID) to events info in agent message feat: Add event_id(UUID) to events info in agent message to backend Apr 13, 2026
@ambermingxin ambermingxin merged commit 594104e into main Apr 13, 2026
9 checks passed
@ambermingxin ambermingxin deleted the GPUHEALTH-1778 branch April 13, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants