2020-03-24 07:41:10 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-10-17 20:13:57 +02:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-10-13 21:27:53 +02:00
|
|
|
/*
|
|
|
|
Package oteltest provides testing utilities for the otel package.
|
|
|
|
|
2021-06-18 17:22:16 +02:00
|
|
|
This package is currently in a Release Candidate phase. Backwards incompatible changes
|
|
|
|
may be introduced prior to v1.0.0, but we believe the current API is ready to stabilize.
|
2020-10-29 18:23:13 +02:00
|
|
|
|
2020-10-13 21:27:53 +02:00
|
|
|
API Validation
|
|
|
|
|
|
|
|
The Harness can be used to validate an implementation of the OpenTelemetry API
|
|
|
|
defined by the `otel` package.
|
|
|
|
|
|
|
|
func TestCustomSDKTracingImplementation(t *testing.T) {
|
|
|
|
yourTraceProvider := NewTracerProvider()
|
|
|
|
subjectFactory := func() otel.Tracer {
|
|
|
|
return yourTraceProvider.Tracer("testing")
|
|
|
|
}
|
|
|
|
|
|
|
|
oteltest.NewHarness(t).TestTracer(subjectFactory)
|
|
|
|
}
|
|
|
|
|
|
|
|
Currently the Harness only provides testing of the trace portion of the
|
|
|
|
OpenTelemetry API.
|
|
|
|
|
|
|
|
Trace Testing
|
|
|
|
|
|
|
|
To test tracing functionality a full testing implementation of the
|
|
|
|
OpenTelemetry tracing API are provided. The provided TracerProvider, Tracer,
|
|
|
|
and Span all implement their related interface and are designed to allow
|
|
|
|
introspection of their state and history. Additionally, a SpanRecorder can be
|
|
|
|
provided to the TracerProvider to record all Spans started and ended by the
|
|
|
|
testing structures.
|
|
|
|
|
2021-02-17 17:31:59 +02:00
|
|
|
sr := new(oteltest.SpanRecorder)
|
2020-10-13 21:27:53 +02:00
|
|
|
tp := oteltest.NewTracerProvider(oteltest.WithSpanRecorder(sr))
|
|
|
|
*/
|
2020-10-09 04:58:56 +02:00
|
|
|
package oteltest // import "go.opentelemetry.io/otel/oteltest"
|