Converts {@link TraceConfig} to {@link TraceParams}.

@param traceConfigProto {@code TraceConfig}.
@param currentTraceParams current {@code TraceParams}.
@return updated {@code TraceParams}.
@since 0.17
175085
static TraceParams fromTraceConfigProto(
      TraceConfig traceConfigProto, TraceParams currentTraceParams) {
    TraceParams.Builder builder = currentTraceParams.toBuilder();
    if (traceConfigProto.hasConstantSampler()) {
      ConstantSampler constantSampler = traceConfigProto.getConstantSampler();
      ConstantDecision decision = constantSampler.getDecision();
      if (ConstantDecision.ALWAYS_ON.equals(decision)) {
        builder.setSampler(Samplers.alwaysSample());
      } else if (ConstantDecision.ALWAYS_OFF.equals(decision)) {
        builder.setSampler(Samplers.neverSample());
      } // else if (ConstantDecision.ALWAYS_PARENT.equals(decision)) {
      // For ALWAYS_PARENT, don't need to update configs since in Java by default parent sampling
      // decision always takes precedence.
      // }
    } else if (traceConfigProto.hasProbabilitySampler()) {
      builder.setSampler(
          Samplers.probabilitySampler(
              traceConfigProto.getProbabilitySampler().getSamplingProbability()));
    } // TODO: add support for RateLimitingSampler.
    return builder.build();
  }
519399
private static TraceServiceGrpc.TraceServiceStub getTraceServiceStub(
      String endPoint, Boolean useInsecure, SslContext sslContext) {
    ManagedChannelBuilder<?> channelBuilder;
    if (useInsecure) {
      channelBuilder = ManagedChannelBuilder.forTarget(endPoint).usePlaintext();
    } else {
      channelBuilder =
          NettyChannelBuilder.forTarget(endPoint)
              .negotiationType(NegotiationType.TLS)
              .sslContext(sslContext);
    }
    ManagedChannel channel = channelBuilder.build();
    return TraceServiceGrpc.newStub(channel);
  }
1261192
void applyActiveTrace()
                    throws java.io.IOException {
        String[] names = activeNames.split(":");

        // Loop over existing Components.
        for (java.util.Iterator traceIterator = activeTrace.values().iterator(); traceIterator.hasNext();) {
            AbstractTrace abstractTrace = (AbstractTrace) traceIterator.next();

            int traceLevelToSet = Trace.Level_None;
            // Loop over active Components, testing to see if any of them is a match.
            for (int i = 0; i < names.length; i++) {
                String name = names[i];
                if (name.equals("*"))
                    name = ".*";
                if (java.util.regex.Pattern.matches(name, abstractTrace.getSourceClass().getName()))
                    traceLevelToSet = traceLevel;
            } // for names...
            abstractTrace.setLevel(traceLevelToSet);
        } // for ... activeTrace Map.

    }
644308
private synchronized void sendCurrentConfig() {
    // Bouncing back CurrentLibraryConfig to Agent.
    io.opencensus.proto.trace.v1.TraceConfig currentTraceConfigProto =
        TraceProtoUtils.getCurrentTraceConfig(traceConfig);
    CurrentLibraryConfig currentLibraryConfig =
        CurrentLibraryConfig.newBuilder().setConfig(currentTraceConfigProto).build();
    sendCurrentConfig(currentLibraryConfig);
  }
1365409
protected WsTraceRouterImpl getTraceRouter() {
        if (traceRouter == null) {
            // First activation.
            traceRouter = WsTraceRouterSingleton.singleton;

            // Pass the MessageRouter to the TrService via the TrConfigurator.
            TrConfigurator.setTraceRouter(traceRouter);
        }

        return traceRouter;
    }
1068937
public Trace getTrace(Class sourceClass,
                          String traceGroup) {
        synchronized (activeTrace) {
            TraceImpl traceImpl = new TraceImpl(sourceClass, traceGroup, this);
            activeTrace.put(sourceClass, traceImpl);
            try {
                applyActiveTrace();
            } catch (java.io.IOException exception) {
                System.out.println(cclass + ":getTrace() exception" + exception);
                exception.printStackTrace();
            } // try.

            return traceImpl;
        } // synchronized (activeTrace).
    }
