Completely skip metric reporting if backend is 'none'. (#1599)

This commit is contained in:
Markus Thömmes 2020-08-10 19:22:30 +02:00 committed by GitHub
parent 095ff27da6
commit c903170f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -156,9 +156,9 @@ func NewStackdriverClientConfigFromMap(config map[string]string) *StackdriverCli
// record applies the `ros` Options to each measurement in `mss` and then records the resulting
// measurements in the metricsConfig's designated backend.
func (mc *metricsConfig) record(ctx context.Context, mss []stats.Measurement, ros ...stats.Options) error {
if mc == nil {
// Don't record data points if the metric config is not initialized yet.
// At this point, it's unclear whether should record or not.
if mc == nil || mc.backendDestination == none {
// Don't record data points if the metric config is not initialized yet or if
// the defined backend is "none" explicitly.
return nil
}

View File

@ -148,6 +148,10 @@ func testRecord(t *testing.T, measure *stats.Int64Measure, shouldReportCases []c
}, {
name: "empty metricsConfig",
measurement: measure.M(4),
}, {
name: "none backend",
metricsConfig: &metricsConfig{backendDestination: none},
measurement: measure.M(4),
}}
for _, test := range shouldNotReportCases {