Update/otel schema log fix #2703
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2703
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2703/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2358
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2358
Original created: 2026-01-18T20:27:02Z
Original updated: 2026-01-18T20:29:20Z
Original head: carverauto/serviceradar:update/otel-schema-log-fix
Original base: staging
Original merged: 2026-01-18T20:29:18Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement
Description
Add four new OpenTelemetry log fields:
observed_timestamp,trace_flags,event_name,scope_attributesUpdate log processors across Elixir, Go, and Rust to parse and persist new OTEL schema fields
Enhance log UI to augment nested attributes and extract resource/scope metadata from attributes
Add database migration and update schema definitions across all services
Diagram Walkthrough
File Walkthrough
10 files
Add OTEL field parsing functions to log processorAdd new OTEL attributes to Log resource schemaAugment log data with nested attribute extractionAdd parsing for new OTEL log fields in JSONUpdate log row creation to include new OTEL fieldsUpdate SQL insert statement with new columnsAdd new fields to OTELLogRow structExtract scope attributes and trace flags in RustAdd new fields to LogRow struct and JSON serializationUpdate Diesel schema definition with new columns1 files
Create migration to add new log table columns3 files
Add test for nested attributes augmentationUpdate test database schema with new columnsUpdate test fixture schema with new columns2 files
Minor formatting improvements in query builderMinor formatting improvements in test code1 files
Mark SRQL paths update task as completeImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2358#issuecomment-3765711767
Original created: 2026-01-18T20:27:50Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 No ticket provided
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Trace flag truncation:
parseTraceFlagsconverts a potentially non-integer/large numeric value toint32withoutvalidating bounds or integer-ness, which can silently truncate/alter the trace flags
value.
Referred Code
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Audit scope unclear: The PR primarily extends log schema/ingestion but does not show whether critical
user/security actions are consistently audited with user ID, timestamp, action, and
outcome across the system.
Referred Code
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status:
Sensitive data exposure: The UI now unwraps and renders nested
attributes/resource_attributes(and derivesscope/service fields), which may surface secrets/PII if those are present in incoming log
attributes.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2358#issuecomment-3765712902
Original created: 2026-01-18T20:29:10Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Move data normalization to ingestion
The suggestion is to move the data normalization logic, currently in the UI
layer (
show.ex), to the data ingestion processors. This ensures data isconsistently structured upon storage, improving query performance and data
reliability for all consumers.
Examples:
web-ng/lib/serviceradar_web_ng_web/live/log_live/show.ex [138-162]
pkg/consumers/db-event-writer/json_logs.go [140-160]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 9
__
Why: This is a critical architectural suggestion; placing normalization logic in the UI is incorrect and leads to data inconsistency, while the PR already implements similar logic in some ingestion paths, indicating this was an oversight.
Correctly handle epoch timestamps
Remove the
parsed.IsZero()check inparseObservedTimestampto preventincorrectly discarding valid Unix epoch timestamps.
pkg/consumers/db-event-writer/json_logs.go [453-473]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a bug where a valid Unix epoch timestamp would be incorrectly discarded due to the
IsZero()check, leading to data loss.Ensure resource attributes are correctly propagated
Fix a bug in
augment_log/1by correctly assigning the extracted nested resourceattributes to the
resource_attributesvariable, ensuring service details areproperly populated.
web-ng/lib/serviceradar_web_ng_web/live/log_live/show.ex [138-162]
Suggestion importance[1-10]: 8
__
Why: This suggestion correctly identifies a bug where nested
resource_attributesare not propagated correctly, causingput_service_from_resource/2to fail. The fix is accurate and necessary.Fix incorrect scope attributes parsing logic
Refactor
parse_scope_attributesto correctly handle the fallback tojson["scope"]after attempting to encodescope_attributes, preventing incorrectparsing when
scopeis a string.elixir/serviceradar_core/lib/serviceradar/event_writer/processors/logs.ex [135-147]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a logic flaw where falling back to
json["scope"]might result in an empty map ifscopeis a string. The proposed fix correctly handles this edge case.Preserve epoch for zero timestamp
In
safeTimeFromUnixNano, return the Unix epoch for a zero timestamp instead oftime.Now()to maintain consistent semantics for unset time fields.pkg/consumers/db-event-writer/processor.go [166-173]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that using
time.Now()for a zero timestamp is incorrect. Returning the Unix epoch is a more sensible default and aligns with howObservedTimestampis handled.Unify observed timestamp key
In
otel_logs.rs, rename theobserved_time_unix_nanoJSON field toobserved_timestampto ensure consistency across services.cmd/consumers/zen/src/otel_logs.rs [75-79]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: This suggestion correctly proposes standardizing the
observed_timestampfield name for consistency with other services in the PR, which improves maintainability and reduces parsing complexity downstream.