func RunAPIChecks( t *testing.T, newTracer func() (tracer opentracing.Tracer, closer func()), opts ...APICheckOption, )
RunAPIChecks runs a test suite to check a Tracer against the OpenTracing API. It is provided a function that will be executed to create and destroy a tracer for each test in the suite, and the given APICheckOption functional options `opts`.
APICheckCapabilities describes capabilities of a Tracer that should be checked by APICheckSuite.
type APICheckCapabilities struct { CheckBaggageValues bool // whether to check for propagation of baggage values CheckExtract bool // whether to check if extracting contexts from carriers works CheckInject bool // whether to check if injecting contexts works Probe APICheckProbe // optional interface providing methods to check recorded data }
APICheckOption instances may be passed to NewAPICheckSuite.
type APICheckOption func(*APICheckSuite)
func CheckBaggageValues(val bool) APICheckOption
CheckBaggageValues returns an option that sets whether to check for propagation of baggage values.
func CheckEverything() APICheckOption
CheckEverything returns an option that enables all API checks.
func CheckExtract(val bool) APICheckOption
CheckExtract returns an option that sets whether to check if extracting contexts from carriers works.
func CheckInject(val bool) APICheckOption
CheckInject returns an option that sets whether to check if injecting contexts works.
func UseProbe(probe APICheckProbe) APICheckOption
UseProbe returns an option that specifies an APICheckProbe implementation to use.
APICheckProbe exposes methods for testing data recorded by a Tracer.
type APICheckProbe interface { // SameTrace helps tests assert that this tracer's spans are from the same trace. SameTrace(first, second opentracing.Span) bool // SameSpanContext helps tests assert that a span and a context are from the same trace and span. SameSpanContext(opentracing.Span, opentracing.SpanContext) bool }
APICheckSuite is a testify suite for checking a Tracer against the OpenTracing API.
type APICheckSuite struct { suite.Suite // contains filtered or unexported fields }
func (s *APICheckSuite) SetupTest()
SetupTest creates a tracer for this specific test invocation.
func (s *APICheckSuite) TearDownTest()
TearDownTest closes the tracer, and clears the test-specific tracer.
func (s *APICheckSuite) TestBinaryPropagation()
TestBinaryPropagation tests if the Tracer can Inject a span into a binary buffer, and later Extract it. If CheckExtract is set, it will check if Extract was successful (returned no error). If a Probe is set, it will check if the extracted context is in the same trace as the original span.
func (s *APICheckSuite) TestContextBaggage()
TestContextBaggage tests calls to set and get span baggage, and if the CheckBaggageValues option is set, asserts that baggage values were successfully retrieved from the span's SpanContext.
func (s *APICheckSuite) TestHTTPPropagation()
TestHTTPPropagation tests if the Tracer can Inject a span into HTTP headers, and later Extract it. If CheckExtract is set, it will check if Extract was successful (returned no error). If a Probe is set, it will check if the extracted context is in the same trace as the original span.
func (s *APICheckSuite) TestInvalidExtract()
TestInvalidExtract checks if errors are returned when Extract is called with invalid inputs.
func (s *APICheckSuite) TestInvalidInject()
TestInvalidInject checks if errors are returned when Inject is called with invalid inputs.
func (s *APICheckSuite) TestMandatoryFormats()
TestMandatoryFormats tests if all mandatory carrier formats are supported. If CheckExtract is set, it will check if the call to Extract was successful (returned no error such as ErrUnsupportedFormat).
func (s *APICheckSuite) TestMultiBaggage()
TestMultiBaggage tests calls to set multiple baggage items, and if the CheckBaggageValues option is set, asserts that a baggage value was successfully retrieved from the span's SpanContext. It also ensures that returning false from the ForeachBaggageItem handler aborts iteration.
func (s *APICheckSuite) TestSetOperationName()
TestSetOperationName attempts to set the operation name on a span after it has been created.
func (s *APICheckSuite) TestSpanBaggage()
TestSpanBaggage tests calls to set and get span baggage, and if the CheckBaggageValues option is set, asserts that baggage values were successfully retrieved.
func (s *APICheckSuite) TestSpanLogs()
TestSpanLogs tests calls to log keys and values with spans.
func (s *APICheckSuite) TestSpanTagValueTypes()
TestSpanTagValueTypes sets tags using values of different types.
func (s *APICheckSuite) TestSpanTagsWithChaining()
TestSpanTagsWithChaining tests chaining of calls to SetTag.
func (s *APICheckSuite) TestStartSpan()
TestStartSpan checks if a Tracer can start a span and calls some span API methods.
func (s *APICheckSuite) TestStartSpanWithParent()
TestStartSpanWithParent checks if a Tracer can start a span with a specified parent.
func (s *APICheckSuite) TestTextPropagation()
TestTextPropagation tests if the Tracer can Inject a span into a TextMapCarrier, and later Extract it. If CheckExtract is set, it will check if Extract was successful (returned no error). If a Probe is set, it will check if the extracted context is in the same trace as the original span.
func (s *APICheckSuite) TestUnknownFormat()
TestUnknownFormat checks if attempting to Inject or Extract using an unsupported format returns ErrUnsupportedFormat, if CheckInject and CheckExtract are set.
ForeignSpanContext satisfies the opentracing.SpanContext interface, but otherwise does nothing.
type ForeignSpanContext struct{}
func (f ForeignSpanContext) ForeachBaggageItem(handler func(k, v string) bool)
ForeachBaggageItem could call handler for each baggage KV, but does nothing.
NotACarrier does not satisfy any of the opentracing carrier interfaces.
type NotACarrier struct{}