You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, create a `MetricsCollector` object. This is the top-level container which will hold all of your metrics and handle sending them to various metric endpoints. Therefore, you should only instantiate one, and make it a global singleton.
Tags are used to subdivide data in various metric platforms. In StackExchange.Metrics, tag sets are defined as C# classes. For example:
141
+
Tags are used to subdivide data in various metric platforms. In StackExchange.Metrics, tags are by specifying additional arguments when creating a metric. For example:
If none of the built-in metric types meet your specific needs, it's easy to [create your own](https://github.com/StackExchange/StackExchange.Metrics/blob/master/docs/MetricTypes.md#create-your-own).
132
185
133
-
### Metric Groups
134
-
135
-
Metric groups allow you to easily setup metrics which share the same name, but with different tag values. [See Documentation](https://github.com/StackExchange/StackExchange.Metrics/blob/master/docs/MetricGroup.md).
136
-
137
-
### Metric sets
186
+
### Metric Sources
138
187
139
-
Metric sets are pre-packaged sets of metrics that are useful across different applications. [See Documentation](https://github.com/StackExchange/StackExchange.Metrics/blob/master/docs/MetricSet.md) for further details.
188
+
Metric sets are pre-packaged sources of metrics that are useful across different applications. [See Documentation](https://github.com/StackExchange/StackExchange.Metrics/blob/master/docs/MetricSources.md) for further details.
140
189
141
190
## Implementation Notes
142
191
143
-
Periodically a `MetricsCollector` instance serializes all the metrics that it is responsible for collecting.
144
-
When it does so it serially calls Serialize on each metric which eventually results in a call to WriteValue.
192
+
Periodically a `MetricsCollector` instance serializes all the metrics from the sources attached to it.
193
+
When it does so it serially calls `WriteReadings` on each metric.
145
194
WriteValue uses an `IMetricBatch` to assist in writing metrics into an endpoint-defined format using an
146
195
implementation of `IBufferWriter<byte>` for buffering purposes.
Copy file name to clipboardExpand all lines: docs/MetricSources.md
+27-12Lines changed: 27 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
-
# Metric Sets
1
+
# Metric Sources
2
2
3
-
Metric sets are pre-packaged sets of metrics that are useful across different applications. These can be added to a `MetricsCollector` by specifying in the `IEnumerable<IMetricSet>` exposed at `MetricsCollectorOptions.Sets`.
3
+
Metric sources are a way to consume metrics and their readings. These can be added to a `MetricsCollector` by specifying in the `IEnumerable<MetricSource>` exposed at `MetricsCollectorOptions.Sources`.
4
4
5
-
## Built-in sets
5
+
## Built-in sources
6
6
7
-
### ProcessMetricSet
7
+
We provide some built-in metric sources that can report basic metrics within an application. Built-in sources can be added to a collector using the `MetricsCollectorOptions.Sources` property or by calling `AddDefaultSources` on the `IMetricsCollectorBuilder` exposed by `AddMetricsCollector` on an `IServiceCollection`.
8
+
9
+
### ProcessMetricSource
8
10
9
11
Provides basic metrics for a .NET application. This set contains the following metrics:
10
12
@@ -13,15 +15,15 @@ Provides basic metrics for a .NET application. This set contains the following m
13
15
-`dotnet.mem.virtual` - virtual memory for the process
14
16
-`dotnet.mem.paged` - paged memory for the process
15
17
16
-
### GarbageCollectionMetricSet (.NET Full Framework)
18
+
### GarbageCollectionMetricSource (.NET Full Framework only)
17
19
18
20
Provides metrics about the garbage collector (GC). This set contains the following metrics:
19
21
20
22
-`dotnet.mem.collections.gen0` - number of gen-0 collections
21
23
-`dotnet.mem.collections.gen1` - number of gen-1 collections
22
24
-`dotnet.mem.collections.gen2` - number of gen-2 collections
23
25
24
-
### RuntimeMetricSet (.NET Core)
26
+
### RuntimeMetricSource (.NET Core only)
25
27
26
28
Provides .NET Core runtime metrics which includes:
Custom metric sets can be defined by instantiating `MetricSource` and calling the `Add*` methods or by deriving from `MetricSource`.
53
57
54
-
Custom metric sets can be defined by implementing the `IMetricSet` interface. Implementors need to implement two methods:
58
+
Typically an application will define an `AppMetricSource` as follows:
55
59
56
-
-`Initialize` - this method is passed an `IMetricsCollector` and should be used to create metrics that the set defines. It can also be used to hook up long-lived metrics monitoring checks
57
-
-`Snapshot` - this method can be optionally implemented and is executed everytime the collector snapshots metrics for reporting
Once defined `IMetricSet` implementations should be added to the `MetricsCollectorOptions` that is passed to the `MetricsCollector`.
74
+
Custom metric sources can be configured using `MetricsCollectorOptions.Sources` in .NET full framework or the `AddSource` method on the `IMetricsCollectorBuilder` exposed by `AddMetricsCollector` on an `IServiceCollection`.
0 commit comments