Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

TRACER-#369: Added a logger property logr which will handle the excep… #668

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@

package io.jaegertracing.thrift.internal.senders;

import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

import io.jaegertracing.Configuration;
import io.jaegertracing.agent.thrift.Agent;
import io.jaegertracing.internal.JaegerTracer;
import io.jaegertracing.internal.exceptions.SenderException;
import io.jaegertracing.thrift.internal.reporters.protocols.ThriftUdpTransport;
import io.jaegertracing.thriftjava.Batch;
import io.jaegertracing.thriftjava.Process;
import java.util.List;
import lombok.ToString;

@ToString
public class UdpSender extends ThriftSender {
public static final String DEFAULT_AGENT_UDP_HOST = "localhost";
public static final int DEFAULT_AGENT_UDP_COMPACT_PORT = 6831;

private final static Logger logr = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);

@ToString.Exclude private Agent.Client agentClient;
@ToString.Exclude private ThriftUdpTransport udpTransport;
Expand Down Expand Up @@ -66,6 +75,31 @@ public void send(Process process, List<io.jaegertracing.thriftjava.Span> spans)
throw new SenderException(String.format("Could not send %d spans", spans.size()), e, spans.size());
}
}

public JaegerTracer getTracer() {

LogManager.getLogManager().reset();
logr.setLevel(Level.ALL);

ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.SEVERE);
logr.addHandler(ch);

try {
FileHandler fh = new FileHandler("getTracer", true);
fh.setLevel(Level.FINE);
logr.addHandler(fh);

}
catch (java.io.IOException e) {

logr.log(Level.SEVERE, "File Logger not working", e);

}

logr.info("Logged Exception");
return Configuration.fromEnv().getTracer();
}

@Override
public int close() throws SenderException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@

package io.jaegertracing.tracerresolver.internal;

import io.jaegertracing.Configuration;
import io.jaegertracing.internal.JaegerTracer;
import io.opentracing.Tracer;
import io.opentracing.contrib.tracerresolver.TracerFactory;

public class JaegerTracerFactory implements TracerFactory {
@Override
public JaegerTracer getTracer() {
return Configuration.fromEnv().getTracer();

@Override
public Tracer getTracer() {
// TODO Auto-generated method stub
return null;
}

}
}