-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from launchdarkly/eb/ch81724/metrics3
(v6 - #7) refactoring of metrics code to clarify scopes of components
- Loading branch information
Showing
18 changed files
with
842 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package metrics | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/launchdarkly/ld-relay/v6/config" | ||
"gopkg.in/launchdarkly/go-sdk-common.v1/ldvalue" | ||
"gopkg.in/launchdarkly/go-sdk-common.v2/ldlog" | ||
) | ||
|
||
func TestDatadogExporterType(t *testing.T) { | ||
exporterType := datadogExporterType | ||
|
||
t.Run("name", func(t *testing.T) { | ||
assert.Equal(t, "Datadog", exporterType.getName()) | ||
}) | ||
|
||
t.Run("included in allExporterTypes", func(t *testing.T) { | ||
assert.Contains(t, allExporterTypes(), exporterType) | ||
}) | ||
|
||
t.Run("does not create exporter if Datadog is disabled", func(t *testing.T) { | ||
var mc config.MetricsConfig | ||
e, err := exporterType.createExporterIfEnabled(mc, ldlog.NewDisabledLoggers()) | ||
require.NoError(t, err) | ||
assert.Nil(t, e) | ||
}) | ||
|
||
t.Run("creates exporter if Datadog is enabled", func(t *testing.T) { | ||
var mc config.MetricsConfig | ||
mc.Datadog.Enabled = true | ||
e, err := exporterType.createExporterIfEnabled(mc, ldlog.NewDisabledLoggers()) | ||
require.NoError(t, err) | ||
assert.NotNil(t, e) | ||
e.close() | ||
}) | ||
|
||
t.Run("returns error for invalid stats address", func(t *testing.T) { | ||
var mc config.MetricsConfig | ||
mc.Datadog.Enabled = true | ||
mc.Datadog.StatsAddr = ldvalue.NewOptionalString("::").AsPointer() | ||
e, err := exporterType.createExporterIfEnabled(mc, ldlog.NewDisabledLoggers()) | ||
require.Error(t, err) | ||
assert.Nil(t, e) | ||
}) | ||
|
||
t.Run("registers exporter without errors", func(t *testing.T) { | ||
var mc config.MetricsConfig | ||
mc.Datadog.Enabled = true | ||
e, err := exporterType.createExporterIfEnabled(mc, ldlog.NewDisabledLoggers()) | ||
require.NoError(t, err) | ||
assert.NotNil(t, e) | ||
defer e.close() | ||
assert.NoError(t, e.register()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.