Skip to content

Commit

Permalink
fix histogram for SDK tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Jul 18, 2023
1 parent 3e61f03 commit c1b5e34
Show file tree
Hide file tree
Showing 3 changed files with 799 additions and 8 deletions.
31 changes: 25 additions & 6 deletions exporter/collector/integrationtest/testcases/testcases_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var MetricsTestCases = []TestCase{
cfg.MetricConfig.InstrumentationLibraryLabels = true
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Delta Counter",
Expand All @@ -47,6 +48,7 @@ var MetricsTestCases = []TestCase{
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Non-monotonic Counter",
Expand All @@ -55,6 +57,7 @@ var MetricsTestCases = []TestCase{
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Summary",
Expand All @@ -74,6 +77,7 @@ var MetricsTestCases = []TestCase{
cfg.MetricConfig.InstrumentationLibraryLabels = true
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Boolean valued Gauge metrics becomes an int Gauge",
Expand All @@ -100,8 +104,8 @@ var MetricsTestCases = []TestCase{
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.ServiceResourceLabels = false
cfg.MetricConfig.InstrumentationLibraryLabels = true
cfg.MetricConfig.EnableSumOfSquaredDeviation = true
},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Exponential Histogram",
Expand All @@ -127,6 +131,17 @@ var MetricsTestCases = []TestCase{
SkipForSDK: true,
},
// Tests with special configuration options
{
Name: "Histogram with SumOfSquaredDeviation",
OTLPInputFixturePath: "testdata/fixtures/metrics/histogram.json",
ExpectFixturePath: "testdata/fixtures/metrics/histogram_sosd_expect.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.ServiceResourceLabels = false
cfg.MetricConfig.InstrumentationLibraryLabels = true
cfg.MetricConfig.EnableSumOfSquaredDeviation = true
},
SkipForSDK: true,
},
{
Name: "Project not found return code",
OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json",
Expand All @@ -135,7 +150,7 @@ var MetricsTestCases = []TestCase{
cfg.ProjectID = "notfoundproject"
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithProjectID("notfoundproject")},
MetricSDKExporterOptions: []metric.Option{metric.WithProjectID("notfoundproject"), metric.WithFilteredResourceAttributes(metric.NoAttributes)},
ExpectErr: true,
},
{
Expand All @@ -146,9 +161,12 @@ var MetricsTestCases = []TestCase{
cfg.MetricConfig.Prefix = "custom.googleapis.com/foobar.org"
cfg.MetricConfig.ServiceResourceLabels = false
},
MetricSDKExporterOptions: []metric.Option{metric.WithMetricDescriptorTypeFormatter(func(m metricdata.Metrics) string {
return "custom.googleapis.com/foobar.org/" + m.Name
})},
MetricSDKExporterOptions: []metric.Option{
metric.WithMetricDescriptorTypeFormatter(func(m metricdata.Metrics) string {
return "custom.googleapis.com/foobar.org/" + m.Name
}),
metric.WithFilteredResourceAttributes(metric.NoAttributes),
},
},
{
Name: "Modified prefix workload.googleapis.com",
Expand All @@ -157,8 +175,8 @@ var MetricsTestCases = []TestCase{
ConfigureCollector: func(cfg *collector.Config) {
cfg.MetricConfig.Prefix = "workload.googleapis.com"
cfg.MetricConfig.ServiceResourceLabels = false

},
MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)},
},
{
Name: "Batching only sends 200 timeseries per-batch",
Expand Down Expand Up @@ -208,6 +226,7 @@ var MetricsTestCases = []TestCase{
cfg.MetricConfig.ClientConfig.Compression = "gzip"
cfg.MetricConfig.ServiceResourceLabels = false
},
SkipForSDK: true,
},
{
Name: "CreateServiceTimeSeries option enabled",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"distributionValue": {
"count": "1",
"mean": 2,
"sumOfSquaredDeviation": 2.25,
"bucketOptions": {
"explicitBuckets": {
"bounds": [
Expand Down Expand Up @@ -87,7 +86,6 @@
"distributionValue": {
"count": "2",
"mean": 7,
"sumOfSquaredDeviation": 76.25,
"bucketOptions": {
"explicitBuckets": {
"bounds": [
Expand Down
Loading

0 comments on commit c1b5e34

Please sign in to comment.