Skip to content

Commit

Permalink
autoexport: Rename IsNone to IsNoneSpanExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Aug 3, 2023
1 parent 83a3c26 commit 571b398
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exporters/autoexport/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func WithFallbackSpanExporter(exporter trace.SpanExporter) Option {
// Use [WithFallbackSpanExporter] option to change the returned exporter
// when OTEL_TRACES_EXPORTER is unset or empty.
//
// Use [IsNone] to check if the retured exporter is a "no operation" exporter.
// Use [IsNoneSpanExporter] to check if the retured exporter is a "no operation" exporter.
func NewSpanExporter(ctx context.Context, opts ...Option) (trace.SpanExporter, error) {
// prefer exporter configured via environment variables over exporter
// passed in via exporter parameter
Expand Down
8 changes: 4 additions & 4 deletions exporters/autoexport/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestFallbackExporterReturnedWhenNoEnvExporterConfigured(t *testing.T) {
)
assert.NoError(t, err)
assert.Equal(t, testExporter, exporter)
assert.False(t, IsNone(exporter))
assert.False(t, IsNoneSpanExporter(exporter))
}

func TestEnvExporterIsPreferredOverFallbackExporter(t *testing.T) {
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestEnvExporterNone(t *testing.T) {

exporter, err := NewSpanExporter(context.Background())
assert.NoError(t, err)
assert.True(t, IsNone(exporter))
assert.True(t, IsNoneSpanExporter(exporter))
}

func assertOTLPHTTPExporter(t *testing.T, got trace.SpanExporter) {
Expand All @@ -108,7 +108,7 @@ func assertOTLPHTTPExporter(t *testing.T, got trace.SpanExporter) {
clientType := reflect.Indirect(reflect.ValueOf(got)).FieldByName("client").Elem().Type().String()
assert.Equal(t, "*otlptracehttp.client", clientType)

assert.False(t, IsNone(got))
assert.False(t, IsNoneSpanExporter(got))
}

func assertOTLPGRPCExporter(t *testing.T, got trace.SpanExporter) {
Expand All @@ -122,7 +122,7 @@ func assertOTLPGRPCExporter(t *testing.T, got trace.SpanExporter) {
clientType := reflect.Indirect(reflect.ValueOf(got)).FieldByName("client").Elem().Type().String()
assert.Equal(t, "*otlptracegrpc.client", clientType)

assert.False(t, IsNone(got))
assert.False(t, IsNoneSpanExporter(got))
}

type testExporter struct{}
Expand Down
4 changes: 2 additions & 2 deletions exporters/autoexport/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func (e noop) Shutdown(ctx context.Context) error {
return nil
}

// IsNone returns true for the exporter returned by [NewSpanExporter]
// IsNoneSpanExporter returns true for the exporter returned by [NewSpanExporter]
// when OTEL_TRACES_EXPORTER environment variable is set to "none".
func IsNone(e trace.SpanExporter) bool {
func IsNoneSpanExporter(e trace.SpanExporter) bool {
_, ok := e.(noop)
return ok
}

0 comments on commit 571b398

Please sign in to comment.