diff --git a/.chloggen/snowflake_add_doc.yaml b/.chloggen/snowflake_add_doc.yaml new file mode 100644 index 000000000000..25f69ac204a4 --- /dev/null +++ b/.chloggen/snowflake_add_doc.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: snowflakereceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: added doc.go containing pragma for mdatagen + +# One or more tracking issues related to the change +issues: [17978] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/receiver/snowflakereceiver/doc.go b/receiver/snowflakereceiver/doc.go new file mode 100644 index 000000000000..ebee1dc4cf78 --- /dev/null +++ b/receiver/snowflakereceiver/doc.go @@ -0,0 +1,17 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:generate mdatagen metadata.yaml + +package snowflakereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/snowflakereceiver" diff --git a/receiver/snowflakereceiver/documentation.md b/receiver/snowflakereceiver/documentation.md index 02b32f8285df..d7ee337b57ef 100644 --- a/receiver/snowflakereceiver/documentation.md +++ b/receiver/snowflakereceiver/documentation.md @@ -612,6 +612,6 @@ Number of bytes of data in Fail-safe. ## Resource Attributes -| Name | Description | Values | -| ---- | ----------- | ------ | -| snowflake.account.name | Snowflake account being used by receiver. | Any Str | +| Name | Description | Values | Enabled | +| ---- | ----------- | ------ | ------- | +| snowflake.account.name | Snowflake account being used by receiver. | Any Str | true | diff --git a/receiver/snowflakereceiver/internal/metadata/generated_metrics.go b/receiver/snowflakereceiver/internal/metadata/generated_metrics.go index 442bee46b742..b4f7dc793b75 100644 --- a/receiver/snowflakereceiver/internal/metadata/generated_metrics.go +++ b/receiver/snowflakereceiver/internal/metadata/generated_metrics.go @@ -16,12 +16,7 @@ import ( type MetricSettings struct { Enabled bool `mapstructure:"enabled"` - enabledProvidedByUser bool -} - -// IsEnabledProvidedByUser returns true if `enabled` option is explicitly set in user settings to any value. -func (ms *MetricSettings) IsEnabledProvidedByUser() bool { - return ms.enabledProvidedByUser + enabledSetByUser bool } func (ms *MetricSettings) Unmarshal(parser *confmap.Conf) error { @@ -32,7 +27,7 @@ func (ms *MetricSettings) Unmarshal(parser *confmap.Conf) error { if err != nil { return err } - ms.enabledProvidedByUser = parser.IsSet("enabled") + ms.enabledSetByUser = parser.IsSet("enabled") return nil } @@ -185,6 +180,38 @@ func DefaultMetricsSettings() MetricsSettings { } } +// ResourceAttributeSettings provides common settings for a particular metric. +type ResourceAttributeSettings struct { + Enabled bool `mapstructure:"enabled"` + + enabledProvidedByUser bool +} + +func (ras *ResourceAttributeSettings) Unmarshal(parser *confmap.Conf) error { + if parser == nil { + return nil + } + err := parser.Unmarshal(ras, confmap.WithErrorUnused()) + if err != nil { + return err + } + ras.enabledProvidedByUser = parser.IsSet("enabled") + return nil +} + +// ResourceAttributesSettings provides settings for snowflakereceiver metrics. +type ResourceAttributesSettings struct { + SnowflakeAccountName ResourceAttributeSettings `mapstructure:"snowflake.account.name"` +} + +func DefaultResourceAttributesSettings() ResourceAttributesSettings { + return ResourceAttributesSettings{ + SnowflakeAccountName: ResourceAttributeSettings{ + Enabled: true, + }, + } +} + type metricSnowflakeBillingCloudServiceTotal struct { data pmetric.Metric // data buffer for generated metric. settings MetricSettings // metric settings provided by user. @@ -2088,6 +2115,7 @@ type MetricsBuilder struct { resourceCapacity int // maximum observed number of resource attributes. metricsBuffer pmetric.Metrics // accumulates metrics data before emitting. buildInfo component.BuildInfo // contains version information + resourceAttributesSettings ResourceAttributesSettings metricSnowflakeBillingCloudServiceTotal metricSnowflakeBillingCloudServiceTotal metricSnowflakeBillingTotalCreditTotal metricSnowflakeBillingTotalCreditTotal metricSnowflakeBillingVirtualWarehouseTotal metricSnowflakeBillingVirtualWarehouseTotal @@ -2135,11 +2163,19 @@ func WithStartTime(startTime pcommon.Timestamp) metricBuilderOption { } } +// WithResourceAttributesSettings sets ResourceAttributeSettings on the metrics builder. +func WithResourceAttributesSettings(ras ResourceAttributesSettings) metricBuilderOption { + return func(mb *MetricsBuilder) { + mb.resourceAttributesSettings = ras + } +} + func NewMetricsBuilder(ms MetricsSettings, settings receiver.CreateSettings, options ...metricBuilderOption) *MetricsBuilder { mb := &MetricsBuilder{ startTime: pcommon.NewTimestampFromTime(time.Now()), metricsBuffer: pmetric.NewMetrics(), buildInfo: settings.BuildInfo, + resourceAttributesSettings: DefaultResourceAttributesSettings(), metricSnowflakeBillingCloudServiceTotal: newMetricSnowflakeBillingCloudServiceTotal(ms.SnowflakeBillingCloudServiceTotal), metricSnowflakeBillingTotalCreditTotal: newMetricSnowflakeBillingTotalCreditTotal(ms.SnowflakeBillingTotalCreditTotal), metricSnowflakeBillingVirtualWarehouseTotal: newMetricSnowflakeBillingVirtualWarehouseTotal(ms.SnowflakeBillingVirtualWarehouseTotal), @@ -2193,19 +2229,21 @@ func (mb *MetricsBuilder) updateCapacity(rm pmetric.ResourceMetrics) { } // ResourceMetricsOption applies changes to provided resource metrics. -type ResourceMetricsOption func(pmetric.ResourceMetrics) +type ResourceMetricsOption func(ResourceAttributesSettings, pmetric.ResourceMetrics) // WithSnowflakeAccountName sets provided value as "snowflake.account.name" attribute for current resource. func WithSnowflakeAccountName(val string) ResourceMetricsOption { - return func(rm pmetric.ResourceMetrics) { - rm.Resource().Attributes().PutStr("snowflake.account.name", val) + return func(ras ResourceAttributesSettings, rm pmetric.ResourceMetrics) { + if ras.SnowflakeAccountName.Enabled { + rm.Resource().Attributes().PutStr("snowflake.account.name", val) + } } } // WithStartTimeOverride overrides start time for all the resource metrics data points. // This option should be only used if different start time has to be set on metrics coming from different resources. func WithStartTimeOverride(start pcommon.Timestamp) ResourceMetricsOption { - return func(rm pmetric.ResourceMetrics) { + return func(ras ResourceAttributesSettings, rm pmetric.ResourceMetrics) { var dps pmetric.NumberDataPointSlice metrics := rm.ScopeMetrics().At(0).Metrics() for i := 0; i < metrics.Len(); i++ { @@ -2269,8 +2307,9 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricSnowflakeStorageStageBytesTotal.emit(ils.Metrics()) mb.metricSnowflakeStorageStorageBytesTotal.emit(ils.Metrics()) mb.metricSnowflakeTotalElapsedTimeAvg.emit(ils.Metrics()) + for _, op := range rmo { - op(rm) + op(mb.resourceAttributesSettings, rm) } if ils.Metrics().Len() > 0 { mb.updateCapacity(rm) diff --git a/receiver/snowflakereceiver/internal/metadata/generated_metrics_test.go b/receiver/snowflakereceiver/internal/metadata/generated_metrics_test.go index 75b9440b0be0..f184746ac978 100644 --- a/receiver/snowflakereceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/snowflakereceiver/internal/metadata/generated_metrics_test.go @@ -3,10 +3,13 @@ package metadata import ( - "reflect" + "path/filepath" "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver/receivertest" @@ -14,1131 +17,1076 @@ import ( "go.uber.org/zap/zaptest/observer" ) -func TestDefaultMetrics(t *testing.T) { - start := pcommon.Timestamp(1_000_000_000) - ts := pcommon.Timestamp(1_000_001_000) - mb := NewMetricsBuilder(DefaultMetricsSettings(), receivertest.NewNopCreateSettings(), WithStartTime(start)) - enabledMetrics := make(map[string]bool) +type testMetricsSet int - mb.RecordSnowflakeBillingCloudServiceTotalDataPoint(ts, 1, "attr-val") +const ( + testMetricsSetDefault testMetricsSet = iota + testMetricsSetAll + testMetricsSetNo +) - mb.RecordSnowflakeBillingTotalCreditTotalDataPoint(ts, 1, "attr-val") +func TestMetricsBuilder(t *testing.T) { + tests := []struct { + name string + metricsSet testMetricsSet + }{ + { + name: "default", + metricsSet: testMetricsSetDefault, + }, + { + name: "all_metrics", + metricsSet: testMetricsSetAll, + }, + { + name: "no_metrics", + metricsSet: testMetricsSetNo, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + start := pcommon.Timestamp(1_000_000_000) + ts := pcommon.Timestamp(1_000_001_000) + observedZapCore, observedLogs := observer.New(zap.WarnLevel) + settings := receivertest.NewNopCreateSettings() + settings.Logger = zap.New(observedZapCore) + mb := NewMetricsBuilder(loadConfig(t, test.name), settings, WithStartTime(start)) - mb.RecordSnowflakeBillingVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") + expectedWarnings := 0 + assert.Equal(t, expectedWarnings, observedLogs.Len()) - mb.RecordSnowflakeBillingWarehouseCloudServiceTotalDataPoint(ts, 1, "attr-val") + defaultMetricsCount := 0 + allMetricsCount := 0 - mb.RecordSnowflakeBillingWarehouseTotalCreditTotalDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingTotalCreditTotalDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.database.bytes_scanned.avg"] = true - mb.RecordSnowflakeDatabaseBytesScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.database.query.count"] = true - mb.RecordSnowflakeDatabaseQueryCountDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingWarehouseCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeLoginsTotalDataPoint(ts, 1, "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingWarehouseTotalCreditTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakePipeCreditsUsedTotalDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeBillingWarehouseVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.query.blocked"] = true - mb.RecordSnowflakeQueryBlockedDataPoint(ts, 1, "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeDatabaseBytesScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.query.bytes_deleted.avg"] = true - mb.RecordSnowflakeQueryBytesDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeDatabaseQueryCountDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledLocalAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeLoginsTotalDataPoint(ts, 1, "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledRemoteAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakePipeCreditsUsedTotalDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.query.bytes_written.avg"] = true - mb.RecordSnowflakeQueryBytesWrittenAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryBlockedDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.query.compilation_time.avg"] = true - mb.RecordSnowflakeQueryCompilationTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryBytesDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryDataScannedCacheAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeQueryBytesSpilledLocalAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.query.executed"] = true - mb.RecordSnowflakeQueryExecutedDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeQueryBytesSpilledRemoteAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.query.execution_time.avg"] = true - mb.RecordSnowflakeQueryExecutionTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryBytesWrittenAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryPartitionsScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryCompilationTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.query.queued_overload"] = true - mb.RecordSnowflakeQueryQueuedOverloadDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeQueryDataScannedCacheAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.query.queued_provision"] = true - mb.RecordSnowflakeQueryQueuedProvisionDataPoint(ts, 1, "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryExecutedDataPoint(ts, 1, "attr-val") - enabledMetrics["snowflake.queued_overload_time.avg"] = true - mb.RecordSnowflakeQueuedOverloadTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryExecutionTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.queued_provisioning_time.avg"] = true - mb.RecordSnowflakeQueuedProvisioningTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeQueryPartitionsScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.queued_repair_time.avg"] = true - mb.RecordSnowflakeQueuedRepairTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryQueuedOverloadDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeRowsDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueryQueuedProvisionDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeRowsInsertedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueuedOverloadTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsProducedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueuedProvisioningTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUnloadedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeQueuedRepairTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUpdatedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeRowsDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeSessionIDCountDataPoint(ts, 1, "attr-val") + allMetricsCount++ + mb.RecordSnowflakeRowsInsertedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeStorageFailsafeBytesTotalDataPoint(ts, 1) + allMetricsCount++ + mb.RecordSnowflakeRowsProducedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.storage.stage_bytes.total"] = true - mb.RecordSnowflakeStorageStageBytesTotalDataPoint(ts, 1) + allMetricsCount++ + mb.RecordSnowflakeRowsUnloadedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.storage.storage_bytes.total"] = true - mb.RecordSnowflakeStorageStorageBytesTotalDataPoint(ts, 1) + allMetricsCount++ + mb.RecordSnowflakeRowsUpdatedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - enabledMetrics["snowflake.total_elapsed_time.avg"] = true - mb.RecordSnowflakeTotalElapsedTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + allMetricsCount++ + mb.RecordSnowflakeSessionIDCountDataPoint(ts, 1, "attr-val") - metrics := mb.Emit() + allMetricsCount++ + mb.RecordSnowflakeStorageFailsafeBytesTotalDataPoint(ts, 1) - assert.Equal(t, 1, metrics.ResourceMetrics().Len()) - sm := metrics.ResourceMetrics().At(0).ScopeMetrics() - assert.Equal(t, 1, sm.Len()) - ms := sm.At(0).Metrics() - assert.Equal(t, len(enabledMetrics), ms.Len()) - seenMetrics := make(map[string]bool) - for i := 0; i < ms.Len(); i++ { - assert.True(t, enabledMetrics[ms.At(i).Name()]) - seenMetrics[ms.At(i).Name()] = true - } - assert.Equal(t, len(enabledMetrics), len(seenMetrics)) -} + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeStorageStageBytesTotalDataPoint(ts, 1) -func TestAllMetrics(t *testing.T) { - start := pcommon.Timestamp(1_000_000_000) - ts := pcommon.Timestamp(1_000_001_000) - metricsSettings := MetricsSettings{ - SnowflakeBillingCloudServiceTotal: MetricSettings{Enabled: true}, - SnowflakeBillingTotalCreditTotal: MetricSettings{Enabled: true}, - SnowflakeBillingVirtualWarehouseTotal: MetricSettings{Enabled: true}, - SnowflakeBillingWarehouseCloudServiceTotal: MetricSettings{Enabled: true}, - SnowflakeBillingWarehouseTotalCreditTotal: MetricSettings{Enabled: true}, - SnowflakeBillingWarehouseVirtualWarehouseTotal: MetricSettings{Enabled: true}, - SnowflakeDatabaseBytesScannedAvg: MetricSettings{Enabled: true}, - SnowflakeDatabaseQueryCount: MetricSettings{Enabled: true}, - SnowflakeLoginsTotal: MetricSettings{Enabled: true}, - SnowflakePipeCreditsUsedTotal: MetricSettings{Enabled: true}, - SnowflakeQueryBlocked: MetricSettings{Enabled: true}, - SnowflakeQueryBytesDeletedAvg: MetricSettings{Enabled: true}, - SnowflakeQueryBytesSpilledLocalAvg: MetricSettings{Enabled: true}, - SnowflakeQueryBytesSpilledRemoteAvg: MetricSettings{Enabled: true}, - SnowflakeQueryBytesWrittenAvg: MetricSettings{Enabled: true}, - SnowflakeQueryCompilationTimeAvg: MetricSettings{Enabled: true}, - SnowflakeQueryDataScannedCacheAvg: MetricSettings{Enabled: true}, - SnowflakeQueryExecuted: MetricSettings{Enabled: true}, - SnowflakeQueryExecutionTimeAvg: MetricSettings{Enabled: true}, - SnowflakeQueryPartitionsScannedAvg: MetricSettings{Enabled: true}, - SnowflakeQueryQueuedOverload: MetricSettings{Enabled: true}, - SnowflakeQueryQueuedProvision: MetricSettings{Enabled: true}, - SnowflakeQueuedOverloadTimeAvg: MetricSettings{Enabled: true}, - SnowflakeQueuedProvisioningTimeAvg: MetricSettings{Enabled: true}, - SnowflakeQueuedRepairTimeAvg: MetricSettings{Enabled: true}, - SnowflakeRowsDeletedAvg: MetricSettings{Enabled: true}, - SnowflakeRowsInsertedAvg: MetricSettings{Enabled: true}, - SnowflakeRowsProducedAvg: MetricSettings{Enabled: true}, - SnowflakeRowsUnloadedAvg: MetricSettings{Enabled: true}, - SnowflakeRowsUpdatedAvg: MetricSettings{Enabled: true}, - SnowflakeSessionIDCount: MetricSettings{Enabled: true}, - SnowflakeStorageFailsafeBytesTotal: MetricSettings{Enabled: true}, - SnowflakeStorageStageBytesTotal: MetricSettings{Enabled: true}, - SnowflakeStorageStorageBytesTotal: MetricSettings{Enabled: true}, - SnowflakeTotalElapsedTimeAvg: MetricSettings{Enabled: true}, - } - observedZapCore, observedLogs := observer.New(zap.WarnLevel) - settings := receivertest.NewNopCreateSettings() - settings.Logger = zap.New(observedZapCore) - mb := NewMetricsBuilder(metricsSettings, settings, WithStartTime(start)) + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeStorageStorageBytesTotalDataPoint(ts, 1) - assert.Equal(t, 0, observedLogs.Len()) + defaultMetricsCount++ + allMetricsCount++ + mb.RecordSnowflakeTotalElapsedTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeBillingCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingTotalCreditTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseTotalCreditTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeDatabaseBytesScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeDatabaseQueryCountDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeLoginsTotalDataPoint(ts, 1, "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakePipeCreditsUsedTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryBlockedDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryBytesDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledLocalAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledRemoteAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesWrittenAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryCompilationTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryDataScannedCacheAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryExecutedDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryExecutionTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryPartitionsScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryQueuedOverloadDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryQueuedProvisionDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueuedOverloadTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueuedProvisioningTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueuedRepairTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsInsertedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsProducedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUnloadedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUpdatedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeSessionIDCountDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeStorageFailsafeBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeStorageStageBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeStorageStorageBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeTotalElapsedTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") + metrics := mb.Emit(WithSnowflakeAccountName("attr-val")) - metrics := mb.Emit(WithSnowflakeAccountName("attr-val")) + if test.metricsSet == testMetricsSetNo { + assert.Equal(t, 0, metrics.ResourceMetrics().Len()) + return + } - assert.Equal(t, 1, metrics.ResourceMetrics().Len()) - rm := metrics.ResourceMetrics().At(0) - attrCount := 0 - attrCount++ - attrVal, ok := rm.Resource().Attributes().Get("snowflake.account.name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - assert.Equal(t, attrCount, rm.Resource().Attributes().Len()) + assert.Equal(t, 1, metrics.ResourceMetrics().Len()) + rm := metrics.ResourceMetrics().At(0) + attrCount := 0 + enabledAttrCount := 0 + attrVal, ok := rm.Resource().Attributes().Get("snowflake.account.name") + attrCount++ + assert.Equal(t, mb.resourceAttributesSettings.SnowflakeAccountName.Enabled, ok) + if mb.resourceAttributesSettings.SnowflakeAccountName.Enabled { + enabledAttrCount++ + assert.EqualValues(t, "attr-val", attrVal.Str()) + } + assert.Equal(t, enabledAttrCount, rm.Resource().Attributes().Len()) + assert.Equal(t, attrCount, 1) - assert.Equal(t, 1, rm.ScopeMetrics().Len()) - ms := rm.ScopeMetrics().At(0).Metrics() - allMetricsCount := reflect.TypeOf(MetricsSettings{}).NumField() - assert.Equal(t, allMetricsCount, ms.Len()) - validatedMetrics := make(map[string]struct{}) - for i := 0; i < ms.Len(); i++ { - switch ms.At(i).Name() { - case "snowflake.billing.cloud_service.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Reported total credits used in the cloud service over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("service_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.cloud_service.total"] = struct{}{} - case "snowflake.billing.total_credit.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Reported total credits used across account over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("service_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.total_credit.total"] = struct{}{} - case "snowflake.billing.virtual_warehouse.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Reported total credits used by virtual warehouse service over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("service_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.virtual_warehouse.total"] = struct{}{} - case "snowflake.billing.warehouse.cloud_service.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Credits used across cloud service for given warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.warehouse.cloud_service.total"] = struct{}{} - case "snowflake.billing.warehouse.total_credit.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Total credits used associated with given warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.warehouse.total_credit.total"] = struct{}{} - case "snowflake.billing.warehouse.virtual_warehouse.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Total credits used by virtual warehouse service for given warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.billing.warehouse.virtual_warehouse.total"] = struct{}{} - case "snowflake.database.bytes_scanned.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average bytes scanned in a database over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.database.bytes_scanned.avg"] = struct{}{} - case "snowflake.database.query.count": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Total query count for database over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.database.query.count"] = struct{}{} - case "snowflake.logins.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Total login attempts for account over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("reported_client_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("is_success") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.logins.total"] = struct{}{} - case "snowflake.pipe.credits_used.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Snow pipe credits contotaled over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{credits}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("pipe_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.pipe.credits_used.total"] = struct{}{} - case "snowflake.query.blocked": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Blocked query count for warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.blocked"] = struct{}{} - case "snowflake.query.bytes_deleted.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average bytes deleted in database over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.bytes_deleted.avg"] = struct{}{} - case "snowflake.query.bytes_spilled.local.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Avergae bytes spilled (intermediate results do not fit in memory) by local storage over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.bytes_spilled.local.avg"] = struct{}{} - case "snowflake.query.bytes_spilled.remote.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Avergae bytes spilled (intermediate results do not fit in memory) by remote storage over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.bytes_spilled.remote.avg"] = struct{}{} - case "snowflake.query.bytes_written.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average bytes written by database over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.bytes_written.avg"] = struct{}{} - case "snowflake.query.compilation_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average time taken to compile query over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.compilation_time.avg"] = struct{}{} - case "snowflake.query.data_scanned_cache.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average percentage of data scanned from cache over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.data_scanned_cache.avg"] = struct{}{} - case "snowflake.query.executed": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Executed query count for warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.executed"] = struct{}{} - case "snowflake.query.execution_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average time spent executing queries in database over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.execution_time.avg"] = struct{}{} - case "snowflake.query.partitions_scanned.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of partitions scanned during query so far over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.partitions_scanned.avg"] = struct{}{} - case "snowflake.query.queued_overload": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Overloaded query count for warehouse over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.queued_overload"] = struct{}{} - case "snowflake.query.queued_provision": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of compute resources queued for provisioning over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.query.queued_provision"] = struct{}{} - case "snowflake.queued_overload_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average time spent in warehouse queue due to warehouse being overloaded over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.queued_overload_time.avg"] = struct{}{} - case "snowflake.queued_provisioning_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average time spent in warehouse queue waiting for resources to provision over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.queued_provisioning_time.avg"] = struct{}{} - case "snowflake.queued_repair_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average time spent in warehouse queue waiting for compute resources to be repaired over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.queued_repair_time.avg"] = struct{}{} - case "snowflake.rows_deleted.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of rows deleted from a table (or tables) over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{rows}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.rows_deleted.avg"] = struct{}{} - case "snowflake.rows_inserted.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of rows inserted into a table (or tables) over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{rows}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.rows_inserted.avg"] = struct{}{} - case "snowflake.rows_produced.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average number of rows produced by statement over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{rows}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.rows_produced.avg"] = struct{}{} - case "snowflake.rows_unloaded.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average number of rows unloaded during data export over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{rows}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.rows_unloaded.avg"] = struct{}{} - case "snowflake.rows_updated.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average number of rows updated in a table over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "{rows}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.rows_updated.avg"] = struct{}{} - case "snowflake.session_id.count": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Distinct session id's associated with snowflake username over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "1", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("user_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.session_id.count"] = struct{}{} - case "snowflake.storage.failsafe_bytes.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of bytes of data in Fail-safe.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - validatedMetrics["snowflake.storage.failsafe_bytes.total"] = struct{}{} - case "snowflake.storage.stage_bytes.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of bytes of stage storage used by files in all internal stages (named, table, user).", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - validatedMetrics["snowflake.storage.stage_bytes.total"] = struct{}{} - case "snowflake.storage.storage_bytes.total": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Number of bytes of table storage used, including bytes for data currently in Time Travel.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - validatedMetrics["snowflake.storage.storage_bytes.total"] = struct{}{} - case "snowflake.total_elapsed_time.avg": - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average elapsed time over the last 24 hour window.", ms.At(i).Description()) - assert.Equal(t, "s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.Equal(t, float64(1), dp.DoubleValue()) - attrVal, ok := dp.Attributes().Get("schema_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("execution_status") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("error_message") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("query_type") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("database_name") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("warehouse_size") - assert.True(t, ok) - assert.EqualValues(t, "attr-val", attrVal.Str()) - validatedMetrics["snowflake.total_elapsed_time.avg"] = struct{}{} - } + assert.Equal(t, 1, rm.ScopeMetrics().Len()) + ms := rm.ScopeMetrics().At(0).Metrics() + if test.metricsSet == testMetricsSetDefault { + assert.Equal(t, defaultMetricsCount, ms.Len()) + } + if test.metricsSet == testMetricsSetAll { + assert.Equal(t, allMetricsCount, ms.Len()) + } + validatedMetrics := make(map[string]bool) + for i := 0; i < ms.Len(); i++ { + switch ms.At(i).Name() { + case "snowflake.billing.cloud_service.total": + assert.False(t, validatedMetrics["snowflake.billing.cloud_service.total"], "Found a duplicate in the metrics slice: snowflake.billing.cloud_service.total") + validatedMetrics["snowflake.billing.cloud_service.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Reported total credits used in the cloud service over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("service_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.billing.total_credit.total": + assert.False(t, validatedMetrics["snowflake.billing.total_credit.total"], "Found a duplicate in the metrics slice: snowflake.billing.total_credit.total") + validatedMetrics["snowflake.billing.total_credit.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Reported total credits used across account over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("service_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.billing.virtual_warehouse.total": + assert.False(t, validatedMetrics["snowflake.billing.virtual_warehouse.total"], "Found a duplicate in the metrics slice: snowflake.billing.virtual_warehouse.total") + validatedMetrics["snowflake.billing.virtual_warehouse.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Reported total credits used by virtual warehouse service over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("service_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.billing.warehouse.cloud_service.total": + assert.False(t, validatedMetrics["snowflake.billing.warehouse.cloud_service.total"], "Found a duplicate in the metrics slice: snowflake.billing.warehouse.cloud_service.total") + validatedMetrics["snowflake.billing.warehouse.cloud_service.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Credits used across cloud service for given warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.billing.warehouse.total_credit.total": + assert.False(t, validatedMetrics["snowflake.billing.warehouse.total_credit.total"], "Found a duplicate in the metrics slice: snowflake.billing.warehouse.total_credit.total") + validatedMetrics["snowflake.billing.warehouse.total_credit.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Total credits used associated with given warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.billing.warehouse.virtual_warehouse.total": + assert.False(t, validatedMetrics["snowflake.billing.warehouse.virtual_warehouse.total"], "Found a duplicate in the metrics slice: snowflake.billing.warehouse.virtual_warehouse.total") + validatedMetrics["snowflake.billing.warehouse.virtual_warehouse.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Total credits used by virtual warehouse service for given warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.database.bytes_scanned.avg": + assert.False(t, validatedMetrics["snowflake.database.bytes_scanned.avg"], "Found a duplicate in the metrics slice: snowflake.database.bytes_scanned.avg") + validatedMetrics["snowflake.database.bytes_scanned.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average bytes scanned in a database over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.database.query.count": + assert.False(t, validatedMetrics["snowflake.database.query.count"], "Found a duplicate in the metrics slice: snowflake.database.query.count") + validatedMetrics["snowflake.database.query.count"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Total query count for database over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.logins.total": + assert.False(t, validatedMetrics["snowflake.logins.total"], "Found a duplicate in the metrics slice: snowflake.logins.total") + validatedMetrics["snowflake.logins.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Total login attempts for account over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("reported_client_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("is_success") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.pipe.credits_used.total": + assert.False(t, validatedMetrics["snowflake.pipe.credits_used.total"], "Found a duplicate in the metrics slice: snowflake.pipe.credits_used.total") + validatedMetrics["snowflake.pipe.credits_used.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Snow pipe credits contotaled over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{credits}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("pipe_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.blocked": + assert.False(t, validatedMetrics["snowflake.query.blocked"], "Found a duplicate in the metrics slice: snowflake.query.blocked") + validatedMetrics["snowflake.query.blocked"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Blocked query count for warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.bytes_deleted.avg": + assert.False(t, validatedMetrics["snowflake.query.bytes_deleted.avg"], "Found a duplicate in the metrics slice: snowflake.query.bytes_deleted.avg") + validatedMetrics["snowflake.query.bytes_deleted.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average bytes deleted in database over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.bytes_spilled.local.avg": + assert.False(t, validatedMetrics["snowflake.query.bytes_spilled.local.avg"], "Found a duplicate in the metrics slice: snowflake.query.bytes_spilled.local.avg") + validatedMetrics["snowflake.query.bytes_spilled.local.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Avergae bytes spilled (intermediate results do not fit in memory) by local storage over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.bytes_spilled.remote.avg": + assert.False(t, validatedMetrics["snowflake.query.bytes_spilled.remote.avg"], "Found a duplicate in the metrics slice: snowflake.query.bytes_spilled.remote.avg") + validatedMetrics["snowflake.query.bytes_spilled.remote.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Avergae bytes spilled (intermediate results do not fit in memory) by remote storage over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.bytes_written.avg": + assert.False(t, validatedMetrics["snowflake.query.bytes_written.avg"], "Found a duplicate in the metrics slice: snowflake.query.bytes_written.avg") + validatedMetrics["snowflake.query.bytes_written.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average bytes written by database over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.compilation_time.avg": + assert.False(t, validatedMetrics["snowflake.query.compilation_time.avg"], "Found a duplicate in the metrics slice: snowflake.query.compilation_time.avg") + validatedMetrics["snowflake.query.compilation_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average time taken to compile query over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.data_scanned_cache.avg": + assert.False(t, validatedMetrics["snowflake.query.data_scanned_cache.avg"], "Found a duplicate in the metrics slice: snowflake.query.data_scanned_cache.avg") + validatedMetrics["snowflake.query.data_scanned_cache.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average percentage of data scanned from cache over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.executed": + assert.False(t, validatedMetrics["snowflake.query.executed"], "Found a duplicate in the metrics slice: snowflake.query.executed") + validatedMetrics["snowflake.query.executed"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Executed query count for warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.execution_time.avg": + assert.False(t, validatedMetrics["snowflake.query.execution_time.avg"], "Found a duplicate in the metrics slice: snowflake.query.execution_time.avg") + validatedMetrics["snowflake.query.execution_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average time spent executing queries in database over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.partitions_scanned.avg": + assert.False(t, validatedMetrics["snowflake.query.partitions_scanned.avg"], "Found a duplicate in the metrics slice: snowflake.query.partitions_scanned.avg") + validatedMetrics["snowflake.query.partitions_scanned.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of partitions scanned during query so far over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.queued_overload": + assert.False(t, validatedMetrics["snowflake.query.queued_overload"], "Found a duplicate in the metrics slice: snowflake.query.queued_overload") + validatedMetrics["snowflake.query.queued_overload"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Overloaded query count for warehouse over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.query.queued_provision": + assert.False(t, validatedMetrics["snowflake.query.queued_provision"], "Found a duplicate in the metrics slice: snowflake.query.queued_provision") + validatedMetrics["snowflake.query.queued_provision"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of compute resources queued for provisioning over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.queued_overload_time.avg": + assert.False(t, validatedMetrics["snowflake.queued_overload_time.avg"], "Found a duplicate in the metrics slice: snowflake.queued_overload_time.avg") + validatedMetrics["snowflake.queued_overload_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average time spent in warehouse queue due to warehouse being overloaded over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.queued_provisioning_time.avg": + assert.False(t, validatedMetrics["snowflake.queued_provisioning_time.avg"], "Found a duplicate in the metrics slice: snowflake.queued_provisioning_time.avg") + validatedMetrics["snowflake.queued_provisioning_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average time spent in warehouse queue waiting for resources to provision over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.queued_repair_time.avg": + assert.False(t, validatedMetrics["snowflake.queued_repair_time.avg"], "Found a duplicate in the metrics slice: snowflake.queued_repair_time.avg") + validatedMetrics["snowflake.queued_repair_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average time spent in warehouse queue waiting for compute resources to be repaired over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.rows_deleted.avg": + assert.False(t, validatedMetrics["snowflake.rows_deleted.avg"], "Found a duplicate in the metrics slice: snowflake.rows_deleted.avg") + validatedMetrics["snowflake.rows_deleted.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of rows deleted from a table (or tables) over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{rows}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.rows_inserted.avg": + assert.False(t, validatedMetrics["snowflake.rows_inserted.avg"], "Found a duplicate in the metrics slice: snowflake.rows_inserted.avg") + validatedMetrics["snowflake.rows_inserted.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of rows inserted into a table (or tables) over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{rows}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.rows_produced.avg": + assert.False(t, validatedMetrics["snowflake.rows_produced.avg"], "Found a duplicate in the metrics slice: snowflake.rows_produced.avg") + validatedMetrics["snowflake.rows_produced.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average number of rows produced by statement over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{rows}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.rows_unloaded.avg": + assert.False(t, validatedMetrics["snowflake.rows_unloaded.avg"], "Found a duplicate in the metrics slice: snowflake.rows_unloaded.avg") + validatedMetrics["snowflake.rows_unloaded.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average number of rows unloaded during data export over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{rows}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.rows_updated.avg": + assert.False(t, validatedMetrics["snowflake.rows_updated.avg"], "Found a duplicate in the metrics slice: snowflake.rows_updated.avg") + validatedMetrics["snowflake.rows_updated.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average number of rows updated in a table over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "{rows}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.session_id.count": + assert.False(t, validatedMetrics["snowflake.session_id.count"], "Found a duplicate in the metrics slice: snowflake.session_id.count") + validatedMetrics["snowflake.session_id.count"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Distinct session id's associated with snowflake username over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "1", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("user_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + case "snowflake.storage.failsafe_bytes.total": + assert.False(t, validatedMetrics["snowflake.storage.failsafe_bytes.total"], "Found a duplicate in the metrics slice: snowflake.storage.failsafe_bytes.total") + validatedMetrics["snowflake.storage.failsafe_bytes.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of bytes of data in Fail-safe.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "snowflake.storage.stage_bytes.total": + assert.False(t, validatedMetrics["snowflake.storage.stage_bytes.total"], "Found a duplicate in the metrics slice: snowflake.storage.stage_bytes.total") + validatedMetrics["snowflake.storage.stage_bytes.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of bytes of stage storage used by files in all internal stages (named, table, user).", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "snowflake.storage.storage_bytes.total": + assert.False(t, validatedMetrics["snowflake.storage.storage_bytes.total"], "Found a duplicate in the metrics slice: snowflake.storage.storage_bytes.total") + validatedMetrics["snowflake.storage.storage_bytes.total"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Number of bytes of table storage used, including bytes for data currently in Time Travel.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + case "snowflake.total_elapsed_time.avg": + assert.False(t, validatedMetrics["snowflake.total_elapsed_time.avg"], "Found a duplicate in the metrics slice: snowflake.total_elapsed_time.avg") + validatedMetrics["snowflake.total_elapsed_time.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average elapsed time over the last 24 hour window.", ms.At(i).Description()) + assert.Equal(t, "s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.Equal(t, float64(1), dp.DoubleValue()) + attrVal, ok := dp.Attributes().Get("schema_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("execution_status") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("error_message") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("query_type") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("database_name") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("warehouse_size") + assert.True(t, ok) + assert.EqualValues(t, "attr-val", attrVal.Str()) + } + } + }) } - assert.Equal(t, allMetricsCount, len(validatedMetrics)) } -func TestNoMetrics(t *testing.T) { - start := pcommon.Timestamp(1_000_000_000) - ts := pcommon.Timestamp(1_000_001_000) - metricsSettings := MetricsSettings{ - SnowflakeBillingCloudServiceTotal: MetricSettings{Enabled: false}, - SnowflakeBillingTotalCreditTotal: MetricSettings{Enabled: false}, - SnowflakeBillingVirtualWarehouseTotal: MetricSettings{Enabled: false}, - SnowflakeBillingWarehouseCloudServiceTotal: MetricSettings{Enabled: false}, - SnowflakeBillingWarehouseTotalCreditTotal: MetricSettings{Enabled: false}, - SnowflakeBillingWarehouseVirtualWarehouseTotal: MetricSettings{Enabled: false}, - SnowflakeDatabaseBytesScannedAvg: MetricSettings{Enabled: false}, - SnowflakeDatabaseQueryCount: MetricSettings{Enabled: false}, - SnowflakeLoginsTotal: MetricSettings{Enabled: false}, - SnowflakePipeCreditsUsedTotal: MetricSettings{Enabled: false}, - SnowflakeQueryBlocked: MetricSettings{Enabled: false}, - SnowflakeQueryBytesDeletedAvg: MetricSettings{Enabled: false}, - SnowflakeQueryBytesSpilledLocalAvg: MetricSettings{Enabled: false}, - SnowflakeQueryBytesSpilledRemoteAvg: MetricSettings{Enabled: false}, - SnowflakeQueryBytesWrittenAvg: MetricSettings{Enabled: false}, - SnowflakeQueryCompilationTimeAvg: MetricSettings{Enabled: false}, - SnowflakeQueryDataScannedCacheAvg: MetricSettings{Enabled: false}, - SnowflakeQueryExecuted: MetricSettings{Enabled: false}, - SnowflakeQueryExecutionTimeAvg: MetricSettings{Enabled: false}, - SnowflakeQueryPartitionsScannedAvg: MetricSettings{Enabled: false}, - SnowflakeQueryQueuedOverload: MetricSettings{Enabled: false}, - SnowflakeQueryQueuedProvision: MetricSettings{Enabled: false}, - SnowflakeQueuedOverloadTimeAvg: MetricSettings{Enabled: false}, - SnowflakeQueuedProvisioningTimeAvg: MetricSettings{Enabled: false}, - SnowflakeQueuedRepairTimeAvg: MetricSettings{Enabled: false}, - SnowflakeRowsDeletedAvg: MetricSettings{Enabled: false}, - SnowflakeRowsInsertedAvg: MetricSettings{Enabled: false}, - SnowflakeRowsProducedAvg: MetricSettings{Enabled: false}, - SnowflakeRowsUnloadedAvg: MetricSettings{Enabled: false}, - SnowflakeRowsUpdatedAvg: MetricSettings{Enabled: false}, - SnowflakeSessionIDCount: MetricSettings{Enabled: false}, - SnowflakeStorageFailsafeBytesTotal: MetricSettings{Enabled: false}, - SnowflakeStorageStageBytesTotal: MetricSettings{Enabled: false}, - SnowflakeStorageStorageBytesTotal: MetricSettings{Enabled: false}, - SnowflakeTotalElapsedTimeAvg: MetricSettings{Enabled: false}, - } - observedZapCore, observedLogs := observer.New(zap.WarnLevel) - settings := receivertest.NewNopCreateSettings() - settings.Logger = zap.New(observedZapCore) - mb := NewMetricsBuilder(metricsSettings, settings, WithStartTime(start)) - - assert.Equal(t, 0, observedLogs.Len()) - mb.RecordSnowflakeBillingCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingTotalCreditTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseCloudServiceTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseTotalCreditTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeBillingWarehouseVirtualWarehouseTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeDatabaseBytesScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeDatabaseQueryCountDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeLoginsTotalDataPoint(ts, 1, "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakePipeCreditsUsedTotalDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryBlockedDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryBytesDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledLocalAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesSpilledRemoteAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryBytesWrittenAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryCompilationTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryDataScannedCacheAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryExecutedDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryExecutionTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryPartitionsScannedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueryQueuedOverloadDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueryQueuedProvisionDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeQueuedOverloadTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueuedProvisioningTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeQueuedRepairTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsDeletedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsInsertedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsProducedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUnloadedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeRowsUpdatedAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - mb.RecordSnowflakeSessionIDCountDataPoint(ts, 1, "attr-val") - mb.RecordSnowflakeStorageFailsafeBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeStorageStageBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeStorageStorageBytesTotalDataPoint(ts, 1) - mb.RecordSnowflakeTotalElapsedTimeAvgDataPoint(ts, 1, "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val", "attr-val") - - metrics := mb.Emit() - - assert.Equal(t, 0, metrics.ResourceMetrics().Len()) +func loadConfig(t *testing.T, name string) MetricsSettings { + cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) + require.NoError(t, err) + sub, err := cm.Sub(name) + require.NoError(t, err) + cfg := DefaultMetricsSettings() + require.NoError(t, component.UnmarshalConfig(sub, &cfg)) + return cfg } diff --git a/receiver/snowflakereceiver/internal/metadata/testdata/config.yaml b/receiver/snowflakereceiver/internal/metadata/testdata/config.yaml new file mode 100644 index 000000000000..9cdde6c092be --- /dev/null +++ b/receiver/snowflakereceiver/internal/metadata/testdata/config.yaml @@ -0,0 +1,143 @@ +default: +all_metrics: + snowflake.billing.cloud_service.total: + enabled: true + snowflake.billing.total_credit.total: + enabled: true + snowflake.billing.virtual_warehouse.total: + enabled: true + snowflake.billing.warehouse.cloud_service.total: + enabled: true + snowflake.billing.warehouse.total_credit.total: + enabled: true + snowflake.billing.warehouse.virtual_warehouse.total: + enabled: true + snowflake.database.bytes_scanned.avg: + enabled: true + snowflake.database.query.count: + enabled: true + snowflake.logins.total: + enabled: true + snowflake.pipe.credits_used.total: + enabled: true + snowflake.query.blocked: + enabled: true + snowflake.query.bytes_deleted.avg: + enabled: true + snowflake.query.bytes_spilled.local.avg: + enabled: true + snowflake.query.bytes_spilled.remote.avg: + enabled: true + snowflake.query.bytes_written.avg: + enabled: true + snowflake.query.compilation_time.avg: + enabled: true + snowflake.query.data_scanned_cache.avg: + enabled: true + snowflake.query.executed: + enabled: true + snowflake.query.execution_time.avg: + enabled: true + snowflake.query.partitions_scanned.avg: + enabled: true + snowflake.query.queued_overload: + enabled: true + snowflake.query.queued_provision: + enabled: true + snowflake.queued_overload_time.avg: + enabled: true + snowflake.queued_provisioning_time.avg: + enabled: true + snowflake.queued_repair_time.avg: + enabled: true + snowflake.rows_deleted.avg: + enabled: true + snowflake.rows_inserted.avg: + enabled: true + snowflake.rows_produced.avg: + enabled: true + snowflake.rows_unloaded.avg: + enabled: true + snowflake.rows_updated.avg: + enabled: true + snowflake.session_id.count: + enabled: true + snowflake.storage.failsafe_bytes.total: + enabled: true + snowflake.storage.stage_bytes.total: + enabled: true + snowflake.storage.storage_bytes.total: + enabled: true + snowflake.total_elapsed_time.avg: + enabled: true +no_metrics: + snowflake.billing.cloud_service.total: + enabled: false + snowflake.billing.total_credit.total: + enabled: false + snowflake.billing.virtual_warehouse.total: + enabled: false + snowflake.billing.warehouse.cloud_service.total: + enabled: false + snowflake.billing.warehouse.total_credit.total: + enabled: false + snowflake.billing.warehouse.virtual_warehouse.total: + enabled: false + snowflake.database.bytes_scanned.avg: + enabled: false + snowflake.database.query.count: + enabled: false + snowflake.logins.total: + enabled: false + snowflake.pipe.credits_used.total: + enabled: false + snowflake.query.blocked: + enabled: false + snowflake.query.bytes_deleted.avg: + enabled: false + snowflake.query.bytes_spilled.local.avg: + enabled: false + snowflake.query.bytes_spilled.remote.avg: + enabled: false + snowflake.query.bytes_written.avg: + enabled: false + snowflake.query.compilation_time.avg: + enabled: false + snowflake.query.data_scanned_cache.avg: + enabled: false + snowflake.query.executed: + enabled: false + snowflake.query.execution_time.avg: + enabled: false + snowflake.query.partitions_scanned.avg: + enabled: false + snowflake.query.queued_overload: + enabled: false + snowflake.query.queued_provision: + enabled: false + snowflake.queued_overload_time.avg: + enabled: false + snowflake.queued_provisioning_time.avg: + enabled: false + snowflake.queued_repair_time.avg: + enabled: false + snowflake.rows_deleted.avg: + enabled: false + snowflake.rows_inserted.avg: + enabled: false + snowflake.rows_produced.avg: + enabled: false + snowflake.rows_unloaded.avg: + enabled: false + snowflake.rows_updated.avg: + enabled: false + snowflake.session_id.count: + enabled: false + snowflake.storage.failsafe_bytes.total: + enabled: false + snowflake.storage.stage_bytes.total: + enabled: false + snowflake.storage.storage_bytes.total: + enabled: false + snowflake.total_elapsed_time.avg: + enabled: false