Skip to content
Expected Span

Expected Span

Introduction

An expected span represents a call that is expected to be found within the trace collected following the trigger execution.

Example:

spans:
  - serviceName: "grpc-server"
    operationName: "grpc.RollDice"
    spanKind: "server"
    spanStatus: "unset"
    maxDuration: 2s
    minDuration: 1us
  - serviceName: "even-or-odd-service"
    operationName: "even-or-odd-span"
    spanKind: "internal"
    spanStatus: "unset"

Configuration

Within an expected span, you can specify various parameters to verify that the span collected in the generated trace exhibits specific characteristics. Below are the parameters that can be used in an expected span:

ArgumentDescriptionOptional
serviceNameThe OTel service name associated with the expected spanNo
operationNameThe OTel operation name associated with the expected spanYes
spanKindThe OTel span kind of the expected spanYes
spanStatusThe OTel span status of the expected spanYes
maxDurationMaximum allowed duration of the expected spanYes
minDurationMinimum allowed duration of the expected spanYes

SpanKind

The spanKind field specifies the OTel span kind of the expected span, which can be one of the following values:

  • internal
  • server
  • client
  • producer
  • consumer
  • unset/unspecified

We recommend reading the official OpenTelemetry documentation.

SpanStatus

The spanStatus field specifies the OTel span status of the expected span, which can be one of the following values:

  • unset
  • ok
  • error

We recommend reading the official OpenTelemetry documentation.

MaxDuration and MinDuration

The maxDuration and minDuration fields specify the maximum and minimum duration of the expected span, respectively. They must be formatted as a Go Duration String.