Skip to content

Commit 4eace0f

Browse files
authored
Merge pull request #1 from MhouneyLH/feat/nbomber_prefix
Feat/nbomber prefix
2 parents 3242bde + 1378418 commit 4eace0f

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ NBomberRunner
107107

108108
For more code samples and examples, please refer to the [samples](samples) directory.
109109

110+
## Known Issues & Limitations
111+
112+
When using Rider and want or any other ide and try to start with a "green play button" it will not work when using `LoadInfraConfig`, please create Program.cs with Main method and run from terminal using `dotnet run`
113+
114+
The export interval is currently fixed to the OtelExporter default of `60` seconds and cannot be changed via configuration (the only thing that can be changed is the reporting interval in NBomber using `WithReportingInterval` which is independent from the export interval)
115+
110116
## Contributing
111117

112118
Contributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request. Happy coding! 🎉

src/NBomber.Sinks.Otel/AppDiagnostics.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@ namespace NBomber.Sinks.Otel;
66

77
internal static class AppDiagnostics
88
{
9+
private const string MetricPrefix = "nbomber_";
10+
11+
private static string PrefixMetric(string name) => $"{MetricPrefix}{name}";
12+
913
internal static readonly string AssemblyVersion =
1014
typeof(AppDiagnostics).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
1115
?? typeof(AppDiagnostics).Assembly.GetName().Version!.ToString();
1216

1317
internal static readonly Meter Meter = new("NBomber.Sinks.Otel", AssemblyVersion);
1418

15-
internal static readonly SynchronousGauge<int> NodeCount = new(Meter, "cluster.node_count", description: "Number of nodes involved in the test run");
16-
internal static readonly SynchronousGauge<int> CpuCount = new(Meter, "cluster.node_cpu_count", description: "Number of CPU cores involved in the test run");
19+
internal static readonly SynchronousGauge<int> NodeCount = new(Meter, PrefixMetric("cluster.node_count"), description: "Number of nodes involved in the test run");
20+
internal static readonly SynchronousGauge<int> CpuCount = new(Meter, PrefixMetric("cluster.node_cpu_count"), description: "Number of CPU cores involved in the test run");
1721

18-
internal static readonly Histogram<double> SuccessfulRequestLatency = Meter.CreateHistogram<double>("ok.request.latency", description: "Latency for successful requests", unit: "ms");
19-
internal static readonly Histogram<double> FailedRequestLatency = Meter.CreateHistogram<double>("fail.request.latency", description: "Latency for failed requests", unit: "ms");
22+
internal static readonly Histogram<double> SuccessfulRequestLatency = Meter.CreateHistogram<double>(PrefixMetric("ok.request.latency"), description: "Latency for successful requests", unit: "ms");
23+
internal static readonly Histogram<double> FailedRequestLatency = Meter.CreateHistogram<double>(PrefixMetric("fail.request.latency"), description: "Latency for failed requests", unit: "ms");
2024

2125
internal static void SetUsersCount(double value, params KeyValuePair<string, object?>[]? tags)
2226
{
2327
const string name = "users.count";
2428

25-
Gauge(name, null, null, value, tags);
29+
Gauge(PrefixMetric(name), null, null, value, tags);
2630
}
2731

2832
internal static void SetTotalRps(double value, params KeyValuePair<string, object?>[]? tags)
@@ -31,7 +35,7 @@ internal static void SetTotalRps(double value, params KeyValuePair<string, objec
3135
const string unit = "req/s";
3236
const string description = "Number of requests per second for the step";
3337

34-
Gauge(name, unit, description, value, tags);
38+
Gauge(PrefixMetric(name), unit, description, value, tags);
3539
}
3640

3741
internal static void SetSuccessfulRps(double value, params KeyValuePair<string, object?>[]? tags)
@@ -40,7 +44,7 @@ internal static void SetSuccessfulRps(double value, params KeyValuePair<string,
4044
const string unit = "req/s";
4145
const string description = "Number of successful requests per second for the step";
4246

43-
Gauge(name, unit, description, value, tags);
47+
Gauge(PrefixMetric(name), unit, description, value, tags);
4448
}
4549

4650
internal static void SetFailedRps(double value, params KeyValuePair<string, object?>[]? tags)
@@ -49,28 +53,28 @@ internal static void SetFailedRps(double value, params KeyValuePair<string, obje
4953
const string unit = "req/s";
5054
const string description = "Number of failed requests per second for a step";
5155

52-
Gauge(name, unit, description, value, tags);
56+
Gauge(PrefixMetric(name), unit, description, value, tags);
5357
}
5458

5559
internal static void SetTotalRequestsCount(double value, params KeyValuePair<string, object?>[]? tags)
5660
{
5761
const string name = "all.request.count";
5862

59-
Gauge(name, null, null, value, tags);
63+
Gauge(PrefixMetric(name), null, null, value, tags);
6064
}
6165

6266
internal static void SetSuccessfulRequestsCount(double value, KeyValuePair<string, object?>[] tags)
6367
{
6468
const string name = "ok.request.count";
6569

66-
Gauge(name, null, null, value, tags);
70+
Gauge(PrefixMetric(name), null, null, value, tags);
6771
}
6872

6973
internal static void SetFailedRequestsCount(double value, KeyValuePair<string, object?>[] tags)
7074
{
7175
const string name = "fail.request.count";
7276

73-
Gauge(name, null, null, value, tags);
77+
Gauge(PrefixMetric(name), null, null, value, tags);
7478
}
7579

7680

src/NBomber.Sinks.Otel/FileExporter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public override ExportResult Export(in Batch<Metric> batch)
5353
sb.Append($"Gauge: {dataPoint.GetGaugeLastValueDouble()} | ");
5454
break;
5555
case MetricType.Histogram:
56-
var histogram = dataPoint.GetHistogramBuckets();
5756
sb.Append($"Histogram - Count: {dataPoint.GetHistogramCount()}, Sum: {dataPoint.GetHistogramSum()} | ");
5857
break;
5958
default:

0 commit comments

Comments
 (0)