Class MockSpan

java.lang.Object
org.opensearch.telemetry.tracing.AbstractSpan
org.opensearch.test.telemetry.tracing.MockSpan
All Implemented Interfaces:
org.opensearch.telemetry.tracing.Span

public class MockSpan extends org.opensearch.telemetry.tracing.AbstractSpan
MockSpan for testing and strict check validations. Not to be used for production cases.
  • Constructor Details

    • MockSpan

      public MockSpan(org.opensearch.telemetry.tracing.SpanCreationContext spanCreationContext, org.opensearch.telemetry.tracing.Span parentSpan, SpanProcessor spanProcessor)
      Base Constructor.
      Parameters:
      spanCreationContext - Span Creation context.
      parentSpan - Parent Span
      spanProcessor - Span Processor
    • MockSpan

      public MockSpan(String spanName, org.opensearch.telemetry.tracing.Span parentSpan, String traceId, String spanId, SpanProcessor spanProcessor, org.opensearch.telemetry.tracing.attributes.Attributes attributes, org.opensearch.telemetry.tracing.SpanKind spanKind)
      Constructor with traceId and SpanIds
      Parameters:
      spanName - Span Name
      parentSpan - Parent Span
      traceId - Trace ID
      spanId - Span ID
      spanProcessor - Span Processor
      attributes - attributes
      spanKind - type of span.
  • Method Details

    • endSpan

      public void endSpan()
    • addAttribute

      public void addAttribute(String key, String value)
    • addAttribute

      public void addAttribute(String key, Long value)
    • addAttribute

      public void addAttribute(String key, Double value)
    • addAttribute

      public void addAttribute(String key, Boolean value)
    • addEvent

      public void addEvent(String event)
    • getTraceId

      public String getTraceId()
    • getSpanId

      public String getSpanId()
    • hasEnded

      public boolean hasEnded()
      Returns whether the span is ended or not.
      Returns:
      span end status.
    • getStartTime

      public Long getStartTime()
      Returns the start time of the span.
      Returns:
      start time of the span.
    • getEndTime

      public Long getEndTime()
      Returns the start time of the span.
      Returns:
      end time of the span.
    • setError

      public void setError(Exception exception)
    • getAttribute

      public Object getAttribute(String key)
      Returns attribute.
      Parameters:
      key - key
      Returns:
      value
    • getAttributes

      public Map<String,Object> getAttributes()
      Returns the attributes as map.
      Returns:
      returns the attributes map.