Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize metric integration tests #674

Merged
merged 17 commits into from
Jul 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 20 additions & 35 deletions exporter/collector/integrationtest/testcases/testcases_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,7 @@ var MetricsTestCases = []TestCase{
Name: "Google Managed Prometheus",
OTLPInputFixturePath: "testdata/fixtures/metrics/google_managed_prometheus.json",
ExpectFixturePath: "testdata/fixtures/metrics/google_managed_prometheus_expect.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.Prefix = "prometheus.googleapis.com/"
cfg.MetricConfig.SkipCreateMetricDescriptor = true
cfg.MetricConfig.GetMetricName = googlemanagedprometheus.GetMetricName
cfg.MetricConfig.MapMonitoredResource = googlemanagedprometheus.MapToPrometheusTarget
cfg.MetricConfig.ExtraMetrics = func(m pmetric.Metrics) pmetric.ResourceMetricsSlice {
// This should not add any change without the featuregate enabled (from Ops Agent)
googlemanagedprometheus.AddUntypedMetrics(m)
googlemanagedprometheus.AddScopeInfoMetric(m)
googlemanagedprometheus.AddTargetInfoMetric(m)
return m.ResourceMetrics()
}
cfg.MetricConfig.InstrumentationLibraryLabels = false
cfg.MetricConfig.ServiceResourceLabels = false
cfg.MetricConfig.EnableSumOfSquaredDeviation = true
},
ConfigureCollector: configureGMPCollector,
// prometheus_target is not supported by the SDK
SkipForSDK: true,
},
Expand All @@ -178,25 +163,8 @@ var MetricsTestCases = []TestCase{
OTLPInputFixturePath: "testdata/fixtures/metrics/google_managed_prometheus.json",
ExpectFixturePath: "testdata/fixtures/metrics/google_managed_prometheus_untyped_expect.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.Prefix = "prometheus.googleapis.com/"
cfg.MetricConfig.SkipCreateMetricDescriptor = true
cfg.MetricConfig.GetMetricName = googlemanagedprometheus.GetMetricName
cfg.MetricConfig.MapMonitoredResource = googlemanagedprometheus.MapToPrometheusTarget
cfg.MetricConfig.ExtraMetrics = func(m pmetric.Metrics) pmetric.ResourceMetricsSlice {
//nolint:errcheck
featuregate.GlobalRegistry().Set("gcp.untyped_double_export", true)
googlemanagedprometheus.AddUntypedMetrics(m)
googlemanagedprometheus.AddScopeInfoMetric(m)
googlemanagedprometheus.AddTargetInfoMetric(m)
return m.ResourceMetrics()
}
cfg.MetricConfig.InstrumentationLibraryLabels = false
cfg.MetricConfig.ServiceResourceLabels = false
cfg.MetricConfig.EnableSumOfSquaredDeviation = true
// disable cumulative normalization so we can see the counter without having to send 2 data points.
// with normalization enabled, the first data point would get dropped.
// but trying to send 2 data points causes the GCM integration test to fail for duplicate timeseries.
cfg.MetricConfig.CumulativeNormalization = false
configureGMPCollector(cfg)
featuregate.GlobalRegistry().Set("gcp.untyped_double_export", true)
},
// prometheus_target is not supported by the SDK
SkipForSDK: true,
Expand Down Expand Up @@ -399,3 +367,20 @@ var MetricsTestCases = []TestCase{
},
// TODO: Add integration tests for workload.googleapis.com metrics from the ops agent
}

func configureGMPCollector(cfg *collector.Config) {
dashpole marked this conversation as resolved.
Show resolved Hide resolved
cfg.MetricConfig.Prefix = "prometheus.googleapis.com/"
cfg.MetricConfig.SkipCreateMetricDescriptor = true
cfg.MetricConfig.GetMetricName = googlemanagedprometheus.GetMetricName
cfg.MetricConfig.MapMonitoredResource = googlemanagedprometheus.MapToPrometheusTarget
cfg.MetricConfig.ExtraMetrics = func(m pmetric.Metrics) pmetric.ResourceMetricsSlice {
// This should not add any change without the featuregate enabled (from Ops Agent)
googlemanagedprometheus.AddUntypedMetrics(m)
googlemanagedprometheus.AddScopeInfoMetric(m)
googlemanagedprometheus.AddTargetInfoMetric(m)
return m.ResourceMetrics()
}
cfg.MetricConfig.InstrumentationLibraryLabels = false
cfg.MetricConfig.ServiceResourceLabels = false
cfg.MetricConfig.EnableSumOfSquaredDeviation = true
}