1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-01-26 03:52:03 +02:00

Remove unnecessary internal package for noop instances (#2867)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Bogdan Drutu 2022-04-28 12:11:17 -07:00 committed by GitHub
parent a50cf6aadd
commit a14ecc7a57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 40 deletions

View File

@ -31,11 +31,18 @@ import (
"go.opentelemetry.io/otel/bridge/opentracing/migration"
"go.opentelemetry.io/otel/codes"
iBaggage "go.opentelemetry.io/otel/internal/baggage"
"go.opentelemetry.io/otel/internal/trace/noop"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
)
var (
noopTracer = trace.NewNoopTracerProvider().Tracer("")
noopSpan = func() trace.Span {
_, s := noopTracer.Start(context.Background(), "")
return s
}()
)
type bridgeSpanContext struct {
bag baggage.Baggage
otelSpanContext trace.SpanContext
@ -321,7 +328,7 @@ var _ ot.TracerContextWithSpanExtension = &BridgeTracer{}
func NewBridgeTracer() *BridgeTracer {
return &BridgeTracer{
setTracer: bridgeSetTracer{
otelTracer: noop.Tracer,
otelTracer: noopTracer,
},
warningHandler: func(msg string) {},
propagator: nil,
@ -641,7 +648,7 @@ func (t *BridgeTracer) Inject(sm ot.SpanContext, format interface{}, carrier int
}
header := http.Header(hhcarrier)
fs := fakeSpan{
Span: noop.Span,
Span: noopSpan,
sc: bridgeSC.otelSpanContext,
}
ctx := trace.ContextWithSpan(context.Background(), fs)

View File

@ -1,35 +0,0 @@
// Copyright The OpenTelemetry Authors
//
// 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.
// Package noop provides noop tracing implementations for tracer and span.
package noop // import "go.opentelemetry.io/otel/internal/trace/noop"
import (
"context"
"go.opentelemetry.io/otel/trace"
)
var (
// Tracer is a noop tracer that starts noop spans.
Tracer trace.Tracer
// Span is a noop Span.
Span trace.Span
)
func init() {
Tracer = trace.NewNoopTracerProvider().Tracer("")
_, Span = Tracer.Start(context.Background(), "")
}

View File

@ -19,7 +19,6 @@ import (
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/internal/trace/noop"
"go.opentelemetry.io/otel/trace"
)
@ -28,7 +27,7 @@ type testTracerProvider struct{}
var _ trace.TracerProvider = &testTracerProvider{}
func (*testTracerProvider) Tracer(_ string, _ ...trace.TracerOption) trace.Tracer {
return noop.Tracer
return trace.NewNoopTracerProvider().Tracer("")
}
func TestMultipleGlobalTracerProvider(t *testing.T) {