-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Xunit; | ||
|
||
namespace OpenTelemetry.Metrics.Tests; | ||
|
||
public class MetricTestData | ||
{ | ||
public static IEnumerable<object[]> InvalidInstrumentNames | ||
=> new List<object[]> | ||
{ | ||
new object[] { " " }, | ||
new object[] { "-first-char-not-alphabetic" }, | ||
new object[] { "1first-char-not-alphabetic" }, | ||
new object[] { "invalid+separator" }, | ||
new object[] { new string('m', 256) }, | ||
new object[] { "a\xb5" }, // `\xb5` is the Micro character | ||
}; | ||
public static TheoryData<string> InvalidInstrumentNames | ||
=> | ||
[ | ||
" ", | ||
"-first-char-not-alphabetic", | ||
"1first-char-not-alphabetic", | ||
"invalid+separator", | ||
new('m', 256), | ||
"a\xb5", // `\xb5` is the Micro character | ||
]; | ||
|
||
public static IEnumerable<object[]> ValidInstrumentNames | ||
=> new List<object[]> | ||
{ | ||
new object[] { "m" }, | ||
new object[] { "first-char-alphabetic" }, | ||
new object[] { "my-2-instrument" }, | ||
new object[] { "my.metric" }, | ||
new object[] { "my_metric2" }, | ||
new object[] { new string('m', 255) }, | ||
new object[] { "CaSe-InSeNsItIvE" }, | ||
new object[] { "my_metric/environment/database" }, | ||
}; | ||
public static TheoryData<string> ValidInstrumentNames | ||
=> | ||
[ | ||
"m", | ||
"first-char-alphabetic", | ||
"my-2-instrument", | ||
"my.metric", | ||
"my_metric2", | ||
new('m', 255), | ||
"CaSe-InSeNsItIvE", | ||
"my_metric/environment/database", | ||
]; | ||
|
||
public static IEnumerable<object[]> InvalidHistogramBoundaries | ||
=> new List<object[]> | ||
{ | ||
new object[] { new double[] { 0, 0 } }, | ||
new object[] { new double[] { 1, 0 } }, | ||
new object[] { new double[] { 0, 1, 1, 2 } }, | ||
new object[] { new double[] { 0, 1, 2, -1 } }, | ||
}; | ||
public static TheoryData<double[]> InvalidHistogramBoundaries | ||
=> | ||
[ | ||
[0.0, 0.0], | ||
[1.0, 0.0], | ||
[0.0, 1.0, 1.0, 2.0], | ||
[0.0, 1.0, 2.0, -1.0], | ||
]; | ||
|
||
public static IEnumerable<object[]> ValidHistogramMinMax | ||
=> new List<object[]> | ||
{ | ||
new object[] { new double[] { -10, 0, 1, 9, 10, 11, 19 }, new HistogramConfiguration(), -10, 19 }, | ||
new object[] { new double[] { double.NegativeInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity }, | ||
new object[] { new double[] { double.NegativeInfinity, 0, double.PositiveInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity }, | ||
new object[] { new double[] { 1 }, new HistogramConfiguration(), 1, 1 }, | ||
new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] }, -2, 101 }, | ||
new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new Base2ExponentialBucketHistogramConfiguration(), 4, 101 }, | ||
}; | ||
public static TheoryData<double[], HistogramConfiguration, double, double> ValidHistogramMinMax => | ||
new() | ||
{ | ||
{ [-10.0, 0.0, 1.0, 9.0, 10.0, 11.0, 19.0], new HistogramConfiguration(), -10.0, 19.0 }, | ||
{ [double.NegativeInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity }, | ||
{ [double.NegativeInfinity, 0.0, double.PositiveInfinity], new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity }, | ||
{ [1.0], new HistogramConfiguration(), 1.0, 1.0 }, | ||
{ [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0] }, -2.0, 101.0 }, | ||
{ [5.0, 100.0, 4.0, 101.0, -2.0, 97.0], new Base2ExponentialBucketHistogramConfiguration(), 4.0, 101.0 }, | ||
}; | ||
|
||
public static IEnumerable<object[]> InvalidHistogramMinMax | ||
=> new List<object[]> | ||
public static TheoryData<double[], HistogramConfiguration> InvalidHistogramMinMax | ||
=> new() | ||
{ | ||
new object[] { new double[] { 1 }, new HistogramConfiguration() { RecordMinMax = false } }, | ||
new object[] { new double[] { 1 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], RecordMinMax = false } }, | ||
new object[] { new double[] { 1 }, new Base2ExponentialBucketHistogramConfiguration() { RecordMinMax = false } }, | ||
{ [1.0], new HistogramConfiguration { RecordMinMax = false } }, | ||
{ [1.0], new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0], RecordMinMax = false } }, | ||
{ [1.0], new Base2ExponentialBucketHistogramConfiguration { RecordMinMax = false } }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters