Skip to content

refactor(checks): move global target merging responsibility to checks#278

Open
lvlcn-t wants to merge 2 commits intomainfrom
refactor/global-targets
Open

refactor(checks): move global target merging responsibility to checks#278
lvlcn-t wants to merge 2 commits intomainfrom
refactor/global-targets

Conversation

@lvlcn-t
Copy link
Collaborator

@lvlcn-t lvlcn-t commented Mar 23, 2025

Motivation

Closes #100

I've also added global target merging for the traceroute check, as we didn't enrich the targets yet.

Changes

This commit moves the responsibility of merging global targets with the configured targets to each check. This way the checks can decide how to merge the global targets with the configured targets.

Signed-off-by: lvlcn-t 75443136+lvlcn-t@users.noreply.github.com

For additional information look at the commits.

Tests done

I've added an additional test case for the traceroute enrichment.

  • Unit tests succeeded
  • E2E tests succeeded - we have none for this

TODO

  • I've assigned this PR to myself
  • I've labeled this PR correctly

This commit moves the responsibility of merging global targets with the configured targets to each check. This way the checks can decide how to merge the global targets with the configured targets.

Signed-off-by: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com>
@lvlcn-t lvlcn-t added refactoring Refactoring of existing code area/checks Issues/PRs related to Checks labels Mar 23, 2025
@lvlcn-t lvlcn-t self-assigned this Mar 23, 2025
This commit uses the target.String() representation in error logs to make the error messages more readable.

Signed-off-by: lvlcn-t <75443136+lvlcn-t@users.noreply.github.com>
Comment on lines +94 to +96
func (g GlobalTarget) URL() (*url.URL, error) {
return url.Parse(g.Url)
}
Copy link
Member

Choose a reason for hiding this comment

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

We're already storing the url on the GlobalTarget as a string. Why not parse that string into a url when we first construct the object? That way getting the url can never fail. Getting the URL as a string is using stringbuilder internally, so it should also be reasonably efficient (atleast faster than parsing the url)

Copy link
Member

Choose a reason for hiding this comment

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

To add to this, we also call this method everywhere in the interface implementation, so parsing the url is done quite often.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will require a bigger refactoring, since we use the string everywhere. Should I do it in this PR or shall I open another?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/checks Issues/PRs related to Checks refactoring Refactoring of existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Move global target merging responsibility to checks

2 participants