Skip to content

Commit 0ed0c08

Browse files
github-actions[bot]github-actions
andauthored
sync branch with origin/main (#3572)
Co-authored-by: github-actions <[email protected]>
1 parent 8c1732d commit 0ed0c08

File tree

8 files changed

+271
-3
lines changed

8 files changed

+271
-3
lines changed

.github/dependabot.template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ updates:
99
schedule:
1010
interval: "daily"
1111
target-branch: "main"
12-
#@ for branch in ["main", "release/7.x", "release/7.0", "release/6.x"]:
12+
#@ for branch in ["main", "release/8.x", "release/7.x", "release/7.0", "release/6.x"]:
1313
- package-ecosystem: "nuget"
1414
directory: "/eng/dependabot"
1515
schedule:

.github/dependabot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,47 @@ updates:
4646
- dependency-name: '*'
4747
update-types:
4848
- version-update:semver-major
49+
- package-ecosystem: nuget
50+
directory: /eng/dependabot
51+
schedule:
52+
interval: daily
53+
target-branch: release/8.x
54+
ignore:
55+
- dependency-name: Microsoft.Extensions.*
56+
update-types:
57+
- version-update:semver-major
58+
- package-ecosystem: nuget
59+
directory: /eng/dependabot/nuget.org
60+
schedule:
61+
interval: daily
62+
target-branch: release/8.x
63+
- package-ecosystem: nuget
64+
directory: /eng/dependabot/net7.0
65+
schedule:
66+
interval: daily
67+
target-branch: release/8.x
68+
ignore:
69+
- dependency-name: '*'
70+
update-types:
71+
- version-update:semver-major
72+
- package-ecosystem: nuget
73+
directory: /eng/dependabot/net6.0
74+
schedule:
75+
interval: daily
76+
target-branch: release/8.x
77+
ignore:
78+
- dependency-name: '*'
79+
update-types:
80+
- version-update:semver-major
81+
- package-ecosystem: nuget
82+
directory: /eng/dependabot/netcoreapp3.1
83+
schedule:
84+
interval: daily
85+
target-branch: release/8.x
86+
ignore:
87+
- dependency-name: '*'
88+
update-types:
89+
- version-update:semver-major
4990
- package-ecosystem: nuget
5091
directory: /eng/dependabot
5192
schedule:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
on:
2+
release:
3+
types: [released]
4+
5+
permissions:
6+
contents: write
7+
8+
env:
9+
shipping_branch_prefix: 'shipped'
10+
11+
jobs:
12+
update-shipping-branch:
13+
if: github.repository == 'dotnet/dotnet-monitor'
14+
name: '[${{ github.ref_name }}] Update shipping branch'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Update shipping branch
22+
run: |
23+
release_version=${GITHUB_REF_NAME%-*}
24+
if [[ ! "$release_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
25+
echo "Unexpected release tag: $release_version."
26+
exit 1
27+
fi
28+
29+
major_minor_version=${release_version%.*}
30+
shipping_branch_name="${{ env.shipping_branch_prefix }}/$major_minor_version"
31+
32+
# This is a shallow clone so we will always create a new local branch even if it already exists on the remote
33+
git checkout -b "$shipping_branch_name"
34+
git push --force --set-upstream origin "HEAD:$shipping_branch_name"

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"openapi",
6363
"Pids",
6464
"PKCS",
65+
"quantile",
6566
"rclsid",
6667
"reentrancy",
6768
"REFCLSID",

documentation/api/livemetrics-custom.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ The expected content type is `application/json`.
6060
6161
## Examples
6262

63-
### Sample Request
63+
### EventCounter
64+
65+
#### Sample Request
6466

6567
```http
6668
POST /livemetrics?pid=21632&durationSeconds=60 HTTP/1.1
@@ -81,7 +83,7 @@ Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff=
8183
}
8284
```
8385

84-
### Sample Response
86+
#### Sample Response
8587

8688
```http
8789
HTTP/1.1 200 OK
@@ -113,6 +115,50 @@ Location: localhost:52323/operations/67f07e40-5cca-4709-9062-26302c484f18
113115
}
114116
```
115117

118+
### System.Diagnostics.Metrics
119+
120+
#### Sample Request
121+
122+
```http
123+
GET /livemetrics?pid=21632&durationSeconds=60 HTTP/1.1
124+
Host: localhost:52323
125+
Authorization: Bearer fffffffffffffffffffffffffffffffffffffffffff=
126+
127+
{
128+
"includeDefaultProviders": false,
129+
"providers": [
130+
{
131+
"providerName": "CustomProvider",
132+
"counterNames": [
133+
"myHistogram"
134+
]
135+
}
136+
]
137+
}
138+
```
139+
140+
#### Sample Histogram Response
141+
142+
```http
143+
HTTP/1.1 200 OK
144+
Content-Type: application/json-seq
145+
Location: localhost:52323/operations/67f07e40-5cca-4709-9062-26302c484f18
146+
147+
{
148+
"timestamp": "2021-08-31T16:58:39.7514031+00:00",
149+
"provider": "CustomProvider",
150+
"name": "myHistogram",
151+
"displayName": "myHistogram",
152+
"unit": null,
153+
"counterType": "Metric",
154+
"value": {
155+
"0.5": 2892,
156+
"0.95": 4848,
157+
"0.99": 4984
158+
}
159+
}
160+
```
161+
116162
## Supported Runtimes
117163

118164
| Operating System | Runtime Version |

documentation/configuration/metrics-configuration.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,72 @@ When `CounterNames` are not specified, all the counters associated with the `Pro
168168

169169
[7.1+] Custom metrics support labels for metadata. Metadata cannot include commas (`,`); the inclusion of a comma in metadata will result in all metadata being removed from the custom metric.
170170

171+
## Limit How Many Histograms To Track (8.0+)
172+
173+
For System.Diagnostics.Metrics, `dotnet monitor` allows you to set the maximum number of histograms that can be tracked. Each unique combination of provider name, histogram name, and dimension values counts as one histogram. Tracking more histograms uses more memory in the target process so this bound guards against unintentional high memory use. `MaxHistograms` has a default value of `20`.
174+
175+
<details>
176+
<summary>JSON</summary>
177+
178+
```json
179+
{
180+
"GlobalCounter": {
181+
"MaxHistograms": 5
182+
}
183+
}
184+
```
185+
</details>
186+
187+
<details>
188+
<summary>Kubernetes ConfigMap</summary>
189+
190+
```yaml
191+
GlobalCounter__MaxHistograms: "5"
192+
```
193+
</details>
194+
195+
<details>
196+
<summary>Kubernetes Environment Variables</summary>
197+
198+
```yaml
199+
- name: DotnetMonitor_GlobalCounter__MaxHistograms
200+
value: "5"
201+
```
202+
</details>
203+
204+
## Limit How Many Time Series To Track (8.0+)
205+
206+
For System.Diagnostics.Metrics, `dotnet monitor` allows you to set the maximum number of time series that can be tracked. Each unique combination of provider name, metric name, and dimension values counts as one time series. Tracking more time series uses more memory in the target process so this bound guards against unintentional high memory use. `MaxTimeSeries` has a default value of `1000`.
207+
208+
<details>
209+
<summary>JSON</summary>
210+
211+
```json
212+
{
213+
"GlobalCounter": {
214+
"MaxTimeSeries": 500
215+
}
216+
}
217+
```
218+
</details>
219+
220+
<details>
221+
<summary>Kubernetes ConfigMap</summary>
222+
223+
```yaml
224+
GlobalCounter__MaxTimeSeries: "500"
225+
```
226+
</details>
227+
228+
<details>
229+
<summary>Kubernetes Environment Variables</summary>
230+
231+
```yaml
232+
- name: DotnetMonitor_GlobalCounter__MaxTimeSeries
233+
value: "500"
234+
```
235+
</details>
236+
171237
## Disable default providers
172238

173239
In addition to enabling custom providers, `dotnet monitor` also allows you to disable collection of the default providers. You can do so via the following configuration:

documentation/learningPath/collectionrules.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,79 @@
22
### Was this documentation helpful? [Share feedback](https://www.research.net/r/DGDQWXH?src=documentation%2FlearningPath%2Fcollectionrules)
33

44
# Collection Rules
5+
6+
## How To Use Collection Rules
7+
8+
You can learn more about how collection rules work [here](https://github.com/dotnet/dotnet-monitor/blob/main/documentation/collectionrules/collectionrules.md#collection-rules), with usage examples [here](https://github.com/dotnet/dotnet-monitor/blob/main/documentation/collectionrules/collectionruleexamples.md). If you're unfamiliar with collection rules in `dotnet-monitor`, we recommend taking a look at how to use collection rules before continuing with this learning path.
9+
10+
## Collection Rule Architecture
11+
12+
Collection rules' implementation is distributed between the `dotnet monitor` repo and the [`dotnet diagnostics` repo](https://github.com/dotnet/diagnostics). The flowchart below shows a simplified version of how `dotnet monitor` and `dotnet diagnostics` interact to run collection rules.
13+
14+
```mermaid
15+
%%{ init: { 'flowchart': { 'curve': 'basis' } } }%%
16+
graph LR
17+
classDef altColor fill:#CAF,stroke:purple;
18+
subgraph ide1 [Set-Up]
19+
A[Configuration] --> N{.NET Monitor}
20+
N --> |1| O[Load Configuration and Bind Options]
21+
N --> |2| P[Connect to Processes in Reverse Mode]
22+
N --> |3| Q[Start Pipelines For Processes That Match Filters]
23+
end
24+
subgraph ide2 [Repeat until Rule Limits Reached]
25+
N ---> |4| R[Wait To Satisfy Trigger - See Diagram B]
26+
N ---> |5| V[Check For Throttling]
27+
N ---> |6| W[Execute Action List]
28+
end
29+
30+
class ide2 altColor
31+
```
32+
33+
### Key Areas Of The Code
34+
35+
* Collection rules are registered [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs#L100). When adding a new trigger or action, these types need to be added here to take effect. This section is also responsible for making sure options get configured and validated.
36+
* Options for collection rules can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs).
37+
* Rules are applied, removed, and restarted in response to configuration changes [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRuleService.cs). This is also responsible for generating a description of each collection rule's state for the `/collectionrules` API Endpoint.
38+
* The pipeline responsible for the lifetime of a single executing collection rule can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRulePipeline.cs#L55).
39+
* To run collection rules, `dotnet monitor` must be in `Listen` mode - this is set via [DiagnosticPortOptions](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptions.cs).
40+
* For each type of trigger, the [dotnet diagnostics repo](https://github.com/dotnet/diagnostics/blob/v6.0.351802/src/Microsoft.Diagnostics.Monitoring.EventPipe/Triggers/ITraceEventTrigger.cs#L29) is responsible for determining whether the triggering conditions have been satisfied.
41+
42+
### Triggers
43+
44+
A trigger will monitor for a specific condition in the target application and raise a notification when that condition has been observed. Options for triggers can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs); the type of `Settings` is determined by which trigger is being used (possible trigger types can be found [here](https://github.com/dotnet/dotnet-monitor/tree/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers)). The interface for all triggers can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Triggers/ICollectionRuleTrigger.cs) - this allows `dotnet monitor` to start and stop triggers, regardless of the trigger's properties. The collection rule pipeline creates instances of triggers [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRulePipeline.cs#L100) before waiting for the trigger to [satisfy its conditions](https://github.com/dotnet/diagnostics/blob/v6.0.351802/src/Microsoft.Diagnostics.Monitoring.EventPipe/Triggers/Pipelines/TraceEventTriggerPipeline.cs#L107) - each trigger has its own set of criteria that determines when a trigger has been satisfied.
45+
46+
### Actions
47+
48+
Actions allow executing an operation or an external executable in response to a trigger condition being satisfied. Options for actions can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs); the type of `Settings` is determined by which action is being used (possible action types can be found [here](https://github.com/dotnet/dotnet-monitor/tree/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/Actions)). The interface for all actions can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Actions/ICollectionRuleAction.cs) - this allows `dotnet monitor` to start an action, wait for it to complete, and get its output values regardless of the action's properties. The action list is [executed](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRulePipeline.cs#L150) once the triggering condition has been met (assuming the action list isn't throttled), with each action by default starting without waiting for prior actions to complete.
49+
50+
### Filters
51+
52+
Filters can optionally be applied to a collection rule to choose which processes can trigger the rule. This uses the same set of [options](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.Options/ProcessFilterOptions.cs#L47) as setting the default process for `dotnet-monitor`. When starting a collection rule, [these filters are used to check if the current process should have the collection rule applied to it](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRuleContainer.cs#L189); if so, the collection rule starts.
53+
54+
### Limits
55+
56+
Limits can optionally be applied to a collection rule to constrain the lifetime of the rule and how often its actions can be run before being throttled. Options for limits can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleLimitsOptions.cs). When provided (or when using default values), limits are evaluated in the collection rule pipeline while running. `RuleDuration` is used to [create a token](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/CollectionRulePipeline.cs#L80) that shuts down the pipeline. `ActionCountSlidingWindowDuration` does not rely on setting cancellation tokens; rather, the number of executions within the sliding window are checked on-demand [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/CollectionRulePipelineState.cs#L212), and `ActionCount` is referenced to determine whether the rule needs to [terminate](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/CollectionRulePipelineState.cs#L195) or [throttle](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/CollectionRulePipelineState.cs#L235).
57+
58+
## Miscellaneous
59+
60+
### Trigger Shortcuts
61+
62+
Trigger Shortcuts provide improved defaults, range validation, and a simpler syntax for [several commonly used `EventCounter` triggers](https://github.com/dotnet/dotnet-monitor/tree/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterShortcuts). These shortcuts provide the same functionality as using the standard `EventCounter` syntax, but have fewer available options (since there is no need to specify the `ProviderName` or the `CounterName`) - as a result, shortcuts do not inherit from `EventCounterOptions`, but rather [IEventCounterShortcuts](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterShortcuts/IEventCounterShortcuts.cs). Each type of shortcut is registered independently [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs#L117). After binding with configuration and undergoing validation, shortcuts are then converted to be treated as `EventCounter` triggers [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Triggers/EventCounterTriggerFactory.cs), using their respective defaults instead of the generic ones.
63+
64+
### Templates
65+
66+
Templates allow users to design reusable collection rule components by associating a name with a piece of configuration. Options for templates can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/TemplateOptions.cs). Before collection rules undergo validation, `dotnet monitor` checks to see if any of the rule's components in configuration [list the name of a template](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Configuration/CollectionRulePostConfigureNamedOptions.cs) - if so, the collection rule's options are populated from the correspondingly named template. Note that templates undergo the same binding process for triggers/actions as collection rules; however, since templates are treated as separate parts of configuration, this binding instead happens [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Configuration/TemplatesConfigureNamedOptions.cs).
67+
68+
### Collection Rule Defaults
69+
70+
Defaults can be used to limit the verbosity of configuration, allowing frequently used values for collection rules to be assigned as defaults. Options for collection rule defaults can be found [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleDefaultsOptions.cs). These defaults are merged with the user's provided configuration [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Tools/dotnet-monitor/CollectionRules/Options/DefaultCollectionRulePostConfigureOptions.cs) - any properties that the user hasn't set (that have corresponding default values) will be updated at this point to use the default values. This step occurs prior to `dotnet monitor` attempting to use its built-in defaults, which allows user defaults to take precedence.
71+
72+
### Collection Rule API Endpoint
73+
74+
The Collection Rule API Endpoint allows users to get information about the state of their collection rules, providing general information [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/Controllers/DiagController.cs#L532) and more specific information about a particular rule [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/Controllers/DiagController.cs#L557). **This API is solely for viewing the current state of rules, not altering state**.
75+
76+
Each collection rule pipeline has a [state holder](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/src/Microsoft.Diagnostics.Monitoring.WebApi/CollectionRulePipelineState.cs) that keeps track of the rule's execution. By keeping track of the pipeline's state in real-time, this state doesn't need to be calculated in response to a user hitting the `/collectionrules` endpoint. However, other user-facing information, such as countdowns, are calculated on-demand - these values are solely for display purposes and not used by `dotnet-monitor` when determining when to change state (see [Limits](#limits) for more information).
77+
78+
## Keeping Documentation Up-To-Date
79+
80+
When making changes to collection rules that require updates to configuration, these changes should be added [here](https://github.com/dotnet/dotnet-monitor/blob/v7.0.1/documentation/configuration.md#collection-rule-configuration). Additional information on collection rules and examples can be provided [here](https://github.com/dotnet/dotnet-monitor/tree/v7.0.1/documentation/collectionrules).

0 commit comments

Comments
 (0)