-
Notifications
You must be signed in to change notification settings - Fork 729
/
TagNameAttribute.cs
44 lines (40 loc) · 1.32 KB
/
TagNameAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace Microsoft.Extensions.Diagnostics.Metrics;
/// <summary>
/// Provides tag information for strongly typed metrics.
/// </summary>
/// <remarks>
/// This attribute is applied to fields or properties of a metric class to override default tag names. By default,
/// the tag name is the same as the respective field or property. You can use this attribute to override the default
/// and provide a custom tag name.
/// </remarks>
/// <example>
/// <code language="csharp">
/// public class MyStrongTypeMetric
/// {
/// [TagName("tag_name_as_per_some_convention1")]
/// public string Name1 { get; set; }
///
/// [TagName("tag_name_as_per_some_convention2")]
/// public string Name2;
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class TagNameAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="TagNameAttribute"/> class.
/// </summary>
/// <param name="name">Tag name.</param>
public TagNameAttribute(string name)
{
Name = name;
}
/// <summary>
/// Gets the name of the tag.
/// </summary>
public string Name { get; }
}