Skip to content

Replace individual LogEntry URLs with collection LogEntries#4

Merged
yusufaytas merged 1 commit into
mainfrom
add-log-entries-support
Jan 4, 2026
Merged

Replace individual LogEntry URLs with collection LogEntries#4
yusufaytas merged 1 commit into
mainfrom
add-log-entries-support

Conversation

@yusufaytas
Copy link
Copy Markdown
Contributor

Individual log entries don't typically have meaningful URLs in log systems like Datadog/Kibana. Instead, URLs should point to the query results or filtered views that contain these entries. This change aligns the log API with the metrics pattern where MetricSeries has URLs, not individual MetricPoints, providing a more logical and useful interface for external linking.

Individual log entries don't typically have meaningful URLs in log systems like Datadog/Kibana.
Instead, URLs should point to the query results or filtered views that contain these entries.
This change aligns the log API with the metrics pattern where MetricSeries has URLs,
not individual MetricPoints, providing a more logical and useful interface for external linking.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jan 4, 2026

Greptile Summary

This PR refactors the log API to move the URL field from individual LogEntry objects to a new LogEntries collection wrapper, aligning with the pattern used for metrics where MetricSeries has URLs but individual MetricPoint objects do not.

Key Changes:

  • Introduced LogEntries struct with Entries []LogEntry and URL string fields
  • Removed URL field from individual LogEntry and Providers field from LogQuery
  • Updated log.Provider.Query() interface to return LogEntries instead of []LogEntry
  • Updated all plugin providers, tests, and mock implementations consistently
  • Documentation clarifies URL semantics: collection URLs point to query results view in source systems

Impact:
The change is well-motivated and consistent with the existing metric API pattern. All implementations (plugin providers, tests, mocks) have been updated correctly. The API response structure changes from returning an array directly to returning an object with entries and optional url fields.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The refactoring is systematic, consistent, and well-tested. All usages have been updated correctly including provider interfaces, plugin implementations, tests, and documentation. The change aligns with existing patterns in the codebase (metrics API) and improves API consistency
  • No files require special attention

Important Files Changed

Filename Overview
schema/log.go Introduces LogEntries wrapper struct with URL at collection level, removes URL from individual LogEntry and Providers field from LogQuery
log/provider.go Updates Provider.Query signature to return LogEntries instead of []LogEntry
api/plugin_providers.go Updates plugin provider to return LogEntries instead of []LogEntry
api/server_test.go Updates test mocks and assertions to use LogEntries wrapper, moves URL from entry to collection level
plugins/logmock/main.go Defines LogEntries wrapper, updates mock plugin to return wrapped log entries with URL

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Handler
    participant Provider as Log Provider
    participant External as External Log System

    Client->>API: POST /logs/query (LogQuery)
    API->>API: Validate query
    API->>Provider: Query(ctx, LogQuery)
    Provider->>External: Query logs (provider-specific API)
    External-->>Provider: Raw log results
    Provider->>Provider: Normalize to LogEntry[]
    Provider->>Provider: Wrap in LogEntries{Entries, URL}
    Provider-->>API: LogEntries (with collection URL)
    API-->>Client: JSON response {entries: [...], url: "..."}
    
    Note over Provider,External: URL points to query results view<br/>in source system (e.g., Datadog dashboard)
Loading

@yusufaytas yusufaytas merged commit 40bb9a7 into main Jan 4, 2026
4 checks passed
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.

1 participant