szetszwo commented on code in PR #1428:
URL: https://github.com/apache/ratis/pull/1428#discussion_r3319760441
##########
ratis-common/src/main/java/org/apache/ratis/trace/TraceConfigKeys.java:
##########
@@ -30,8 +31,20 @@ public interface TraceConfigKeys {
String ENABLED_KEY = PREFIX + ".enabled";
boolean ENABLED_DEFAULT = false;
+ /**
+ * Whether Ratis should emit OpenTelemetry spans. When the key is absent from
+ * {@link RaftProperties}, the JVM system property {@value #ENABLED_KEY} is
consulted so
+ * {@code -Draft.otel.tracing.enabled=true} works with empty example configs.
+ */
static boolean enabled(RaftProperties properties, Consumer<String> logger) {
- return getBoolean(properties::getBoolean, ENABLED_KEY, ENABLED_DEFAULT,
logger);
+ if (properties.getRaw(ENABLED_KEY) != null) {
+ return getBoolean(properties::getBoolean, ENABLED_KEY, ENABLED_DEFAULT,
logger);
+ }
+ final String fromSystem = System.getProperty(ENABLED_KEY);
Review Comment:
Let's don't fallback to JVM system properties.
Ratis currently do not handle how the confs are stored (e.g. in a file, in a
DB, in an external service, or JVM system properties). The application uses
Ratis has to decide how to do it and pass it to Ratis via a RaftProperties
object.
Also, using JVM system properties could cause problem for applications using
Ratis for multiple components -- e.g. there could be two different services
running in the same JVM using Ratis. They may use different confs.
##########
ratis-examples/src/main/bin/client.sh:
##########
@@ -32,4 +33,4 @@ shift
subcommand="$1"
shift
-java ${LOGGER_OPTS} -jar $ARTIFACT "$example" "$subcommand" "$@"
+java ${OTEL_OPTS} ${LOGGER_OPTS} -jar $ARTIFACT "$example" "$subcommand" "$@"
Review Comment:
For the example command, we could change it to get the JVM property and then
set it to RaftProperties.
One idea is to add a new ExampleLuancher class, which will read JVM property
and then pass it to the examples (e.g. "filestore" or "arithmetic").
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]