Skip to content

Commit 90753a0

Browse files
authored
Merge pull request #951 from wiktork/dev/wiktork/mergemain
2 parents f012f09 + 2ecb1db commit 90753a0

32 files changed

+217
-191
lines changed

documentation/openapi.json

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,6 @@
385385
"default": 30
386386
}
387387
},
388-
{
389-
"name": "metricsIntervalSeconds",
390-
"in": "query",
391-
"description": "The reporting interval (in seconds) for event counters.",
392-
"schema": {
393-
"maximum": 2147483647,
394-
"minimum": 1,
395-
"type": "integer",
396-
"description": "The reporting interval (in seconds) for event counters.",
397-
"format": "int32",
398-
"default": 1
399-
}
400-
},
401388
{
402389
"name": "egressProvider",
403390
"in": "query",
@@ -852,19 +839,6 @@
852839
"default": 30
853840
}
854841
},
855-
{
856-
"name": "metricsIntervalSeconds",
857-
"in": "query",
858-
"description": "The reporting interval (in seconds) for event counters.",
859-
"schema": {
860-
"maximum": 2147483647,
861-
"minimum": 1,
862-
"type": "integer",
863-
"description": "The reporting interval (in seconds) for event counters.",
864-
"format": "int32",
865-
"default": 5
866-
}
867-
},
868842
{
869843
"name": "egressProvider",
870844
"in": "query",
@@ -943,19 +917,6 @@
943917
"default": 30
944918
}
945919
},
946-
{
947-
"name": "metricsIntervalSeconds",
948-
"in": "query",
949-
"description": "The reporting interval (in seconds) for event counters.",
950-
"schema": {
951-
"maximum": 2147483647,
952-
"minimum": 1,
953-
"type": "integer",
954-
"description": "The reporting interval (in seconds) for event counters.",
955-
"format": "int32",
956-
"default": 5
957-
}
958-
},
959920
{
960921
"name": "egressProvider",
961922
"in": "query",

documentation/schema.json

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@
3737
"$ref": "#/definitions/CollectionRuleOptions"
3838
}
3939
},
40+
"GlobalCounter": {
41+
"default": {},
42+
"oneOf": [
43+
{
44+
"type": "null"
45+
},
46+
{
47+
"$ref": "#/definitions/GlobalCounterOptions"
48+
}
49+
]
50+
},
4051
"CorsConfiguration": {
4152
"default": {},
4253
"oneOf": [
@@ -723,6 +734,23 @@
723734
}
724735
}
725736
},
737+
"GlobalCounterOptions": {
738+
"type": "object",
739+
"additionalProperties": false,
740+
"properties": {
741+
"IntervalSeconds": {
742+
"type": [
743+
"integer",
744+
"null"
745+
],
746+
"description": "Determines the metrics interval for all dotnet-monitor scenarios. This includes prometheus metrics, live metrics, triggers, and traces.",
747+
"format": "int32",
748+
"default": 5,
749+
"maximum": 86400.0,
750+
"minimum": 1.0
751+
}
752+
}
753+
},
726754
"CorsConfigurationOptions": {
727755
"type": "object",
728756
"additionalProperties": false,
@@ -933,15 +961,6 @@
933961
],
934962
"description": "Endpoints that expose prometheus metrics. Defaults to http://localhost:52325."
935963
},
936-
"UpdateIntervalSeconds": {
937-
"type": [
938-
"integer",
939-
"null"
940-
],
941-
"description": "How often metrics are collected.",
942-
"format": "int32",
943-
"default": 10
944-
},
945964
"MetricCount": {
946965
"type": [
947966
"integer",
@@ -1168,17 +1187,6 @@
11681187
}
11691188
]
11701189
},
1171-
"MetricsIntervalSeconds": {
1172-
"type": [
1173-
"integer",
1174-
"null"
1175-
],
1176-
"description": "The amount of time (in seconds) between the collection of each sample of the counter. Only applicable when Profile contains Metrics.",
1177-
"format": "int32",
1178-
"default": 1,
1179-
"maximum": 86400.0,
1180-
"minimum": 1.0
1181-
},
11821190
"Providers": {
11831191
"type": [
11841192
"array",
@@ -1520,17 +1528,6 @@
15201528
"description": "The sliding time window in which the counter must maintain its value as specified by the threshold levels in GreaterThan and LessThan.",
15211529
"format": "time-span",
15221530
"default": "00:01:00"
1523-
},
1524-
"Frequency": {
1525-
"type": [
1526-
"integer",
1527-
"null"
1528-
],
1529-
"description": "The amount of time (in seconds) between the collection of each sample of the counter.",
1530-
"format": "int32",
1531-
"default": 5,
1532-
"maximum": 86400.0,
1533-
"minimum": 1.0
15341531
}
15351532
}
15361533
},
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.ComponentModel;
8+
using System.ComponentModel.DataAnnotations;
9+
using System.Text;
10+
11+
namespace Microsoft.Diagnostics.Monitoring.WebApi
12+
{
13+
public class GlobalCounterOptions
14+
{
15+
public const int IntervalMinSeconds = 1;
16+
public const int IntervalMaxSeconds = 60 * 60 * 24; // One day
17+
18+
[Display(
19+
ResourceType = typeof(OptionsDisplayStrings),
20+
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_GlobalCounterOptions_IntervalSeconds))]
21+
[Range(IntervalMinSeconds, IntervalMaxSeconds)]
22+
[DefaultValue(GlobalCounterOptionsDefaults.IntervalSeconds)]
23+
public int? IntervalSeconds { get; set; }
24+
}
25+
26+
internal static class GlobalCounterOptionsExtensions
27+
{
28+
public static int GetIntervalSeconds(this GlobalCounterOptions options) =>
29+
options.IntervalSeconds.GetValueOrDefault(GlobalCounterOptionsDefaults.IntervalSeconds);
30+
}
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace Microsoft.Diagnostics.Monitoring.WebApi
10+
{
11+
internal static class GlobalCounterOptionsDefaults
12+
{
13+
public const int IntervalSeconds = 5;
14+
}
15+
}

