Skip to content

[BUGFIX] Update plugin Selector functions for new datasource.Selector union type - #857

Merged
Nexucis merged 1 commit into
perses:mainfrom
asergeant01:fix/datasource-variable-selector
Oct 7, 2026
Merged

Nexucis merged 1 commit into
perses:mainfrom
asergeant01:fix/datasource-variable-selector

Conversation

@asergeant01

Copy link
Copy Markdown
Contributor

Description

This PR is the plugins-side complement to perses/perses#4545, which replaces the single datasource.Selector struct with an explicit union type:

  • ObjectSelector — the concrete {"kind": "…", "name": "…"} form
  • VariableSelector — the "$var" variable reference form
  • Selector — a union; exactly one of the above must be set

Previously, all 12 plugin Selector(name string) functions constructed &datasource.Selector{Kind: PluginKind, Name: name} directly. This meant that passing "$myDatasource" always produced the structured-object form in JSON/YAML output, which Perses cannot resolve at runtime because no datasource is literally named "$myDatasource".

Changes

All 12 plugin datasource packages are updated uniformly:

  • Selector(name string) now calls datasource.NewSelector(PluginKind, name) — for concrete datasource references.
  • VariableSelector(name string) is added, calling datasource.NewVariableSelector(name) — for variable references. Callers that previously passed a "$var" string to Selector() should switch to VariableSelector().

Note: this PR requires bumping github.com/perses/perses in go.mod once perses/perses#4545 is merged and tagged. The go.mod bump will be sent as a follow-up.

Screenshots

N/A — Go SDK only.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

N/A

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Every changed module references constructor APIs absent from its pinned Perses dependency, preventing compilation.

Review effort: Balanced
Findings: 12 High severity

Open (12)
What changed in this PR

Updates all datasource Go SDKs for static and variable selector construction.

Changes:

  • Uses datasource.NewStaticSelector for concrete datasources.
  • Adds VariableSelector wrappers for variable references.
File Description
alertmanager/​sdk/​go/​datasource/​datasource.go Updates Alertmanager selector helpers.
clickhouse/​sdk/​go/​datasource/​datasource.go Updates ClickHouse selector helpers.
greptimedb/​sdk/​go/​datasource/​datasource.go Updates GreptimeDB selector helpers.
jaeger/​sdk/​go/​datasource/​datasource.go Updates Jaeger selector helpers.
json/​sdk/​go/​datasource/​datasource.go Updates JSON selector helpers.
loki/​sdk/​go/​datasource/​datasource.go Updates Loki selector helpers.
opensearch/​sdk/​go/​datasource/​datasource.go Updates OpenSearch selector helpers.
prometheus/​sdk/​go/​datasource/​datasource.go Updates Prometheus selector helpers.
pyroscope/​sdk/​go/​datasource/​datasource.go Updates Pyroscope selector helpers.
splunk/​sdk/​go/​datasource/​datasource.go Updates Splunk selector helpers.
tempo/​sdk/​go/​datasource/​datasource.go Updates Tempo selector helpers.
victorialogs/​sdk/​go/​datasource/​datasource.go Updates VictoriaLogs selector helpers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread alertmanager/sdk/go/datasource/datasource.go Outdated
Comment thread clickhouse/sdk/go/datasource/datasource.go Outdated
Comment thread greptimedb/sdk/go/datasource/datasource.go Outdated
Comment thread jaeger/sdk/go/datasource/datasource.go Outdated
Comment thread json/sdk/go/datasource/datasource.go Outdated
Comment thread prometheus/sdk/go/datasource/datasource.go Outdated
Comment thread pyroscope/sdk/go/datasource/datasource.go Outdated
Comment thread splunk/sdk/go/datasource/datasource.go Outdated
Comment thread tempo/sdk/go/datasource/datasource.go Outdated
Comment thread victorialogs/sdk/go/datasource/datasource.go Outdated
@asergeant01
asergeant01 force-pushed the fix/datasource-variable-selector branch from d08a61c to 4667f46 Compare October 7, 2026 07:49
Comment thread alertmanager/sdk/go/query/alerts/options.go Outdated
@asergeant01
asergeant01 force-pushed the fix/datasource-variable-selector branch from 4667f46 to 4063f8a Compare October 7, 2026 08:50
@asergeant01
asergeant01 requested a review from Nexucis October 7, 2026 10:07
@asergeant01
asergeant01 force-pushed the fix/datasource-variable-selector branch from 4063f8a to dca53e5 Compare October 7, 2026 10:15
… union type

The upstream perses/perses change (perses/perses#4545) replaces the
single datasource.Selector struct with an explicit union type:
StaticSelector for concrete {kind, name} references, and
VariableSelector for "$var" references.

Update all 12 plugin datasource packages:
- Selector(name) now calls datasource.NewStaticSelector(PluginKind, name)
- Add VariableSelector(name) that calls datasource.NewVariableSelector(name)

Callers that previously passed a "$var" string to Selector() should
switch to VariableSelector() so the variable reference is emitted
correctly in JSON and YAML output.

Note: this change requires bumping github.com/perses/perses in go.mod
once perses/perses#4545 is merged and tagged.

Signed-off-by: Alan Sergeant <alan.sergeant@sap.com>
@asergeant01
asergeant01 force-pushed the fix/datasource-variable-selector branch from dca53e5 to 0ba147b Compare October 7, 2026 10:23

@Nexucis Nexucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

awesome ! Thank you @asergeant01

@Nexucis
Nexucis added this pull request to the merge queue Oct 7, 2026
Merged via the queue into perses:main with commit f6cad57 Oct 7, 2026
17 checks passed
@asergeant01
asergeant01 deleted the fix/datasource-variable-selector branch October 7, 2026 13:42
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.

3 participants