Class SpanBuilder.NoopSpanBuilder

java.lang.Object
io.opencensus.trace.SpanBuilder
io.opencensus.trace.SpanBuilder.NoopSpanBuilder
Enclosing class:
SpanBuilder

static final class SpanBuilder.NoopSpanBuilder extends SpanBuilder
  • Constructor Details

    • NoopSpanBuilder

      private NoopSpanBuilder(String name)
  • Method Details

    • createWithParent

      static SpanBuilder.NoopSpanBuilder createWithParent(String spanName, @Nullable Span parent)
    • createWithRemoteParent

      static SpanBuilder.NoopSpanBuilder createWithRemoteParent(String spanName, @Nullable SpanContext remoteParentSpanContext)
    • startSpan

      public Span startSpan()
      Description copied from class: SpanBuilder
      Starts a new Span.

      Users must manually call Span.end() or Span.end(EndSpanOptions) to end this Span.

      Does not install the newly created Span to the current Context.

      Example of usage:

      
       class MyClass {
         private static final Tracer tracer = Tracing.getTracer();
         void DoWork(Span parent) {
           Span childSpan = tracer.spanBuilderWithExplicitParent("MyChildSpan", parent).startSpan();
           childSpan.addAnnotation("my annotation");
           try {
             doSomeWork(childSpan); // Manually propagate the new span down the stack.
           } finally {
             // To make sure we end the span even in case of an exception.
             childSpan.end();  // Manually end the span.
           }
         }
       }
       
      Specified by:
      startSpan in class SpanBuilder
      Returns:
      the newly created Span.
    • setSampler

      public SpanBuilder setSampler(@Nullable Sampler sampler)
      Description copied from class: SpanBuilder
      Sets the Sampler to use. If not set, the implementation will provide a default.
      Specified by:
      setSampler in class SpanBuilder
      Parameters:
      sampler - the Sampler to use when determining sampling for a Span.
      Returns:
      this.
    • setParentLinks

      public SpanBuilder setParentLinks(List<Span> parentLinks)
      Description copied from class: SpanBuilder
      Sets the List of parent links. Links are used to link Spans in different traces. Used (for example) in batching operations, where a single batch handler processes multiple requests from different traces.
      Specified by:
      setParentLinks in class SpanBuilder
      Parameters:
      parentLinks - new links to be added.
      Returns:
      this.
    • setRecordEvents

      public SpanBuilder setRecordEvents(boolean recordEvents)
      Description copied from class: SpanBuilder
      Sets the option Span.Options.RECORD_EVENTS for the newly created Span. If not called, the implementation will provide a default.
      Specified by:
      setRecordEvents in class SpanBuilder
      Parameters:
      recordEvents - new value determining if this Span should have events recorded.
      Returns:
      this.
    • setSpanKind

      public SpanBuilder setSpanKind(@Nullable Span.Kind spanKind)
      Description copied from class: SpanBuilder
      Sets the Span.Kind for the newly created Span. If not called, the implementation will provide a default.
      Overrides:
      setSpanKind in class SpanBuilder
      Parameters:
      spanKind - the kind of the newly created Span.
      Returns:
      this.