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
Conversation
/* Set of fullMethodNames. */ | ||
public final Set<String> methods; | ||
|
||
/** Number of bytes of header to log. */ | ||
public final Integer headerBytes; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getListOfStrings()
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/interceptors/ConfigFilterHelper.java
Show resolved
Hide resolved
Might be better to say it uses "text order" to match since "iterative" could be confusing |
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfig.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/interceptors/ConfigFilterHelper.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/interceptors/ConfigFilterHelper.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/interceptors/ConfigFilterHelper.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/LoggingTest.java
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/ObservabilityConfigImplTest.java
Show resolved
Hide resolved
gcp-observability/src/test/java/io/grpc/gcp/observability/TracesTest.java
Show resolved
Hide resolved
There was a problem hiding this 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
Addressed comments. PTAL |
Thanks for the fix. The integration tests all passed. |
gcp-observability/src/main/java/io/grpc/gcp/observability/ObservabilityConfigImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
fe312c6
to
7c24daf
Compare
/** Number of bytes of each header to log. */ | ||
public final Integer headerBytes; | ||
/* Set of fullMethodNames. */ | ||
public final Set<String> methods; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- check for
*
filter present in the list of methods - check for all methods under service filter i.e
service/*
instances - Check against exact method i.e
service/method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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