Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/target-manager-registered-metric #243

Merged
merged 2 commits into from
Dec 25, 2024

Conversation

puffitos
Copy link
Collaborator

Motivation

Part of #231

A metric in the target manager component should expose the current state of the sparrow (whether it's registered or not.)

Changes

  • Added metrics to target manager
  • Added new gauge metric (0/1) to the targetmanager, to expose the registration status
  • Set the new metric to 0/1 upon successful registration & deregistration of sparrow.

Tests done

Manual E2E tests were done. The sparrow exposes the new metric and it's 0 on start and is set to 1 upon registration.

❯ curl localhost:8080/metrics | rg register
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12718    0 12718    0     0  8112k      0 --:--:-- --:--:-- --:--:-- 12.1M
# HELP sparrow_target_manager_registered Indicates whether the instance is registered as a global target
# TYPE sparrow_target_manager_registered gauge
sparrow_target_manager_registered 1
❯ curl localhost:8080/metrics | rg register
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9743    0  9743    0     0  6859k      0 --:--:-- --:--:-- --:--:-- 9514k
# HELP sparrow_target_manager_registered Indicates whether the instance is registered as a global target
# TYPE sparrow_target_manager_registered gauge
sparrow_target_manager_registered 0

Deregistration wasn't tested in an e2e setting, as deregistration only happens upon shutdown -> the metric isn't exposed anymore. I didn't start a local prometheus just to check whether the last state would've parsed. Additionally, as there is no guarantee that the last state of the metric will be parsed from prometheus, I don't know how one can easily test this scenario without some complicated setup :)

  • Unit tests succeeded
  • E2E tests succeeded

TODO

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

@puffitos puffitos self-assigned this Dec 23, 2024
@puffitos puffitos added feature Introduces a new feature area/target-manager Issues/PRs related to the TargetManager labels Dec 23, 2024
@puffitos puffitos merged commit 92835cf into main Dec 25, 2024
8 checks passed
@puffitos puffitos deleted the feat/target-manager-registered-metric branch December 25, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/target-manager Issues/PRs related to the TargetManager feature Introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants