Skip to content

Check if query names are unique across jobs#150

Open
dewey wants to merge 1 commit into
masterfrom
philippdefner/error-if-duplicate-metric-names
Open

Check if query names are unique across jobs#150
dewey wants to merge 1 commit into
masterfrom
philippdefner/error-if-duplicate-metric-names

Conversation

@dewey

@dewey dewey commented Feb 17, 2025

Copy link
Copy Markdown
Member

No description provided.

@marevers marevers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@dewey dewey requested a review from Copilot March 20, 2025 12:15

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.

Pull Request Overview

This PR ensures that query names are unique across jobs to prevent conflicts in Prometheus metrics.

  • Introduces a validation loop to detect duplicate query names.
  • Aborts exporter initialization with a descriptive error when duplicates are found.

Comment thread exporter.go
for _, job := range cfg.Jobs {
for _, query := range job.Queries {
if _, ok := uniqueQueries[query.Name]; ok {
duplicateQueries = append(duplicateQueries, query.Name)

Copilot AI Mar 20, 2025

Copy link

Choose a reason for hiding this comment

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

Duplicate query names may be appended multiple times if encountered repeatedly, resulting in redundant entries in the error message.

Suggested change
duplicateQueries = append(duplicateQueries, query.Name)
if _, added := addedDuplicates[query.Name]; !added {
duplicateQueries = append(duplicateQueries, query.Name)
addedDuplicates[query.Name] = struct{}{}
}

Copilot uses AI. Check for mistakes.
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