Tabnine Logo
Tracer.spanBuilderWithExplicitParent
Code IndexAdd Tabnine to your IDE (free)

How to use
spanBuilderWithExplicitParent
method
in
io.opencensus.trace.Tracer

Best Java code snippets using io.opencensus.trace.Tracer.spanBuilderWithExplicitParent (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

protected ResumableStreamIterator(int maxBufferSize, String streamName, Span parent) {
 checkArgument(maxBufferSize >= 0);
 this.maxBufferSize = maxBufferSize;
 this.span = tracer.spanBuilderWithExplicitParent(streamName, parent).startSpan();
}
origin: googleapis/google-cloud-java

Span opSpan = tracer.spanBuilderWithExplicitParent(COMMIT, span).startSpan();
try (Scope s = tracer.withSpan(opSpan)) {
 CommitResponse commitResponse =
origin: GoogleCloudPlatform/java-docs-samples

.spanBuilderWithExplicitParent(SAMPLE_SPAN, null)
.setSampler(Samplers.alwaysSample())
.startScopedSpan()) {
origin: com.google.cloud/google-cloud-spanner

protected ResumableStreamIterator(int maxBufferSize, String streamName, Span parent) {
 checkArgument(maxBufferSize >= 0);
 this.maxBufferSize = maxBufferSize;
 this.span = tracer.spanBuilderWithExplicitParent(streamName, parent).startSpan();
}
origin: census-instrumentation/opencensus-java

/**
 * Returns a {@link SpanBuilder} to create and start a new child {@link Span} as a child of to the
 * current {@code Span} if any, otherwise creates a root {@code Span}.
 *
 * <p>See {@link SpanBuilder} for usage examples.
 *
 * <p>This <b>must</b> be used to create a {@code Span} when automatic Context propagation is
 * used.
 *
 * <p>This is equivalent with:
 *
 * <pre>{@code
 * tracer.spanBuilderWithExplicitParent("MySpanName",tracer.getCurrentSpan());
 * }</pre>
 *
 * @param spanName The name of the returned Span.
 * @return a {@code SpanBuilder} to create and start a new {@code Span}.
 * @throws NullPointerException if {@code spanName} is {@code null}.
 * @since 0.5
 */
public final SpanBuilder spanBuilder(String spanName) {
 return spanBuilderWithExplicitParent(spanName, CurrentSpanUtils.getCurrentSpan());
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Returns a {@link SpanBuilder} to create and start a new child {@link Span} as a child of to the
 * current {@code Span} if any, otherwise creates a root {@code Span}.
 *
 * <p>See {@link SpanBuilder} for usage examples.
 *
 * <p>This <b>must</b> be used to create a {@code Span} when automatic Context propagation is
 * used.
 *
 * <p>This is equivalent with:
 *
 * <pre>{@code
 * tracer.spanBuilderWithExplicitParent("MySpanName",tracer.getCurrentSpan());
 * }</pre>
 *
 * @param spanName The name of the returned Span.
 * @return a {@code SpanBuilder} to create and start a new {@code Span}.
 * @throws NullPointerException if {@code spanName} is {@code null}.
 */
public final SpanBuilder spanBuilder(String spanName) {
 return spanBuilderWithExplicitParent(spanName, CurrentSpanUtils.getCurrentSpan());
}
origin: io.grpc/grpc-core

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();
}
origin: census-instrumentation/opencensus-java

@Test(expected = NullPointerException.class)
public void spanBuilderWithParentAndName_NullName() {
 noopTracer.spanBuilderWithExplicitParent(null, null);
}
origin: census-instrumentation/opencensus-java

@Before
public void setUp() {
 MockitoAnnotations.initMocks(this);
 handler =
   new HttpClientHandler<Object, Object, Object>(
     tracer, extractor, textFormat, textFormatSetter);
 when(tracer.spanBuilderWithExplicitParent(any(String.class), same(parentSpan)))
   .thenReturn(spanBuilder);
 when(spanBuilder.startSpan()).thenReturn(childSpan);
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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();
}
origin: census-instrumentation/opencensus-java

@Test
public void handleStartCreateChildSpanInSpecifiedContext() {
 // without scope
 HttpRequestContext context = handler.handleStart(parentSpan, carrier, request);
 verify(tracer).spanBuilderWithExplicitParent(any(String.class), same(parentSpan));
 assertThat(context.span).isEqualTo(childSpan);
}
origin: com.google.api/gax

@Override
public ApiTracer newRootTracer(SpanName spanName) {
 if (clientNameOverride != null) {
  spanName = spanName.withClientName(clientNameOverride);
 }
 Span span =
   internalTracer
     .spanBuilderWithExplicitParent(spanName.toString(), BlankSpan.INSTANCE)
     .setRecordEvents(true)
     .startSpan();
 return new OpencensusTracer(internalTracer, span);
}
origin: census-instrumentation/opencensus-java

@Test
public void defaultSpanBuilderWithParentAndName() {
 assertThat(noopTracer.spanBuilderWithExplicitParent(SPAN_NAME, null).startSpan())
   .isSameAs(BlankSpan.INSTANCE);
}
origin: census-instrumentation/opencensus-java

@Test
public void handleStartShouldIgnoreContextParseException() throws Exception {
 when(textFormat.extract(same(carrier), same(textFormatGetter)))
   .thenThrow(new SpanContextParseException("test"));
 HttpRequestContext context = handler.handleStart(carrier, request);
 verify(tracer).spanBuilderWithExplicitParent(any(String.class), any(Span.class));
 assertThat(context.span).isEqualTo(spanWithLocalParent);
}
origin: census-instrumentation/opencensus-java

@Before
public void setUp() throws SpanContextParseException {
 MockitoAnnotations.initMocks(this);
 handler =
   new HttpServerHandler<Object, Object, Object>(
     tracer, extractor, textFormat, textFormatGetter, false);
 handlerForPublicEndpoint =
   new HttpServerHandler<Object, Object, Object>(
     tracer, extractor, textFormat, textFormatGetter, true);
 when(tracer.spanBuilderWithRemoteParent(any(String.class), same(spanContextRemote)))
   .thenReturn(spanBuilderWithRemoteParent);
 when(tracer.spanBuilderWithExplicitParent(any(String.class), any(Span.class)))
   .thenReturn(spanBuilderWithLocalParent);
 when(spanBuilderWithRemoteParent.startSpan()).thenReturn(spanWithRemoteParent);
 when(spanBuilderWithLocalParent.startSpan()).thenReturn(spanWithLocalParent);
 when(textFormat.extract(same(carrier), same(textFormatGetter))).thenReturn(spanContextRemote);
}
origin: census-instrumentation/opencensus-java

@Test
public void handleStartWithPublicEndpointShouldAddLink() throws Exception {
 handlerForPublicEndpoint.handleStart(carrier, request);
 verify(tracer).spanBuilderWithExplicitParent(any(String.class), any(Span.class));
 verify(spanWithLocalParent).addLink(captor.capture());
 Link link = captor.getValue();
 assertThat(link.getSpanId()).isEqualTo(spanContextRemote.getSpanId());
 assertThat(link.getTraceId()).isEqualTo(spanContextRemote.getTraceId());
 assertThat(link.getType()).isEqualTo(Type.PARENT_LINKED_SPAN);
}
origin: census-instrumentation/opencensus-java

@Test
public void handleStartShouldCreateChildSpanInCurrentContext() {
 Scope scope = tracer.withSpan(parentSpan);
 try {
  HttpRequestContext context = handler.handleStart(null, carrier, request);
  verify(tracer).spanBuilderWithExplicitParent(any(String.class), same(parentSpan));
  assertThat(context.span).isEqualTo(childSpan);
 } finally {
  scope.close();
 }
}
origin: census-instrumentation/opencensus-java

@Test
public void startSpanWithParentFromContext() {
 Scope ws = tracer.withSpan(span);
 try {
  assertThat(tracer.getCurrentSpan()).isSameAs(span);
  when(tracer.spanBuilderWithExplicitParent(same(SPAN_NAME), same(span)))
    .thenReturn(spanBuilder);
  assertThat(tracer.spanBuilder(SPAN_NAME)).isSameAs(spanBuilder);
 } finally {
  ws.close();
 }
}
origin: census-instrumentation/opencensus-java

 @Test
 public void startSpanWithInvalidParentFromContext() {
  Scope ws = tracer.withSpan(BlankSpan.INSTANCE);
  try {
   assertThat(tracer.getCurrentSpan()).isSameAs(BlankSpan.INSTANCE);
   when(tracer.spanBuilderWithExplicitParent(same(SPAN_NAME), same(BlankSpan.INSTANCE)))
     .thenReturn(spanBuilder);
   assertThat(tracer.spanBuilder(SPAN_NAME)).isSameAs(spanBuilder);
  } finally {
   ws.close();
  }
 }
}
origin: census-instrumentation/opencensus-java

@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);
 }
}
io.opencensus.traceTracerspanBuilderWithExplicitParent

Javadoc

Returns a SpanBuilder to create and start a new child Span (or root if parent is null or has an invalid SpanContext), with parent being the designated Span.

See SpanBuilder for usage examples.

This must be used to create a Span when manual Context propagation is used OR when creating a root Span with a null parent.

Popular methods of Tracer

  • spanBuilder
    Returns a SpanBuilder to create and start a new child Span as a child of to the current Span if any,
  • getCurrentSpan
    Gets the current Span from the current Context.To install a Span to the current Context use #withSpa
  • withSpan
    Returns a Callable that runs the given task with the given Span in the current context.Users may con
  • spanBuilderWithRemoteParent
    Returns a SpanBuilder to create and start a new child Span (or root if parent is SpanContext#INVALID
  • getNoopTracer
    Returns the no-op implementation of the Tracer.

Popular in Java

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • getExternalFilesDir (Context)
  • getSystemService (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now