Skip to content

Commit

Permalink
fix bug when instrumentation explicitly disabled (#19355)
Browse files Browse the repository at this point in the history
  • Loading branch information
jalvz authored Jun 24, 2020
1 parent ebe5373 commit 1498938
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libbeat/instrumentation/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func initTracer(cfg Config, beatName, beatVersion string) (*instrumentation, err
if !cfg.IsEnabled() {
os.Setenv("ELASTIC_APM_ACTIVE", "false")
logger.Infof("APM instrumentation is disabled")
return nil, nil
return &instrumentation{}, nil
} else {
os.Setenv("ELASTIC_APM_ACTIVE", "true")
logger.Infof("APM instrumentation is enabled")
Expand Down
12 changes: 12 additions & 0 deletions libbeat/instrumentation/instrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@ func TestAPMTracerDisabledByDefault(t *testing.T) {
require.NotNil(t, tracer)
assert.False(t, tracer.Active())
}

func TestInstrumentationDisabled(t *testing.T) {
cfg := common.MustNewConfigFrom(map[string]interface{}{
"instrumentation": map[string]interface{}{
"enabled": "false",
},
})
instrumentation, err := New(cfg, "filebeat", version.GetDefaultVersion())
require.NoError(t, err)
require.NotNil(t, instrumentation)

}

0 comments on commit 1498938

Please sign in to comment.