Class StartSpanOptions

java.lang.Object
com.azure.core.util.tracing.StartSpanOptions

public final class StartSpanOptions extends Object
Represents span options that are available before span starts and describe it.
  • Constructor Details

    • StartSpanOptions

      public StartSpanOptions(SpanKind kind)
      Create start options with given kind
      Parameters:
      kind - The kind of the span to be created.
  • Method Details

    • setAttribute

      public StartSpanOptions setAttribute(String key, Object value)
      Sets attribute on span before its started. Such attributes may affect sampling decision. Adding duplicate attributes, update, or removal is discouraged, since underlying implementations behavior can vary.
      Parameters:
      key - attribute key.
      value - attribute value. Note that underlying tracer implementations limit supported value types. OpenTelemetry implementation supports following types:
      • String
      • int
      • double
      • boolean
      • long
      • Arrays of the above
      Returns:
      this instance for chaining.
    • setStartTimestamp

      public StartSpanOptions setStartTimestamp(Instant timestamp)
      Sets span start timestamp. This is optional and used to record past spans. If not set, uses current time.
      Parameters:
      timestamp - span start time.
      Returns:
      this instance for chaining.
    • getStartTimestamp

      public Instant getStartTimestamp()
      Gets span start time.
      Returns:
      start timestamp.
    • setRemoteParent

      public StartSpanOptions setRemoteParent(Context parent)
      Sets remote parent context.
      Parameters:
      parent - context with remote span context.
      Returns:
      this instance for chaining.
    • getRemoteParent

      public Context getRemoteParent()
      Gets remote parent.
      Returns:
      context with remote parent span context on it.
    • addLink

      public StartSpanOptions addLink(TracingLink link)
      Add link to span.
      Parameters:
      link - link.
      Returns:
      this instance for chaining.
    • getSpanKind

      public SpanKind getSpanKind()
      Gets span kind.
      Returns:
      span kind.
    • getAttributes

      public Map<String,Object> getAttributes()
      Gets all attributes on span that should be set before span is started.
      Returns:
      attributes to be set on span and used for sampling.
    • getLinks

      public List<TracingLink> getLinks()
      Gets links to be set on span.
      Returns:
      list of links.