Skip to content

Commit f7cfad7

Browse files
author
R9 Fundamentals
committed
adding missing double quotes
1 parent f35e3aa commit f7cfad7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/core/diagnostics/metrics-generator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ The following example shows a class that declares two metrics. The methods are m
4343
The code generator runs at build time and provides an implementation of these methods, along with accompanying
4444
types.
4545

46-
:::code language="csharp" source="snippets/MetricsGen/MetricConstants.cs id="snippet_metricConstants":::
47-
:::code language="csharp" source="snippets/MetricsGen/Metris.cs id="snippet_Metrics" :::
46+
:::code language="csharp" source="snippets/MetricsGen/MetricConstants.cs" id="snippet_metricConstants":::
47+
:::code language="csharp" source="snippets/MetricsGen/Metris.cs" id="snippet_Metrics" :::
4848

4949
The previous declaration automatically returns the following:
5050

@@ -73,7 +73,7 @@ internal class Latency
7373

7474
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:
7575

76-
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs id ="snippet_metricCreation":::
76+
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs" id ="snippet_metricCreation":::
7777

7878
## Metric methods requirements
7979

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ By default, the source generator derives metric tag names from the field and pro
4242

4343
The following example demonstrates a simple counter metric with one tag. In this scenario, we want to count the number of processed requests and categorize them by a `Region` tag:
4444

45-
:::code language="csharp" source="snippets/MetricsGen/MyMetrics.cs id= "snippet_SimpleMetricTag":::
45+
:::code language="csharp" source="snippets/MetricsGen/MyMetrics.cs" id= "snippet_SimpleMetricTag":::
4646

4747
In the code above, `RequestTags` is a strongly-typed tag struct with a single property `Region`. The `CreateRequestCount` method is marked with <xref:Microsoft.Extensions.Diagnostics.Metrics.CounterAttribute`1> where `T` is an `int`, indicating it generates a **Counter** instrument that tracks `int` values. The attribute references `typeof(RequestTags)`, meaning the counter will use the tags defined in `RequestTags` when recording metrics. The source generator will produce a strongly-typed instrument class (named `RequestCount`) with an `Add` method that accepts integer value and `RequestTags` object.
4848

4949
To use the generated metric, create a <xref:System.Diagnostics.Metrics.Meter> and record measurements as shown below:
5050

51-
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs id ="snippet_SimpleMetricTagUsage":::
51+
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs" id ="snippet_SimpleMetricTagUsage":::
5252

5353
In this usage example, calling `MyMetrics.CreateRequestCount(meter)` creates a counter instrument (via the `Meter`) and returns a `RequestCount` metric object. When you call `requestCountMetric.Add(1, tags)`, the metric system records a count of 1 associated with the tag `Region="NorthAmerica"`. You can reuse the `RequestTags` object or create new ones to record counts for different regions, and the tag name `Region` will consistently be applied to every measurement.
5454

5555
## Example 2: Metric with nested tag objects
5656

5757
For more complex scenarios, you can define tag classes that include multiple tags, nested objects, or even inherited properties. This allows a group of related metrics to share a common set of tags easily. In the next example, we define a set of tag classes and use them for three different metrics:
5858

59-
:::code language="csharp" source="snippets/MetricsGen/MetricTags.cs :::
60-
:::code language="csharp" source="snippets/MetricsGen/Metris.cs id="snippet_MetricTags" :::
59+
:::code language="csharp" source="snippets/MetricsGen/MetricTags.cs" :::
60+
:::code language="csharp" source="snippets/MetricsGen/Metris.cs" id="snippet_MetricTags" :::
6161

6262
In this example, `MetricTags` is a tag class that inherits from `MetricParentTags` and also contains a nested tag object (`MetricChildTags`) and a nested struct (`MetricTagsStruct`). The tag properties demonstrate both default and customized tag names:
6363

@@ -71,7 +71,7 @@ All three metric definitions `CreateLatency`, `CreateTotalCount`, and `CreateTot
7171

7272
The following code shows how to create and use these metrics in a class:
7373

74-
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs id ="snippet_strongMetricCreation":::
74+
:::code language="csharp" source="snippets/MetricsGen/MyClass.cs" id ="snippet_strongMetricCreation":::
7575

7676
In the preceding `MyClass.DoWork` method, a `MetricTags` object is populated with values for each tag. This single `tags` object is then passed to all three instruments when recording data. The `Latency` metric (a histogram) records the elapsed time, and both counters (`TotalCount` and `TotalFailures`) record occurrence counts. Because all metrics share the same tag object type, the tags (`Dim1DimensionName`, `Operation`, `Dim2`, `Dim3`, `DimensionNameOfParentOperation`) are present on every measurement.
7777

0 commit comments

Comments
 (0)