Class SpanDataAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<SpanDataAssert,io.opentelemetry.sdk.trace.data.SpanData>
io.opentelemetry.sdk.testing.assertj.SpanDataAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<SpanDataAssert,io.opentelemetry.sdk.trace.data.SpanData>, org.assertj.core.api.Descriptable<SpanDataAssert>, org.assertj.core.api.ExtensionPoints<SpanDataAssert,io.opentelemetry.sdk.trace.data.SpanData>

public final class SpanDataAssert extends org.assertj.core.api.AbstractAssert<SpanDataAssert,io.opentelemetry.sdk.trace.data.SpanData>
Assertions for an exported SpanData.
  • Method Details

    • hasTraceId

      public SpanDataAssert hasTraceId(String traceId)
      Asserts the span has the given trace ID.
    • hasSpanId

      public SpanDataAssert hasSpanId(String spanId)
      Asserts the span has the given span ID.
    • isSampled

      public SpanDataAssert isSampled()
      Asserts the span is sampled.
    • isNotSampled

      public SpanDataAssert isNotSampled()
      Asserts the span is not sampled.
    • hasTraceState

      public SpanDataAssert hasTraceState(io.opentelemetry.api.trace.TraceState traceState)
      Asserts the span has the given TraceState.
    • hasParentSpanId

      public SpanDataAssert hasParentSpanId(String parentSpanId)
      Asserts the span has the given parent span ID.
    • hasParent

      public SpanDataAssert hasParent(io.opentelemetry.sdk.trace.data.SpanData parent)
      Asserts the span has the given parent span.

      Equivalent to span.hasParentSpanId(parent.getSpanId()).

    • hasNoParent

      public SpanDataAssert hasNoParent()
      Asserts the span has no parent span.

      Equivalent to span.hasParentSpanId(SpanId.getInvalid()).

    • hasResource

      public SpanDataAssert hasResource(io.opentelemetry.sdk.resources.Resource resource)
      Asserts the span has the given Resource.
    • hasResourceSatisfying

      public SpanDataAssert hasResourceSatisfying(Consumer<ResourceAssert> resource)
      Asserts the span has a resource satisfying the given condition.
      Since:
      1.23.0
    • hasInstrumentationLibraryInfo

      @Deprecated public SpanDataAssert hasInstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo instrumentationLibraryInfo)
      Asserts the span has the given InstrumentationLibraryInfo.
    • hasInstrumentationScopeInfo

      public SpanDataAssert hasInstrumentationScopeInfo(io.opentelemetry.sdk.common.InstrumentationScopeInfo instrumentationScopeInfo)
      Asserts the span has the given InstrumentationScopeInfo.
    • hasName

      public SpanDataAssert hasName(String name)
      Asserts the span has the given name.
    • hasKind

      public SpanDataAssert hasKind(io.opentelemetry.api.trace.SpanKind kind)
      Asserts the span has the given kind.
    • startsAt

      public SpanDataAssert startsAt(long startEpochNanos)
      Asserts the span starts at the given epoch timestamp, in nanos.
    • startsAt

      public SpanDataAssert startsAt(long startEpoch, TimeUnit unit)
      Asserts the span starts at the given epoch timestamp.
    • startsAt

      public SpanDataAssert startsAt(Instant timestamp)
      Asserts the span starts at the given epoch timestamp.
    • hasAttribute

      public <T> SpanDataAssert hasAttribute(io.opentelemetry.api.common.AttributeKey<T> key, T value)
      Asserts the span has the given attribute.
    • hasAttribute

      public SpanDataAssert hasAttribute(AttributeAssertion attributeAssertion)
      Asserts the span has an attribute matching the attributeAssertion.
    • hasAttributes

      public SpanDataAssert hasAttributes(io.opentelemetry.api.common.Attributes attributes)
      Asserts the span has the given attributes.
    • hasAttributes

      @SafeVarargs public final SpanDataAssert hasAttributes(Map.Entry<? extends io.opentelemetry.api.common.AttributeKey<?>,?>... entries)
      Asserts the span has the given attributes.
    • hasAttributesSatisfying

      public SpanDataAssert hasAttributesSatisfying(Consumer<io.opentelemetry.api.common.Attributes> attributes)
      Asserts the span has attributes satisfying the given condition.
    • hasAttributesSatisfying

      public SpanDataAssert hasAttributesSatisfying(AttributeAssertion... assertions)
      Asserts the event has attributes matching all assertions. Assertions can be created using methods like OpenTelemetryAssertions.satisfies(AttributeKey, OpenTelemetryAssertions.LongAssertConsumer).
      Since:
      1.21.0
    • hasAttributesSatisfying

      public SpanDataAssert hasAttributesSatisfying(Iterable<AttributeAssertion> assertions)
      Asserts the event has attributes matching all assertions. Assertions can be created using methods like OpenTelemetryAssertions.satisfies(AttributeKey, OpenTelemetryAssertions.LongAssertConsumer).
      Since:
      1.21.0
    • hasAttributesSatisfyingExactly

      public SpanDataAssert hasAttributesSatisfyingExactly(AttributeAssertion... assertions)
      Asserts the span has attributes matching all assertions and no more. Assertions can be created using methods like OpenTelemetryAssertions.satisfies(AttributeKey, OpenTelemetryAssertions.LongAssertConsumer).
    • hasAttributesSatisfyingExactly

      public SpanDataAssert hasAttributesSatisfyingExactly(Iterable<AttributeAssertion> assertions)
      Asserts the span has attributes matching all assertions and no more. Assertions can be created using methods like OpenTelemetryAssertions.satisfies(AttributeKey, OpenTelemetryAssertions.LongAssertConsumer).
    • hasException

      public SpanDataAssert hasException(@Nullable Throwable exception)
      Asserts the span has an exception event for the given Throwable. The stack trace is not matched against. If exception is null, asserts the span has no exception event.
    • hasEvents

      public SpanDataAssert hasEvents(Iterable<io.opentelemetry.sdk.trace.data.EventData> events)
      Asserts the span has the given events.
    • hasEvents

      public SpanDataAssert hasEvents(io.opentelemetry.sdk.trace.data.EventData... events)
      Asserts the span has the given events.
    • hasEventsSatisfying

      public SpanDataAssert hasEventsSatisfying(Consumer<List<? extends io.opentelemetry.sdk.trace.data.EventData>> condition)
      Asserts the span has events satisfying the given condition.
    • hasEventsSatisfyingExactly

      @SafeVarargs public final SpanDataAssert hasEventsSatisfyingExactly(Consumer<EventDataAssert>... assertions)
      Asserts that the span under assertion has the same number of events as provided assertions and executes each EventDataAssert in assertions in order with the corresponding event.
    • hasLinks

      public SpanDataAssert hasLinks(Iterable<io.opentelemetry.sdk.trace.data.LinkData> links)
      Asserts the span has the given links.
    • hasLinks

      public SpanDataAssert hasLinks(io.opentelemetry.sdk.trace.data.LinkData... links)
      Asserts the span has the given links.
    • hasLinksSatisfying

      public SpanDataAssert hasLinksSatisfying(Consumer<List<? extends io.opentelemetry.sdk.trace.data.LinkData>> condition)
      Asserts the span has events satisfying the given condition.
    • hasStatus

      public SpanDataAssert hasStatus(io.opentelemetry.sdk.trace.data.StatusData status)
      Asserts the span has the given StatusData.
      Since:
      1.16.0
    • hasStatusSatisfying

      public SpanDataAssert hasStatusSatisfying(Consumer<StatusDataAssert> condition)
      Asserts the span has a status satisfying the given condition.
    • endsAt

      public SpanDataAssert endsAt(long endEpochNanos)
      Asserts the span ends at the given epoch timestamp, in nanos.
    • endsAt

      public SpanDataAssert endsAt(long startEpoch, TimeUnit unit)
      Asserts the span ends at the given epoch timestamp.
    • endsAt

      public SpanDataAssert endsAt(Instant timestamp)
      Asserts the span ends at the given epoch timestamp.
    • hasEnded

      public SpanDataAssert hasEnded()
      Asserts the span has ended.
    • hasNotEnded

      public SpanDataAssert hasNotEnded()
      Asserts the span has not ended.
    • hasTotalRecordedEvents

      public SpanDataAssert hasTotalRecordedEvents(int totalRecordedEvents)
      Asserts the span has the given total recorded events.
    • hasTotalRecordedLinks

      public SpanDataAssert hasTotalRecordedLinks(int totalRecordedLinks)
      Asserts the span has the given total recorded links.
    • hasTotalAttributeCount

      public SpanDataAssert hasTotalAttributeCount(int totalAttributeCount)
      Asserts the span has the given total attributes.