Refine search
/** Transaction functions that returns its result in the provided SettableFuture. */ private <T> void runTransaction( final Transaction.Function<T> transactionCallback, final SettableApiFuture<T> resultFuture, final TransactionOptions options) { // span is intentionally not ended here. It will be ended by runTransactionAttempt on success // or error. Span span = tracer.spanBuilder("CloudFirestore.Transaction").startSpan(); try (Scope s = tracer.withSpan(span)) { runTransactionAttempt(transactionCallback, resultFuture, options, span); } }
/** Helper method to start a span. */ private Span startSpan(String spanName) { return tracer .spanBuilder(spanName) .setRecordEvents(censusHttpModule.isRecordEvents()) .startSpan(); }
void tick() { try (Scope ss = tracer.spanBuilder("Styx.Scheduler.tick") .setRecordEvents(true) .setSampler(Samplers.alwaysSample()) .startScopedSpan()) { tick0(); } }
@Override public void export(Collection<SpanData> spanDataList) { // Start a new span with explicit 1/10000 sampling probability to avoid the case when user // sets the default sampler to always sample and we get the gRPC span of the stackdriver // export call always sampled and go to an infinite loop. io.opencensus.trace.Span span = tracer .spanBuilder(EXPORT_STACKDRIVER_TRACES) .setSampler(probabilitySampler) .setRecordEvents(true) .startSpan(); Scope scope = tracer.withSpan(span); try { List<Span> spans = new ArrayList<>(spanDataList.size()); for (SpanData spanData : spanDataList) { spans.add(generateSpan(spanData, RESOURCE_LABELS, fixedAttributes)); } // Sync call because it is already called for a batch of data, and on a separate thread. // TODO(bdrutu): Consider to make this async in the future. traceServiceClient.batchWriteSpans(projectName, spans); } finally { scope.close(); span.end(END_SPAN_OPTIONS); } } }
/** {@inheritDoc} */ @Override public HTableDescriptor getTableDescriptor() throws IOException { try ( Scope scope = TRACER.spanBuilder("BigtableTable.getTableDescriptor").startScopedSpan(); Admin admin = this.bigtableConnection.getAdmin()) { return admin.getTableDescriptor(tableName); } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final String operation = method.getName(); final SpanBuilder spanBuilder = tracer.spanBuilder(delegateName + "." + operation); try (Scope ss = spanBuilder.startScopedSpan()) { try { return method.invoke(delegate, args); } catch (InvocationTargetException e) { tracer.getCurrentSpan().addAnnotation("Exception thrown"); tracer.getCurrentSpan().setStatus(Status.UNKNOWN); throw e.getTargetException(); } } } }
ClientCallTracer(@Nullable Span parentSpan, MethodDescriptor<?, ?> method) { checkNotNull(method, "method"); this.isSampledToLocalTracing = method.isSampledToLocalTracing(); this.span = censusTracer .spanBuilderWithExplicitParent( generateTraceSpanName(false, method.getFullMethodName()), parentSpan) .setRecordEvents(true) .startSpan(); }
@Test public void doNotCrash_NoopImplementation() throws Exception { SpanBuilder spanBuilder = tracer.spanBuilder("MySpanName"); spanBuilder.setParentLinks(Collections.<Span>emptyList()); spanBuilder.setRecordEvents(true); spanBuilder.setSampler(Samplers.alwaysSample()); spanBuilder.setSpanKind(Kind.SERVER); assertThat(spanBuilder.startSpan()).isSameAs(BlankSpan.INSTANCE); } }
Span opSpan = tracer.spanBuilderWithExplicitParent(COMMIT, span).startSpan(); try (Scope s = tracer.withSpan(opSpan)) { CommitResponse commitResponse = runWithRetries(
@Override public final void handle(HttpExchange httpExchange) throws IOException { Span span = tracer .spanBuilderWithExplicitParent(httpServerSpanName, null) .setRecordEvents(true) .startSpan(); try (Scope ss = tracer.withSpan(span)) { span.putAttribute( "/http/method ", AttributeValue.stringAttributeValue(httpExchange.getRequestMethod())); httpExchange.sendResponseHeaders(200, 0); zpageHandler.emitHtml( uriQueryToMap(httpExchange.getRequestURI()), httpExchange.getResponseBody()); } finally { httpExchange.close(); span.end(END_SPAN_OPTIONS); } }
protected ResumableStreamIterator(int maxBufferSize, String streamName, Span parent) { checkArgument(maxBufferSize >= 0); this.maxBufferSize = maxBufferSize; this.span = tracer.spanBuilderWithExplicitParent(streamName, parent).startSpan(); }
ServerTracer(String fullMethodName, @Nullable SpanContext remoteSpan) { checkNotNull(fullMethodName, "fullMethodName"); this.span = censusTracer .spanBuilderWithRemoteParent( generateTraceSpanName(true, fullMethodName), remoteSpan) .setRecordEvents(true) .startSpan(); }
@MustBeClosed private static Scope newExportScope() { // Start a new span with explicit sampler (with low probability) to avoid the case when user // sets the default sampler to always sample and we get the Thrift span of the Jaeger // export call always sampled and go to an infinite loop. return tracer.spanBuilder(EXPORT_SPAN_NAME).setSampler(lowProbabilitySampler).startScopedSpan(); }
@Test public void defaultSpanBuilderWithName() { assertThat(noopTracer.spanBuilder(SPAN_NAME).startSpan()).isSameAs(BlankSpan.INSTANCE); }
.spanBuilderWithExplicitParent(SAMPLE_SPAN, null) .setSampler(Samplers.alwaysSample()) .startScopedSpan()) { ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"));
@Test public void defaultSpanBuilderWithRemoteParent() { assertThat(noopTracer.spanBuilderWithRemoteParent(SPAN_NAME, SpanContext.INVALID).startSpan()) .isSameAs(BlankSpan.INSTANCE); }
@Test public void startScopedSpan() { assertThat(tracer.getCurrentSpan()).isSameAs(BlankSpan.INSTANCE); Scope scope = spanBuilder.startScopedSpan(); try { assertThat(tracer.getCurrentSpan()).isSameAs(span); } finally { scope.close(); } verify(span).end(EndSpanOptions.DEFAULT); assertThat(tracer.getCurrentSpan()).isSameAs(BlankSpan.INSTANCE); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); when(spanBuilder.startSpan()).thenReturn(span); }
void tick() { try (Scope ss = tracer.spanBuilder("Styx.BackfillTriggerManager.tick") .setRecordEvents(true) .setSampler(Samplers.alwaysSample()) .startScopedSpan()) { tick0(); } }
@Override public void export(Collection<SpanData> spanDataList) { // Start a new span with explicit 1/10000 sampling probability to avoid the case when user // sets the default sampler to always sample and we get the gRPC span of the stackdriver // export call always sampled and go to an infinite loop. io.opencensus.trace.Span span = tracer .spanBuilder(EXPORT_STACKDRIVER_TRACES) .setSampler(probabilitySampler) .setRecordEvents(true) .startSpan(); Scope scope = tracer.withSpan(span); try { List<Span> spans = new ArrayList<>(spanDataList.size()); for (SpanData spanData : spanDataList) { spans.add(generateSpan(spanData, RESOURCE_LABELS, fixedAttributes)); } // Sync call because it is already called for a batch of data, and on a separate thread. // TODO(bdrutu): Consider to make this async in the future. traceServiceClient.batchWriteSpans(projectName, spans); } finally { scope.close(); span.end(END_SPAN_OPTIONS); } } }