1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-02-09 13:37:12 +02:00

Remove WithDisabledFromEnv from NewRawExporter

This commit is contained in:
Sam Xie 2020-06-10 11:36:25 +08:00
parent 0966ad51ca
commit 4b8f8b90dc
4 changed files with 23 additions and 3 deletions

View File

@ -70,7 +70,7 @@ func WithDisabledFromEnv() Option {
}
}
// WithProcessFromEnv parse environment variables into jaeger exporter's Process.
// ProcessFromEnv parse environment variables into jaeger exporter's Process.
func ProcessFromEnv() Process {
var p Process
if e := os.Getenv(envServiceName); e != "" {

View File

@ -197,7 +197,8 @@ func TestNewRawExporterWithEnvImplicitly(t *testing.T) {
)
assert.NoError(t, err)
assert.Equal(t, false, exp.o.Disabled)
// NewRawExporter will ignore Disabled env
assert.Equal(t, true, exp.o.Disabled)
assert.EqualValues(t, serviceName, exp.process.ServiceName)
assert.Len(t, exp.process.Tags, 1)

View File

@ -97,7 +97,7 @@ func NewRawExporter(endpointOption EndpointOption, opts ...Option) (*Exporter, e
}
o := options{}
opts = append(opts, WithDisabledFromEnv(), WithProcessFromEnv())
opts = append(opts, WithProcessFromEnv())
for _, opt := range opts {
opt(&o)
}
@ -142,6 +142,7 @@ func NewRawExporter(endpointOption EndpointOption, opts ...Option) (*Exporter, e
// with the recommended setup for trace provider
func NewExportPipeline(endpointOption EndpointOption, opts ...Option) (apitrace.Provider, func(), error) {
o := options{}
opts = append(opts, WithDisabledFromEnv())
for _, opt := range opts {
opt(&o)
}

View File

@ -326,3 +326,21 @@ func TestNewExporterPipelineWithDisabled(t *testing.T) {
assert.NoError(t, err)
assert.IsType(t, &apitrace.NoopProvider{}, tp)
}
func TestNewExporterPipelineWithDisabledFromEnv(t *testing.T) {
envStore, err := ottest.SetEnvVariables(map[string]string{
envDisabled: "true",
})
require.NoError(t, err)
envStore.Record(envDisabled)
defer func() {
require.NoError(t, envStore.Restore())
}()
tp, fn, err := NewExportPipeline(
WithCollectorEndpoint("http://localhost:14268/api/traces"),
)
defer fn()
assert.NoError(t, err)
assert.IsType(t, &apitrace.NoopProvider{}, tp)
}