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 Summary
ConstructorsConstructorDescriptionMockSpan(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 SpanIdsMockSpan(org.opensearch.telemetry.tracing.SpanCreationContext spanCreationContext, org.opensearch.telemetry.tracing.Span parentSpan, SpanProcessor spanProcessor) Base Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String key, Boolean value) voidaddAttribute(String key, Double value) voidaddAttribute(String key, Long value) voidaddAttribute(String key, String value) voidvoidendSpan()getAttribute(String key) Returns attribute.Returns the attributes as map.Returns the start time of the span.Returns the start time of the span.booleanhasEnded()Returns whether the span is ended or not.voidMethods inherited from class org.opensearch.telemetry.tracing.AbstractSpan
getParentSpan, getSpanName
-
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 SpanspanProcessor- 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 NameparentSpan- Parent SpantraceId- Trace IDspanId- Span IDspanProcessor- Span Processorattributes- attributesspanKind- type of span.
-
-
Method Details
-
endSpan
public void endSpan() -
addAttribute
-
addAttribute
-
addAttribute
-
addAttribute
-
addEvent
-
getTraceId
-
getSpanId
-
hasEnded
public boolean hasEnded()Returns whether the span is ended or not.- Returns:
- span end status.
-
getStartTime
-
getEndTime
-
setError
-
getAttribute
-
getAttributes
-