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: updated config to public preview config #9622

Merged
merged 8 commits into from Oct 18, 2022

Conversation

DNVindhya
Copy link
Contributor

@DNVindhya DNVindhya commented Oct 13, 2022

This PR implements config changes defined for public preview.
With new config schema, logging filters are matched on text-order basis compared to precedence basis and takes separate filters for client and server RPC events.

b/245415575

CC @sanjaypujare @ejona86

/* Set of fullMethodNames. */
public final Set<String> methods;

/** Number of bytes of header to log. */
public final Integer headerBytes;
Copy link
Member

Choose a reason for hiding this comment

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

I'd expect these to be unboxed, since they have clear defaults defined. Things like if (logFilter.excludePattern) { are just asking for a NPE right now.

Is matchAll in the same situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think boxed types were used, because of the return types from JsonUtil. But I see that using unboxed types makes sense here. I will update.

new ImmutableSet.Builder<>();
ImmutableSet.Builder<String> methodsSetBuilder =
new ImmutableSet.Builder<>();
List<?> methodsList = JsonUtil.getList(logFilterMap, "methods");
Copy link
Member

Choose a reason for hiding this comment

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

getListOfStrings()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

if (methodsList != null) {
for (Object pattern : methodsList) {
String methodOrServicePattern = String.valueOf(pattern);
if (methodOrServicePattern != null) {
Copy link
Member

Choose a reason for hiding this comment

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

This is always true. And will still always be true if swapped to getListOfStrings() above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

/** Pattern indicating which service/method to log. */
public final String pattern;
/** Pattern for service/method filter. */
public final List<String> pattern;
Copy link
Member

Choose a reason for hiding this comment

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

What is this used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just used to store patterns as we see in config. Since we already parse it, I will remove.

private void parseMonitoringObject(Map<String, ?> config, String jsonObjectName) {
Map<String, ?> rawCloudMonitoring = JsonUtil.getObject(config, jsonObjectName);
if (rawCloudMonitoring != null) {
if (rawCloudMonitoring.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

What is with this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this check for validation, if there are any nested objects and fields we might not want to enable monitoring. But as per new design, having an empty object enabled monitoring. I will remove this check.

if (rawCloudTracing != null) {
enableCloudTracing = true;
this.sampler = Samplers.probabilitySampler(0.0);
if (!rawCloudTracing.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

What is with this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this check the intention of adding non-default sampler when specified. Now that you pointed, I see it is redundant. Will remove this check.


private void parseLoggingObject(Map<String, ?> config, String jsonObjectName) {
Map<String, ?> rawCloudLogging = JsonUtil.getObject(config, jsonObjectName);
if (rawCloudLogging != null) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: These methods would have been better served by if (rawCloudLogging == null) return to avoid the indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I will update.

@sanjaypujare
Copy link
Contributor

...are matched on iterative basis...

Might be better to say it uses "text order" to match since "iterative" could be confusing

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

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

Finished this round of review. Will re-review once comments addressed

@DNVindhya
Copy link
Contributor Author

Addressed comments. PTAL

@stanley-cheung
Copy link
Contributor

Thanks for the fix. The integration tests all passed.

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

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

  • pls resolve conflicts
  • a few comments left and it will be good to resolve them

/** Number of bytes of each header to log. */
public final Integer headerBytes;
/* Set of fullMethodNames. */
public final Set<String> methods;
Copy link
Contributor

Choose a reason for hiding this comment

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

I might have alluded to this somewhere else: e.g. when user provides ["service1/method2", "*"] it will be good to sort it to ["*", "service1/method2"] since everything will match "*" and there is no need to do redundant comparison to "service1/method2" in the unsorted one. So it would have been ideal for this to be a List and sorted as per above. But we can make this optimization later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

logRpcMethod in ConfigFilterHelper tries to achieve this by comparing in the order:

  1. check for * filter present in the list of methods
  2. check for all methods under service filter i.e service/* instances
  3. Check against exact method i.e service/method

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

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

LGTM

@sanjaypujare sanjaypujare merged commit aeb90e3 into grpc:master Oct 18, 2022
@DNVindhya DNVindhya deleted the o11y-config-update branch October 18, 2022 21:30
sergiitk pushed a commit to sergiitk/grpc-java that referenced this pull request Oct 18, 2022
sergiitk pushed a commit to sergiitk/grpc-java that referenced this pull request Oct 18, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2023
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.

None yet

4 participants