208563
protected boolean invokeTraceRouters(RoutedMessage routedTrace) {

        boolean retMe = true;
        LogRecord logRecord = routedTrace.getLogRecord();
        /*
         * Avoid any feedback traces that are emitted after this point.
         * The first time the counter increments is the first pass-through.
         * The second time the counter increments is the second pass-through due
         * to trace emitted. We do not want any more pass-throughs.
         */
        try {
            if (!(counterForTraceRouter.incrementCount() > 2)) {
                if (logRecord != null) {
                    Level level = logRecord.getLevel();
                    int levelValue = level.intValue();
                    if (levelValue < Level.INFO.intValue()) {
                        String levelName = level.getName();
                        if (!(levelName.equals("SystemOut") || levelName.equals("SystemErr"))) { //SystemOut/Err=700
                            WsTraceRouter internalTrRouter = internalTraceRouter.get();
                            if (internalTrRouter != null) {
                                retMe &= internalTrRouter.route(routedTrace);
                            } else if (earlierTraces != null) {
                                synchronized (this) {
                                    if (earlierTraces != null) {
                                        earlierTraces.add(routedTrace);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } finally {
            counterForTraceRouter.decrementCount();
        }
        return retMe;
    }
517301
Tracer newTracer(String passName) {
    String comment = passName
        + (recentChange.hasCodeChanged() ? " on recently changed AST" : "");
    if (options.getTracerMode().isOn() && tracker != null) {
      tracker.recordPassStart(passName, true);
    }
    return new Tracer("Compiler", comment);
  }
444202
public void setTraces(Trace... traces) {
        if (this.httpClient instanceof DefaultHttpClient) {
            ((DefaultHttpClient)this.httpClient).setTraces(traces);
        }
        else
            throw new UnsupportedOperationException("Invalid operation for class " + this.httpClient.getClass());
    }
186506
public Router trace(@NotNull final Pattern regex, @NotNull final IMiddleware... handlers) {
        addRegEx("TRACE", regex, handlers, traceBindings);
        return this;
    }
429146
public static StatsTraceContext newServerContext(
      List<? extends ServerStreamTracer.Factory> factories,
      String fullMethodName,
      Metadata headers) {
    if (factories.isEmpty()) {
      return NOOP;
    }
    StreamTracer[] tracers = new StreamTracer[factories.size()];
    for (int i = 0; i < tracers.length; i++) {
      tracers[i] = factories.get(i).newServerStreamTracer(fullMethodName, headers);
    }
    return new StatsTraceContext(tracers);
  }
994475
@Override
    public void setTraceRouter(WsTraceRouter traceRouter) {

        internalTraceRouter.set(traceRouter);

        // Pass the earlierMessages queue to the router.
        // Now that the internalMessageRouter is non-null, this class will
        // NOT add any more messages to the earlierMessages queue.
        // The MessageRouter basically owns the earlierMessages queue
        // from now on.
        if (earlierTraces != null) {
            synchronized (this) {
                if (earlierTraces != null) {
                    traceRouter.setEarlierTraces(earlierTraces);
                }
            }
        } else {
            traceRouter.setEarlierTraces(null);
        }
    }
1182779
public static Tracing getTracing(String serviceName, CurrentTraceContext context) {
        Tracing tracing = Tracing.current();
        if (tracing == null) {
            // TODO reporter based on prop/config
            tracing = getBuilder(serviceName, context).build();
        }
        return tracing;
    }
929415
@Override
    protected void publishTraceLogRecord(TraceWriter detailLog, LogRecord logRecord, Object id, String formattedMsg, String formattedVerboseMsg) {
        if (formattedVerboseMsg == null) {
            formattedVerboseMsg = formatter.formatVerboseMessage(logRecord, formattedMsg, false);
        }
        Level level = logRecord.getLevel();
        int levelVal = level.intValue();

        String traceDetail = formatter.traceLogFormat(logRecord, id, formattedMsg, formattedVerboseMsg);
        invokeTraceRouters(new RoutedMessageImpl(formattedMsg, formattedVerboseMsg, traceDetail, logRecord));
        if (traceDetail.contains("x.com.ibm")) {
            return;
        }
        if (detailLog == systemOut || detailLog == systemErr) {
            if (levelVal == WsLevel.ERROR.intValue() || levelVal == WsLevel.SEVERE.intValue()) {
                writeStreamOutput(systemErr, traceDetail, false);
            } else {
                writeStreamOutput((SystemLogHolder) detailLog, traceDetail, false);
            }
        } else {
            detailLog.writeRecord(traceDetail);
        }
    }
1119490
public Router trace(@NotNull final String pattern, @NotNull final IMiddleware... handlers) {
        addPattern("TRACE", pattern, handlers, traceBindings);
        return this;
    }
655813
public static traceroute[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception
	{
		traceroute obj = new traceroute();
		options option = new options();
		option.set_filter(filter);
		traceroute[] response = (traceroute[]) obj.getfiltered(service, option);
		return response;
	}
435745
Call<Map<String, Long>> newBucketedTraceIdCall(
    QueryRequest request, TimestampRange timestampRange, int traceIndexFetchSize) {
    // trace_by_service_span adds special empty-string span name in order to search by all
    String spanName = null != request.spanName() ? request.spanName() : "";
    Long minDuration = request.minDuration(), maxDuration = request.maxDuration();
    int startBucket = CassandraUtil.durationIndexBucket(timestampRange.startMillis * 1000);
    int endBucket = CassandraUtil.durationIndexBucket(timestampRange.endMillis * 1000);
    if (startBucket > endBucket) {
      throw new IllegalArgumentException(
        "Start bucket (" + startBucket + ") > end bucket (" + endBucket + ")");
    }

    // "" isn't a real value. it is used to template bucketed calls and replaced later
    String serviceName = null != request.serviceName() ? request.serviceName() : "";

    // TODO: ideally, the buckets are traversed backwards, only spawning queries for older buckets
    // if younger buckets are empty. This will be an async continuation, punted for now.
    List<SelectTraceIdsFromServiceSpan.Input> serviceSpans = new ArrayList<>();
    List<SelectTraceIdsFromServiceRemoteService.Input> serviceRemoteServices = new ArrayList<>();
    String remoteService = request.remoteServiceName();
    for (int bucket = endBucket; bucket >= startBucket; bucket--) {
      boolean addSpanQuery = true;
      if (remoteService != null) {
        if (traceIdsFromServiceRemoteService == null) {
          throw new IllegalArgumentException("remoteService=" + remoteService
            + " unsupported due to missing table " + TABLE_SERVICE_REMOTE_SERVICES);
        }
        serviceRemoteServices.add(
          traceIdsFromServiceRemoteService.newInput(
            serviceName,
            remoteService,
            bucket,
            timestampRange,
            traceIndexFetchSize));
        // If the remote service query can satisfy the request, don't make a redundant span query
        addSpanQuery = !spanName.isEmpty() || minDuration != null;
      }
      if (!addSpanQuery) continue;

      serviceSpans.add(
        traceIdsFromServiceSpan.newInput(
          serviceName,
          spanName,
          bucket,
          minDuration,
          maxDuration,
          timestampRange,
          traceIndexFetchSize));
    }

    if ("".equals(serviceName)) {
      // If we have no service name, we have to lookup service names before running trace ID queries
      Call<List<String>> serviceNames = getServiceNames();
      if (serviceRemoteServices.isEmpty()) {
        return serviceNames.flatMap(traceIdsFromServiceSpan.newFlatMapper(serviceSpans));
      } else if (serviceSpans.isEmpty()) {
        return serviceNames.flatMap(
          traceIdsFromServiceRemoteService.newFlatMapper(serviceRemoteServices));
      }
      return serviceNames.flatMap(new AggregateFlatMapper<>(
        traceIdsFromServiceSpan.newFlatMapper(serviceSpans),
        traceIdsFromServiceRemoteService.newFlatMapper(serviceRemoteServices)
      ));
    }
    if (serviceRemoteServices.isEmpty()) {
      return traceIdsFromServiceSpan.newCall(serviceSpans);
    } else if (serviceSpans.isEmpty()) {
      return traceIdsFromServiceRemoteService.newCall(serviceRemoteServices);
    } else {
      return new IntersectMaps<>(asList(
        traceIdsFromServiceSpan.newCall(serviceSpans),
        traceIdsFromServiceRemoteService.newCall(serviceRemoteServices)
      ));
    }
  }