Skip to content

Commit dff07e2

Browse files
author
R9 Fundamentals
committed
fixing docs
1 parent 58653b6 commit dff07e2

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

docs/core/diagnostics/metrics-generator.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ ms.date: 04/11/2025
66

77
# Compile-time metric source generation
88

9-
.NET's metering infrastructure is designed to deliver a highly-usable and high-performance metering solution
10-
for modern .NET applications.
9+
.NET's metering infrastructure is designed to deliver a highly usable and high-performance metering solution for modern .NET applications.
1110

12-
To use source generated metering, you first create a class that defines the names and dimensions of the metrics your code can produce.
13-
Then you need to create the class with partial methods signatures.
11+
To use source-generated metering, create a class that defines the names and dimensions of the metrics your code can produce. Then, create the class with `partial` method signatures.
1412

15-
Then, the .NET's code generator automatically generates the code, which exposes strongly-typed metering types and
16-
methods that you can invoke to record metric values. The generated methods are implemented in a highly efficient
17-
form, which reduces computation overhead as compared to traditional metering solutions.
13+
The code generator automatically generates the code, which exposes strongly typed metering types and methods that you can invoke to record metric values. The generated methods are implemented in a highly efficient form, which reduces computation overhead as compared to traditional metering solutions.
1814

19-
## Install the package
15+
## Get started
2016

2117
To get started, install the [📦 Microsoft.Extensions.Telemetry.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Telemetry.Abstractions) NuGet package:
2218

@@ -37,12 +33,11 @@ dotnet add package Microsoft.Extensions.Telemetry.Abstractions
3733

3834
---
3935

40-
## Generic attributes
36+
For more information, see [dotnet add package](../tools/dotnet-package-add.md) or [Manage package dependencies in .NET applications](../tools/dependencies.md).
4137

42-
Generic attributes are only supported in C# 11 or later, so if you are using generic attributes then please enable C# 11 or later.
43-
Please use non generic attributes if you are using C# 10 or earlier.
38+
## Generic attributes
4439

45-
## Usage
40+
Generic attributes require C# 11 or later. For C# 10 or earlier, use nongeneric attributes instead.
4641

4742
The following example shows a class that declares two metrics. The methods are marked with an attribute and are declared as `static` and `partial`.
4843
The code generator runs at build time and provides an implementation of these methods, along with accompanying
@@ -100,9 +95,7 @@ internal class Latency
10095
}
10196
```
10297

103-
The dimensions specified in the attributes have been turned into arguments to the `Add` and `Record` methods.
104-
You then use the generated methods to create instances of these types. With the instances created,
105-
you can call `Add` and `Record` to register metric values, like this:
98+
The dimensions specified in the attributes have been turned into arguments to the `Add` and `Record` methods. You then use the generated methods to create instances of these types. With the instances created, you can call `Add` and `Record` to register metric values, as shown in the following example:
10699

107100
```csharp
108101
internal class MyClass
@@ -148,15 +141,15 @@ internal class MyClass
148141

149142
## Metric methods requirements
150143

151-
Metric methods have some constraints that you must follow:
144+
Metric methods are constrained to the following:
152145

153-
- They must be static, partial, and public.
146+
- They must be `public static partial`.
154147
- The return type must be unique.
155148
- Their names must not start with an underscore.
156149
- Their parameter names must not start with an underscore.
157-
- Their first parameter must be `Meter`.
158-
- They can't be generic or accept any generic parameters.
150+
- Their first parameter must be <xref:System.Diagnostics.Metrics.Meter> type.
151+
Metric methods are constrained to the following:
159152

160-
## Supported metrics
153+
## See also
161154

162-
Please refer to the .NET [`Types of instruments`](metrics-instrumentation.md#types-of-instruments) to learn about all the supported instruments and description on how to choose which instrument to use in different situations.
155+
For more information on the supported metrics, see [Types of instruments](metrics-instrumentation.md#types-of-instruments) to learn how to choose which instrument to use in different situations.

docs/core/diagnostics/metrics-strongly-typed.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Modern .NET applications can capture metrics using the <xref:System.Diagnostics.
1111
> [!NOTE]
1212
> In the context of metrics, a tag is sometimes also called a "dimension." This article uses "tag" for clarity and consistency with .NET metrics terminology.
1313
14-
## Install the package
14+
## Get started
1515

1616
To get started, install the [📦 Microsoft.Extensions.Telemetry.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Telemetry.Abstractions) NuGet package:
1717

@@ -32,6 +32,8 @@ dotnet add package Microsoft.Extensions.Telemetry.Abstractions
3232

3333
---
3434

35+
For more information, see [dotnet add package](../tools/dotnet-package-add.md) or [Manage package dependencies in .NET applications](../tools/dependencies.md).
36+
3537
## Tag name defaults and customization
3638

3739
By default, the source generator derives metric tag names from the field and property names of your tag class. In other words, each public field or property in the strongly-typed tag object becomes a tag name by default. You can override this by using the <xref:Microsoft.Extensions.Diagnostics.Metrics.TagNameAttribute> on a field or property to specify a custom tag name. In the examples below, you’ll see both approaches in action.

0 commit comments

Comments
 (0)