private String processShellVar(String var) { if (var.equals("tname")) { return tracerName; } else if (var.equals("pname")) { return getProcessName(); } else if (var.equals("ip")) { return getBestIpString(); } else if (var.equals("pid")) { return Long.valueOf(getOsPid()).toString(); } else { LOG.warn("unknown ProcessID variable " + var); return ""; } }
/** * <p>Get the process id from the operating system.</p> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }
public Tracer build() { if (name == null) { throw new RuntimeException("You must specify a name for this Tracer."); } LinkedList<SpanReceiver> spanReceivers = new LinkedList<SpanReceiver>(); LinkedList<Sampler> samplers = new LinkedList<Sampler>(); loadSamplers(samplers); String tracerId = new TracerId(conf, name).get(); Tracer tracer = new Tracer(tracerId, tracerPool, samplers.toArray(new Sampler[samplers.size()])); tracerPool.addTracer(tracer); loadSpanReceivers(); return tracer; } }
if (!escaping) { String var = varBld.toString(); bld.append(processShellVar(var)); varBld = null; varSeen = 0;
/** * @return The new Tracer object. */ public Tracer build() { if (name == null) { throw new RuntimeException("You must specify a name for this Tracer."); } LinkedList<Sampler> samplers = new LinkedList<Sampler>(); loadSamplers(samplers); String tracerId = new TracerId(conf, name).get(); Tracer tracer = new Tracer(tracerId, tracerPool, samplers.toArray(new Sampler[samplers.size()])); tracerPool.addTracer(tracer); loadSpanReceivers(); if (LOG.isTraceEnabled()) { LOG.trace("Created " + tracer + " for " + name); } return tracer; } }
if (!escaping) { String var = varBld.toString(); bld.append(processShellVar(var)); varBld = null; varSeen = 0;
private String processShellVar(String var) { if (var.equals("tname")) { return tracerName; } else if (var.equals("pname")) { return getProcessName(); } else if (var.equals("ip")) { return getBestIpString(); } else if (var.equals("pid")) { return Long.valueOf(getOsPid()).toString(); } else { LOG.warn("unknown ProcessID variable " + var); return ""; } }
/** * @return The new Tracer object. */ public Tracer build() { if (name == null) { throw new RuntimeException("You must specify a name for this Tracer."); } LinkedList<Sampler> samplers = new LinkedList<Sampler>(); loadSamplers(samplers); String tracerId = new TracerId(conf, name).get(); Tracer tracer = new Tracer(tracerId, tracerPool, samplers.toArray(new Sampler[samplers.size()])); tracerPool.addTracer(tracer); loadSpanReceivers(); if (LOG.isTraceEnabled()) { LOG.trace("Created " + tracer + " for " + name); } return tracer; } }
/** * Get the process id from the operating system.<p/> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }
if (!escaping) { String var = varBld.toString(); bld.append(processShellVar(var)); varBld = null; varSeen = 0;
private String processShellVar(String var) { if (var.equals("tname")) { return tracerName; } else if (var.equals("pname")) { return getProcessName(); } else if (var.equals("ip")) { return getBestIpString(); } else if (var.equals("pid")) { return Long.valueOf(getOsPid()).toString(); } else { LOG.warn("unknown ProcessID variable " + var); return ""; } }
/** * <p>Get the process id from the operating system.</p> * * Unfortunately, there is no simple method to get the process id in Java. * The approach we take here is to use the shell method (see * {TracerId#getOsPidFromShellPpid}) unless we are on Windows, where the * shell is not available. On Windows, we use * {TracerId#getOsPidFromManagementFactory}, which depends on some * undocumented features of the JVM, but which doesn't require a shell. */ static long getOsPid() { if ((System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH)). contains("windows")) { return getOsPidFromManagementFactory(); } else { return getOsPidFromShellPpid(); } }
@Test public void testSubstitutionVariables() throws IOException { testTracerIdImpl("myTracerName", "my%{tname}"); testTracerIdImpl(TracerId.getProcessName(), "%{pname}"); testTracerIdImpl("my." + TracerId.getProcessName(), "my.%{pname}"); testTracerIdImpl(TracerId.getBestIpString() + ".str", "%{ip}.str"); testTracerIdImpl("%{pname}", "\\%{pname}"); testTracerIdImpl("%cash%money{}", "%cash%money{}"); testTracerIdImpl("Foo." + Long.valueOf(TracerId.getOsPid()).toString(), "Foo.%{pid}"); } }