src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ public class MetricsOptions
2727
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_MetricsOptions_Endpoints))]
2828
public string Endpoints { get; set; }
2929

30-
[Display(
31-
ResourceType = typeof(OptionsDisplayStrings),
32-
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_MetricsOptions_UpdateIntervalSeconds))]
33-
[DefaultValue(MetricsOptionsDefaults.UpdateIntervalSeconds)]
34-
public int? UpdateIntervalSeconds { get; set; }
35-
3630
[Display(
3731
ResourceType = typeof(OptionsDisplayStrings),
3832
Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_MetricsOptions_MetricCount))]

src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptionsDefaults.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ internal class MetricsOptionsDefaults
88
{
99
public const bool Enabled = true;
1010

11-
public const int UpdateIntervalSeconds = 10;
12-
1311
public const int MetricCount = 3;
1412

1513
public const bool IncludeDefaultProviders = true;

src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs

Lines changed: 9 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@
289289
<value>The name of the egress provider to which the trace is egressed.</value>
290290
<comment>The description provided for the Egress parameter on CollectTraceOptions.</comment>
291291
</data>
292-
<data name="DisplayAttributeDescription_CollectTraceOptions_MetricsIntervalSeconds" xml:space="preserve">
293-
<value>The amount of time (in seconds) between the collection of each sample of the counter. Only applicable when Profile contains Metrics.</value>
294-
<comment>The description provided for the MetricsIntervalSeconds parameter on CollectTraceOptions.</comment>
295-
</data>
296292
<data name="DisplayAttributeDescription_CollectTraceOptions_Profile" xml:space="preserve">
297293
<value>Use a predefined set of event providers and settings to capture in the trace. More than one profile may be specified at the same time. Either Profile or Providers must be specified, but not both.</value>
298294
<comment>The description provided for the Profile parameter on CollectTraceOptions.</comment>
@@ -385,10 +381,6 @@
385381
<value>The name of the counter to monitor.</value>
386382
<comment>The description provided for the CounterName parameter on EventCounterOptions.</comment>
387383
</data>
388-
<data name="DisplayAttributeDescription_EventCounterOptions_Frequency" xml:space="preserve">
389-
<value>The amount of time (in seconds) between the collection of each sample of the counter.</value>
390-
<comment>The description provided for the Frequency parameter on EventCounterOptions.</comment>
391-
</data>
392384
<data name="DisplayAttributeDescription_EventCounterOptions_GreaterThan" xml:space="preserve">
393385
<value>The threshold level the counter must maintain (or higher) for the specified duration. Either GreaterThan or LessThan (or both) must be specified.</value>
394386
<comment>The description provided for the GreaterThan parameter on EventCounterOptions.</comment>
@@ -481,10 +473,6 @@
481473
<value>Providers for custom metrics.</value>
482474
<comment>The description provided for the Providers parameter on MetricsOptions.</comment>
483475
</data>
484-
<data name="DisplayAttributeDescription_MetricsOptions_UpdateIntervalSeconds" xml:space="preserve">
485-
<value>How often metrics are collected.</value>
486-
<comment>The description provided for the UpdateIntervalSeconds parameter on MetricsOptions.</comment>
487-
</data>
488476
<data name="DisplayAttributeDescription_MonitorApiKeyOptions_PublicKey" xml:space="preserve">
489477
<value>The public key used to sign the JWT (JSON Web Token) used for authentication. This field is a JSON Web Key serialized as JSON encoded with base64Url encoding. The JWK must have a kty field of RSA or EC and should not have the private key information.</value>
490478
<comment>The description provided for the PublicKey parameter on MonitorApiKeyOptions.</comment>
@@ -556,4 +544,7 @@
556544
<value>Wait for the current action to complete before starting the next action.</value>
557545
<comment>The description provided for the WaitForCompletion parameter on CollectionRuleActionOptions.</comment>
558546
</data>
547+
<data name="DisplayAttributeDescription_GlobalCounterOptions_IntervalSeconds" xml:space="preserve">
548+
<value>Determines the metrics interval for all dotnet-monitor scenarios. This includes prometheus metrics, live metrics, triggers, and traces.</value>
549+
</data>
559550
</root>

src/Microsoft.Diagnostics.Monitoring.WebApi/Controllers/DiagController.Metrics.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ partial class DiagController
2828
/// <param name="uid">The Runtime instance cookie used to identify the target process.</param>
2929
/// <param name="name">Process name used to identify the target process.</param>
3030
/// <param name="durationSeconds">The duration of the metrics session (in seconds).</param>
31-
/// <param name="metricsIntervalSeconds">The reporting interval (in seconds) for event counters.</param>
3231
/// <param name="egressProvider">The egress provider to which the metrics are saved.</param>
3332
[HttpGet("livemetrics", Name = nameof(CaptureMetrics))]
3433
[ProducesWithProblemDetails(ContentTypes.ApplicationJsonSequence)]
@@ -45,8 +44,6 @@ public Task<ActionResult> CaptureMetrics(
4544
string name = null,
4645
[FromQuery][Range(-1, int.MaxValue)]
4746
int durationSeconds = 30,
48-
[FromQuery][Range(1, int.MaxValue)]
49-
int metricsIntervalSeconds = 5,
5047
[FromQuery]
5148
string egressProvider = null)
5249
{
@@ -60,9 +57,9 @@ public Task<ActionResult> CaptureMetrics(
6057
{
6158
var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);
6259
EventPipeCounterPipelineSettings settings = EventCounterSettingsFactory.CreateSettings(
60+
_counterOptions.CurrentValue,
6361
includeDefaults: true,
64-
durationSeconds: durationSeconds,
65-
refreshInterval: metricsIntervalSeconds);
62+
durationSeconds: durationSeconds);
6663

6764
await using EventCounterPipeline eventCounterPipeline = new EventCounterPipeline(client,
6865
settings,
@@ -89,7 +86,6 @@ public Task<ActionResult> CaptureMetrics(
8986
/// <param name="uid">The Runtime instance cookie used to identify the target process.</param>
9087
/// <param name="name">Process name used to identify the target process.</param>
9188
/// <param name="durationSeconds">The duration of the metrics session (in seconds).</param>
92-
/// <param name="metricsIntervalSeconds">The reporting interval (in seconds) for event counters.</param>
9389
/// <param name="egressProvider">The egress provider to which the metrics are saved.</param>
9490
[HttpPost("livemetrics", Name = nameof(CaptureMetricsCustom))]
9591
[ProducesWithProblemDetails(ContentTypes.ApplicationJsonSequence)]
@@ -108,8 +104,6 @@ public Task<ActionResult> CaptureMetricsCustom(
108104
string name = null,
109105
[FromQuery][Range(-1, int.MaxValue)]
110106
int durationSeconds = 30,
111-
[FromQuery][Range(1, int.MaxValue)]
112-
int metricsIntervalSeconds = 5,
113107
[FromQuery]
114108
string egressProvider = null)
115109
{
@@ -123,8 +117,8 @@ public Task<ActionResult> CaptureMetricsCustom(
123117
{
124118
var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);
125119
EventPipeCounterPipelineSettings settings = EventCounterSettingsFactory.CreateSettings(
120+
_counterOptions.CurrentValue,
126121
durationSeconds,
127-
metricsIntervalSeconds,
128122
configuration);
129123

130124
await using EventCounterPipeline eventCounterPipeline = new EventCounterPipeline(client,

0 commit comments

Comments
 (0)