Codota Logo
Tracer.spanBuilderWithExplicitParent
Code IndexAdd Codota 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)

  • Common ways to obtain Tracer
private void myMethod () {
Tracer t =
  • Codota IconTracing.getTracer()
  • Codota IconTraceComponentImplBase traceComponentImplBase;traceComponentImplBase.getTracer()
  • Smart code suggestions by Codota
}
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

  • Finding current android device location
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • notifyDataSetChanged (ArrayAdapter)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now