You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am consuming the proto in java agent and I want to provide default values for header/body capture (enabled by default) but also reporting address and secure reporting.
The reporting address is easy to set. If it is empty I will just set it to a default value. However the problem is with bool values e.g. reporting.secure and dataCapture.httpHeaders.request etc. These values I am not able to check if they have been set by the user or not. Specifically, I am not able to determine if the user explicitly set the bool to false.
FieldDescriptorrequestField = httpBodyBuilder.getDescriptorForType().findFieldByName("request");
if (!httpBodyBuilder.hasField(requestField)) { // returns always false even if the field has been set to false.httpBodyBuilder.setRequest(true);
}
Here is how I create the config.
publicstaticAgentConfigload(Stringfilename) throwsIOException {
FileconfigFile = newFile(filename);
InputStreamfileInputStream = newFileInputStream(configFile);
Stringjson = convertYamlToJson(fileInputStream);
AgentConfig.BuilderconfigProtoBuilder = AgentConfig.newBuilder(); // if the applyDefaults is called here the PARSER fails on com.google.protobuf.InvalidProtocolBufferException: Field AgentConfig.serviceName has already been set.PARSER.ignoringUnknownFields().merge(json, configProtoBuilder);
AgentConfigagentConfig = configProtoBuilder.build();
returnapplyDefaults(agentConfig.toBuilder()).build();
I am consuming the proto in java agent and I want to provide default values for header/body capture (enabled by default) but also reporting address and secure reporting.
The reporting address is easy to set. If it is empty I will just set it to a default value. However the problem is with
bool
values e.g.reporting.secure
anddataCapture.httpHeaders.request
etc. These values I am not able to check if they have been set by the user or not. Specifically, I am not able to determine if the user explicitly set thebool
to false.Here is how I create the config.
see also protocolbuffers/protobuf#359
I propose to use
optional
in the filed, however it is an experimental feature or use wrappers which is a recommended approach - https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wrappers.proto and https://developers.google.com/protocol-buffers/docs/reference/google.protobuf``
The text was updated successfully, but these errors were encountered: