Skip to content

Commit

Permalink
[WFLY-16238] Don't export traces by default
Browse files Browse the repository at this point in the history
If no sender endpoint is configure, configure a no-op sender

PR feedback
  • Loading branch information
jasondlee committed Sep 20, 2022
1 parent 0f58896 commit fb81c80
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class TracerAttributes {

public static final SimpleAttributeDefinition SENDER_BINDING = SimpleAttributeDefinitionBuilder.create(TracerConfigurationConstants.SENDER_AGENT_BINDING, ModelType.STRING, true)
.setAttributeGroup("sender-configuration")
.setAllowExpression(true)
.setCapabilityReference(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME)
.addAccessConstraint(SensitiveTargetAccessConstraintDefinition.SOCKET_BINDING_REF)
.setRestartAllServices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@

package org.wildfly.extension.microprofile.opentracing;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

import static org.jboss.logging.Logger.Level.DEBUG;
import static org.jboss.logging.Logger.Level.ERROR;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

@MessageLogger(projectCode = "WFLYTRACEXT", length = 4)
public interface TracingExtensionLogger extends BasicLogger {
Expand Down Expand Up @@ -81,4 +81,7 @@ public interface TracingExtensionLogger extends BasicLogger {
OperationFailedException seeDownstream();
*/

@LogMessage(level = WARN)
@Message(id = 12, value="No Jaeger endpoint or sender-binding configured. Installing a no-op sender")
void senderNotConfigured();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
package org.wildfly.extension.microprofile.opentracing.spi.sender;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.senders.NoopSender;
import io.jaegertracing.spi.Sender;
import io.jaegertracing.spi.SenderFactory;
import io.jaegertracing.thrift.internal.senders.ThriftSenderFactory;
import org.wildfly.extension.microprofile.opentracing.TracingExtensionLogger;

/**
* Jaeger client SenderFactory implementation to be able to 'swallow' exceptions when sending the spans to a Jaeger server.
Expand All @@ -30,7 +32,18 @@ public class WildFlySenderFactory implements SenderFactory {

@Override
public Sender getSender(Configuration.SenderConfiguration configuration) {
return new WildFlySender(delegate.getSender(configuration));
if (!isSenderConfigured(configuration)) {
TracingExtensionLogger.ROOT_LOGGER.senderNotConfigured();
return new NoopSender();
} else {
return new WildFlySender(delegate.getSender(configuration));
}
}

private boolean isSenderConfigured(Configuration.SenderConfiguration configuration) {
return (configuration.getEndpoint() != null) ||
(configuration.getAgentHost() != null) ||
(configuration.getAgentPort() != null);
}

@Override
Expand Down

0 comments on commit fb81c80

Please sign in to comment.