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

gcp-observability: add custom tags to metrics and traces using Stackdriver config-builders #9407

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

sanjaypujare
Copy link
Contributor

CC @DNVindhya to provide context/background of this task to the reviewer(s)

@sanjaypujare sanjaypujare requested a review from temawi July 24, 2022 09:38
Comment on lines 158 to 162
Map<LabelKey, LabelValue> constantLabels = new HashMap<>();
for (Map.Entry<String, String> mapEntry : customTags.entrySet()) {
constantLabels.put(LabelKey.create(mapEntry.getKey(), mapEntry.getKey()),
LabelValue.create(mapEntry.getValue()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit, but for a mundane map translation, something like this might be more succinct:

Map<LabelKey, LabelValue> constantLabels = customTags.entrySet().stream()
    .collect(Collectors.toMap(k -> LabelKey.create(k, k), v -> LabelValue.create(v)));

Same for your other map translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be this: do you agree?

       Map<LabelKey, LabelValue> constantLabels = customTags.entrySet().stream()
                .collect(Collectors.toMap(k -> LabelKey.create(k.getKey(), k.getKey()),
                   v -> LabelValue.create(v.getValue())));

because k and v are Map.Entry (and not Map.Key and Map.Value)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes - I did say "something like this" ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, PTAL

@sanjaypujare sanjaypujare merged commit e89d43d into grpc:master Jul 26, 2022
@sanjaypujare sanjaypujare deleted the custom-tags-metrics-traces branch July 26, 2022 15:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants