Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more combinations of tags on telemetry metrics #6429

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public TelemetryMetricAttribute(string metricName)
/// which has a single tag
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag> : System.Attribute
internal class TelemetryMetricAttribute<TTag> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag : System.Enum
{
/// <summary>
Expand All @@ -132,10 +132,8 @@ internal class TelemetryMetricAttribute<TTag> : System.Attribute
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
MetricName = metricName;
IsCommon = isCommon;
NameSpace = nameSpace;
}

/// <summary>
Expand All @@ -145,45 +143,119 @@ public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpa
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: this(metricName, isCommon, null!)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="IsCommon"/> to <c>true</c>
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: this(metricName, isCommon: true, null!)
: base(metricName, isCommon: true, null!)
{
}
}

/// <summary>
/// Used to describe a specific metric defined as a field
/// inside an enum decorated with <see cref="TelemetryMetricTypeAttribute"/>
/// which has two tags
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag1, TTag2> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag1 : System.Enum
where TTag2 : System.Enum
{
/// <summary>
/// Gets the name of the metric, as reported to Datadog
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// </summary>
public string MetricName { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
}

/// <summary>
/// Gets a value indicating whether the metric a "common" metric, shared across languages?
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace
/// </summary>
public bool IsCommon { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Gets the namespace of the metric, if not the default (Tracer)
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
public string? NameSpace { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: base(metricName, isCommon: true, null!)
{
}
}

/// <summary>
/// Used to describe a specific metric defined as a field
/// inside an enum decorated with <see cref="TelemetryMetricTypeAttribute"/>
/// which has two tags
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag1, TTag2, TTag3> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag1 : System.Enum
where TTag2 : System.Enum
where TTag3 : System.Enum
{
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: base(metricName, isCommon: true, null!)
{
}
}

/// <summary>
/// Used to describe a specific metric defined as a field
/// inside an enum decorated with <see cref="TelemetryMetricTypeAttribute"/>
/// which has two tags
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag1, TTag2> : System.Attribute
internal class TelemetryMetricAttribute<TTag1, TTag2, TTag3, TTag4> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag1 : System.Enum
where TTag2 : System.Enum
where TTag3 : System.Enum
where TTag4 : System.Enum
{
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
Expand All @@ -192,10 +264,8 @@ internal class TelemetryMetricAttribute<TTag1, TTag2> : System.Attribute
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
MetricName = metricName;
IsCommon = isCommon;
NameSpace = nameSpace;
}

/// <summary>
Expand All @@ -205,34 +275,112 @@ public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpa
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: this(metricName, isCommon, null!)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="IsCommon"/> to <c>true</c>
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: this(metricName, isCommon: true, null!)
: base(metricName, isCommon: true, null!)
{
}
}

/// <summary>
/// Used to describe a specific metric defined as a field
/// inside an enum decorated with <see cref="TelemetryMetricTypeAttribute"/>
/// which has two tags
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag1, TTag2, TTag3, TTag4, TTag5> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag1 : System.Enum
where TTag2 : System.Enum
where TTag3 : System.Enum
where TTag4 : System.Enum
where TTag5 : System.Enum
{
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
}

/// <summary>
/// Gets the name of the metric, as reported to Datadog
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace
/// </summary>
public string MetricName { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Gets a value indicating whether the metric a "common" metric, shared across languages?
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
public bool IsCommon { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: base(metricName, isCommon: true, null!)
{
}
}

/// <summary>
/// Used to describe a specific metric defined as a field
/// inside an enum decorated with <see cref="TelemetryMetricTypeAttribute"/>
/// which has two tags
/// </summary>
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)]
internal class TelemetryMetricAttribute<TTag1, TTag2, TTag3, TTag4, TTag5, TTag6> : Datadog.Trace.SourceGenerators.TelemetryMetricAttribute
where TTag1 : System.Enum
where TTag2 : System.Enum
where TTag3 : System.Enum
where TTag4 : System.Enum
where TTag5 : System.Enum
where TTag6 : System.Enum
{
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
/// <param name="nameSpace">The namespace of the metric, if not the default (Tracer)</param>
public TelemetryMetricAttribute(string metricName, bool isCommon, string nameSpace)
: base(metricName, isCommon, nameSpace)
{
}

/// <summary>
/// Gets the namespace of the metric, if not the default (Tracer)
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace
/// </summary>
public string? NameSpace { get; }
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
/// <param name="isCommon">Is the metric a "common" metric, shared across languages?</param>
public TelemetryMetricAttribute(string metricName, bool isCommon)
: base(metricName, isCommon, null!)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryMetricAttribute"/> class.
/// Uses the default namespace and sets <see cref="TelemetryMetricAttribute.IsCommon"/> to <c>true</c>
/// </summary>
/// <param name="metricName">The name of the metric, as reported to Datadog</param>
public TelemetryMetricAttribute(string metricName)
: base(metricName, isCommon: true, null!)
{
}
}
""";
}
Loading
Loading