All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.kafka.tracing.TracingFactory Maven / Gradle / Ivy

package io.dropwizard.kafka.tracing;

import brave.Tracing;
import brave.kafka.clients.KafkaTracing;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Optional;

public class TracingFactory {
    @JsonProperty
    private boolean enabled = true;

    @JsonProperty
    private boolean writeB3SingleFormat = true;

    @JsonProperty
    private String remoteServiceName;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(final boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isWriteB3SingleFormat() {
        return writeB3SingleFormat;
    }

    public void setWriteB3SingleFormat(final boolean writeB3SingleFormat) {
        this.writeB3SingleFormat = writeB3SingleFormat;
    }

    public String getRemoteServiceName() {
        return remoteServiceName;
    }

    public void setRemoteServiceName(final String remoteServiceName) {
        this.remoteServiceName = remoteServiceName;
    }

    public Optional build(final Tracing tracing) {
        if (tracing == null) {
            return Optional.empty();
        }

        if (!enabled) {
            return Optional.empty();
        }

        return Optional.of(KafkaTracing.newBuilder(tracing)
                .writeB3SingleFormat(writeB3SingleFormat)
                .remoteServiceName(remoteServiceName)
                .build());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy