Constructs a new {@code TracezZPageHandler}.

@param runningSpanStore the instance of the {@code RunningSpanStore} to be used.
@param sampledSpanStore the instance of the {@code SampledSpanStore} to be used.
@return a new {@code TracezZPageHandler}.
352744
static TracezZPageHandler create(
      @javax.annotation.Nullable RunningSpanStore runningSpanStore,
      @javax.annotation.Nullable SampledSpanStore sampledSpanStore) {
    return new TracezZPageHandler(runningSpanStore, sampledSpanStore);
  }
261283
private org.javasimon.jmx.CounterSample sampleCounter(Simon counter) {
		return new CounterSample((org.javasimon.CounterSample) counter.sample());
	}
40536
public ServerListenerBuilder addStoppedCallback(Runnable runnable) {
        requireNonNull(runnable, "runnable");
        serverStoppedCallbacks.add(unused -> runnable.run());
        return this;
    }
538450
@Override
    public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSRuntimeException, InvalidDestinationRuntimeException, InvalidSelectorRuntimeException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createBrowser", new Object[] { queue, messageSelector });

        QueueBrowser queueBrowser = null;

        try {
            queueBrowser = jmsSession.createBrowser(queue, messageSelector);
        } catch (InvalidDestinationException ide) {
            throw (InvalidDestinationRuntimeException) JmsErrorUtils.getJMS2Exception(ide, InvalidDestinationRuntimeException.class);
        } catch (InvalidSelectorException ise) {
            throw (InvalidSelectorRuntimeException) JmsErrorUtils.getJMS2Exception(ise, InvalidSelectorRuntimeException.class);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createBrowser");
        }

        return queueBrowser;
    }
75529
public KeyStore newInstance() throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, IOException {
        if (data == null) {
            throw new IllegalStateException("data property is not set.");
        }

        KeyStore ks;
        if (provider == null) {
            ks = KeyStore.getInstance(type);
        } else {
            ks = KeyStore.getInstance(type, provider);
        }

        InputStream is = new ByteArrayInputStream(data);
        try {
            ks.load(is, password);
        } finally {
            try {
                is.close();
            } catch (IOException ignored) {
                // Do nothing
            }
        }

        return ks;
    }
1263030
public static SpanContext fromCloudTraceContext(CloudTraceContext cloudTraceContext) {
    checkNotNull(cloudTraceContext, "cloudTraceContext");

    try {
      // Extract the trace ID from the binary protobuf CloudTraceContext#traceId.
      TraceIdProto traceIdProto = TraceIdProto.parseFrom(cloudTraceContext.getTraceId());
      ByteBuffer traceIdBuf = ByteBuffer.allocate(TraceId.SIZE);
      traceIdBuf.putLong(traceIdProto.getHi());
      traceIdBuf.putLong(traceIdProto.getLo());
      ByteBuffer spanIdBuf = ByteBuffer.allocate(SpanId.SIZE);
      spanIdBuf.putLong(cloudTraceContext.getSpanId());

      return SpanContext.create(
          TraceId.fromBytes(traceIdBuf.array()),
          SpanId.fromBytes(spanIdBuf.array()),
          TraceOptions.builder().setIsSampled(cloudTraceContext.isTraceEnabled()).build(),
          TRACESTATE_DEFAULT);
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw new RuntimeException(e);
    }
  }
184178
@Bean Tracing tracing(
      @Lazy Reporter<Span> reporter, @Value("${zipkin.self-tracing.sample-rate:1.0}") float rate) {
    return Tracing.newBuilder()
        .localServiceName("zipkin-server")
        .sampler(rate < 0.01 ? BoundarySampler.create(rate) : Sampler.create(rate))
        .currentTraceContext(currentTraceContext())
        .spanReporter(reporter)
        .build();
  }
887059
private org.javasimon.jmx.StopwatchSample sampleStopwatch(Simon s) {
		return new StopwatchSample((org.javasimon.StopwatchSample) s.sample());
	}
1083964
public MobicentsSipApplicationSession createApplicationSession(SipContext sipContext) {
		if (logger.isDebugEnabled()) {
			logger.debug("Creating new application session for sip context "+ sipContext.getApplicationName());
		}
		//call id not needed anymore since the sipappsessionkey is not a callid anymore but a random uuid
		SipApplicationSessionKey sipApplicationSessionKey = SessionManagerUtil.getSipApplicationSessionKey(
				sipContext.getApplicationName(), 
				null,
				null);		
		MobicentsSipApplicationSession sipApplicationSession = sipContext.getSipManager().getSipApplicationSession(
				sipApplicationSessionKey, true);
		
		if(StaticServiceHolder.sipStandardService.isHttpFollowsSip()) {
			String jvmRoute = StaticServiceHolder.sipStandardService.getJvmRoute();
			if(jvmRoute != null) {
				sipApplicationSession.setJvmRoute(jvmRoute);
			}
		}
			
		return sipApplicationSession.getFacade();
	}
1011714
Session createSession(final DatabaseId db) throws SpannerException {
    final Map<SpannerRpc.Option, ?> options =
        optionMap(SessionOption.channelHint(random.nextLong()));
    Span span = tracer.spanBuilder(CREATE_SESSION).startSpan();
    try (Scope s = tracer.withSpan(span)) {
      com.google.spanner.v1.Session session =
          runWithRetries(
              new Callable<com.google.spanner.v1.Session>() {
                @Override
                public com.google.spanner.v1.Session call() throws Exception {
                  return gapicRpc.createSession(
                      db.getName(), getOptions().getSessionLabels(), options);
                }
              });
      span.end();
      return new SessionImpl(this, session.getName(), options);
    } catch (RuntimeException e) {
      TraceUtil.endSpanWithFailure(span, e);
      throw e;
    }
  }
655856
@Override
    public java.util.concurrent.Future<DescribeReservedInstancesListingsResult> describeReservedInstancesListingsAsync(
            com.amazonaws.handlers.AsyncHandler<DescribeReservedInstancesListingsRequest, DescribeReservedInstancesListingsResult> asyncHandler) {

        return describeReservedInstancesListingsAsync(new DescribeReservedInstancesListingsRequest(), asyncHandler);
    }
185840
public static Function<Service<HttpRequest, HttpResponse>, HttpTracingService>
    newDecorator(Tracing tracing) {
        ensureScopeUsesRequestContext(tracing);
        return service -> new HttpTracingService(service, tracing);
    }
276667
public static GenericResponseBuilderFactory newInstance() {
    ServiceLoader<GenericResponseBuilderFactory> clientBuilderFactoryLoader =
        ServiceLoader.load(GenericResponseBuilderFactory.class);

    Iterator<GenericResponseBuilderFactory> iterator = clientBuilderFactoryLoader.iterator();

    if (!iterator.hasNext()) {
      throw new IllegalStateException(
          "An implementation of GenericResponseBuilderFactory was not found");
    }

    return iterator.next();
  }
601384
@Override
  public Runnable wrap(Runnable runnable) {
    if (isTracing()) {
      return new SpanContinuingTraceRunnable(this, this.traceKeys, this.spanNamer, runnable);
    }
    return runnable;
  }
1001624
public void _doInclude(PageSource[] sources, boolean runOnce, Object cachedWithin) throws PageException {
	if (cachedWithin == null) {
	    _doInclude(sources, runOnce);
	    return;
	}

	// ignore call when runonce an it is not first call
	if (runOnce) {
	    Page currentPage = PageSourceImpl.loadPage(this, sources);
	    if (runOnce && includeOnce.contains(currentPage.getPageSource())) return;
	}

	// get cached data
	String cacheId = CacheHandlerCollectionImpl.createId(sources);
	CacheHandler cacheHandler = config.getCacheHandlerCollection(Config.CACHE_TYPE_INCLUDE, null).getInstanceMatchingObject(cachedWithin, null);

	if (cacheHandler instanceof CacheHandlerPro) {

	    CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(this, cacheId, cachedWithin);

	    if (cacheItem instanceof IncludeCacheItem) {
		try {
		    write(((IncludeCacheItem) cacheItem).getOutput());
		    return;
		}
		catch (IOException e) {
		    throw Caster.toPageException(e);
		}
	    }
	}
	else if (cacheHandler != null) { // TODO this else block can be removed when all cache handlers implement CacheHandlerPro

	    CacheItem cacheItem = cacheHandler.get(this, cacheId);

	    if (cacheItem instanceof IncludeCacheItem) {
		try {
		    write(((IncludeCacheItem) cacheItem).getOutput());
		    return;
		}
		catch (IOException e) {
		    throw Caster.toPageException(e);
		}
	    }
	}

	// cached item not found, process and cache result if needed
	long start = System.nanoTime();
	BodyContent bc = pushBody();

	try {
	    _doInclude(sources, runOnce);
	    String out = bc.getString();

	    if (cacheHandler != null) {
		CacheItem cacheItem = new IncludeCacheItem(out, ArrayUtil.isEmpty(sources) ? null : sources[0], System.nanoTime() - start);
		cacheHandler.set(this, cacheId, cachedWithin, cacheItem);
		return;
	    }
	}
	finally {
	    BodyContentUtil.flushAndPop(this, bc);
	}
    }
1222829
@Override
	public CompletableFuture<StackTraceSampleResponse> requestStackTraceSample(
			final ExecutionAttemptID executionAttemptId,
			final int sampleId,
			final int numSamples,
			final Time delayBetweenSamples,
			final int maxStackTraceDepth,
			final Time timeout) {

		final Task task = taskSlotTable.getTask(executionAttemptId);
		if (task == null) {
			return FutureUtils.completedExceptionally(
				new IllegalStateException(String.format("Cannot sample task %s. " +
					"Task is not known to the task manager.", executionAttemptId)));
		}

		final CompletableFuture<List<StackTraceElement[]>> stackTracesFuture = stackTraceSampleService.requestStackTraceSample(
			TaskStackTraceSampleableTaskAdapter.fromTask(task),
			numSamples,
			delayBetweenSamples,
			maxStackTraceDepth);

		return stackTracesFuture.thenApply(stackTraces ->
			new StackTraceSampleResponse(sampleId, executionAttemptId, stackTraces));
	}
123192
public static void ensureScopeUsesRequestContext(Tracing tracing) {
        final PingPongExtra extra = new PingPongExtra();
        // trace contexts are not recorded until Tracer.toSpan, so this won't end up as junk data
        final TraceContext dummyContext = TraceContext.newBuilder().traceId(1).spanId(1)
                                                      .extra(Collections.singletonList(extra)).build();
        final boolean scopeUsesRequestContext;
        try (Scope scope = tracing.currentTraceContext().newScope(dummyContext)) {
            scopeUsesRequestContext = extra.isPong();
        }
        if (!scopeUsesRequestContext) {
            throw new IllegalStateException(
                    "Tracing.currentTraceContext is not a " + RequestContextCurrentTraceContext.class
                            .getSimpleName() + " scope. " +
                    "Please call Tracing.Builder.currentTraceContext(" + RequestContextCurrentTraceContext.class
                            .getSimpleName() + ".INSTANCE).");
        }
    }