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

MultiEndpoint metrics #158

Merged
merged 1 commit into from Jan 27, 2023
Merged

MultiEndpoint metrics #158

merged 1 commit into from Jan 27, 2023

Conversation

nimf
Copy link
Collaborator

@nimf nimf commented Jan 26, 2023

Adding new metrics for the multi-endpoint feature:

  • endpoint_state (Long Gauge) Labels: endpoint, status (AVAILABLE/UNAVAILABLE). Reports 1 when an endpoint is in the status.
  • endpoint_switch (Long Cumulative) Labels: me_name, type (FALLBACK/RECOVER/REPLACE). Counts the number a multi-endpoint with the name me_name switched current endpoint. When switching to a lower priority endpoint the type is FALLBACK, switching to higher priority is RECOVER and switching because of a new set of endpoints provided is REPLACE.
  • current_endpoint (Long Gauge) Labels: me_name, endpoint. Reports 1 when a multi-endpoint with the name me_name has the endpoint as current.

@nimf nimf requested a review from mohanli-ml January 26, 2023 18:37
@@ -318,7 +518,15 @@ public synchronized void setMultiEndpoints(List<GcpMultiEndpointOptions> meOptio
defaultMultiEndpoint = multiEndpoints.get(meOptions.get(0).getName());

// Remove obsolete multiendpoints.
multiEndpoints.keySet().removeIf(name -> !currentMultiEndpoints.contains(name));
Iterator<String> iter = multiEndpoints.keySet().iterator();
while (iter.hasNext()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not familiar with Java, so this might be a stupid question. But since this is a loop, do you need to update iter? Like iter = iter.Next();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, there is no need in that. When we call iter.next() it advances the current item pointer and retrieves the item.

} else if (fromIdx < toIdx) {
fallbackCnt++;
} else {
recoverCnt++;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just double check, when fromIdx == toIdx, the type is also recover?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fromIdx == toIdx if and only if toId.equals(fromId) because the priority assigned to an endpoint comes from incrementing counter and is unique. And this condition is checked in the first line of this method.

@nimf nimf merged commit 1bda48e into master Jan 27, 2023
@nimf nimf deleted the me_metrics branch January 30, 2023 19:06
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.

None yet

2 participants