Skip to content

Commit

Permalink
Add experimental diagnostics ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Taillefer committed Jul 17, 2023
1 parent 5546e37 commit a46831c
Show file tree
Hide file tree
Showing 82 changed files with 205 additions and 335 deletions.
5 changes: 2 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
<!-- Prevent analyzer crashes from stopping things -->
<NoWarn>$(NoWarn);AD0001</NoWarn>

<!-- R9A029 is for customers, not for this repo -->
<NoWarn>$(NoWarn);R9A029</NoWarn>

<!-- Experimental warnings are for customers, not for this repo -->
<NoWarn>$(NoWarn);EXTEXP0001;EXTEXP0002;EXTEXP0003;EXTEXP0004;EXTEXP0005;;EXTEXP0006;EXTEXP0007;EXTEXP0008;EXTEXP0009;EXTEXP0010;EXTEXP0011</NoWarn>

<!-- NU5104: A stable release of a package should not have a prerelease dependency -->
<NoWarn>$(NoWarn);NU5104</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion eng/MSBuild/Shared.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\Shared\WarningDefinitions.cs" LinkBase="Shared" />
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\Shared\DiagnosticIds\*.cs" LinkBase="Shared\DiagnosticIds" />
</ItemGroup>

<ItemGroup Condition="'$(InjectSharedThrow)' == 'true'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,7 @@ internal static class DiagDescriptors
helpLinkUri: "https://TODO/r9a022",
isEnabledByDefault: true);

// R9A023..R9A028 retired

public static DiagnosticDescriptor UsingExperimentalApi { get; } = new(
id: "R9A029",
messageFormat: Resources.UsingExperimentalApiMessage,
title: Resources.UsingExperimentalApiTitle,
category: Reliability,
description: Resources.UsingExperimentalApiDescription,
defaultSeverity: DiagnosticSeverity.Warning,
helpLinkUri: "https://TODO/r9a029",
isEnabledByDefault: true);
// R9A023..R9A029 retired

public static DiagnosticDescriptor StartsEndsWith { get; } = new(
id: "R9A030",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,6 @@
<data name="SequentialFixAllInSolution" xml:space="preserve">
<value>Apply code fix for all issues in current solution</value>
</data>
<data name="UsingExperimentalApiDescription" xml:space="preserve">
<value>Indicates that code is depending on an experimental API</value>
</data>
<data name="UsingExperimentalApiTitle" xml:space="preserve">
<value>Using experimental API</value>
</data>
<data name="UsingExperimentalApiMessage" xml:space="preserve">
<value>'{0}' is experimental and is subject to change without notice</value>
</data>
<data name="StartsEndsWithDescription" xml:space="preserve">
<value>When checking for a single character, prefer the character overloads of 'String.StartsWith' and 'String.EndsWith' for improved performance</value>
</data>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Http.Telemetry;
using Microsoft.Shared.Data.Validation;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.AspNetCore.Telemetry;

Expand Down Expand Up @@ -67,7 +68,7 @@ public class LoggingOptions
/// <value>
/// The default value is <see cref="HttpRouteParameterRedactionMode.Strict"/>.
/// </value>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode;

/// <summary>
Expand Down Expand Up @@ -208,7 +209,7 @@ public class LoggingOptions
/// };
/// </code>
/// </example>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
[Required]
[SuppressMessage("Usage", "CA2227:Collection properties should be read only",
Justification = "Options pattern.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.AspNetCore.Telemetry;

Expand All @@ -20,7 +21,7 @@ public class RequestHeadersLogEnricherOptions
/// Default value is an empty dictionary.
/// </remarks>
[Required]
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
#pragma warning disable CA2227 // Collection properties should be read only
public IDictionary<string, DataClassification> HeadersDataClasses { get; set; } = new Dictionary<string, DataClassification>();
#pragma warning restore CA2227 // Collection properties should be read only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options.Validation;
using Microsoft.Extensions.Telemetry.Internal;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;
using OpenTelemetry.Instrumentation.AspNetCore;
using OpenTelemetry.Trace;
Expand Down Expand Up @@ -116,7 +117,7 @@ public static TracerProviderBuilder AddHttpTraceEnricher(this TracerProviderBuil
/// <param name="services">The <see cref="IServiceCollection"/> to add this enricher.</param>
/// <returns><see cref="IServiceCollection"/> for chaining.</returns>
/// <exception cref="ArgumentNullException">The argument <paramref name="services"/> is <see langword="null"/>.</exception>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
public static IServiceCollection AddHttpTraceEnricher<T>(this IServiceCollection services)
where T : class, IHttpTraceEnricher
{
Expand All @@ -132,7 +133,7 @@ public static IServiceCollection AddHttpTraceEnricher<T>(this IServiceCollection
/// <param name="enricher">Enricher to be added.</param>
/// <returns><see cref="TracerProviderBuilder"/> for chaining.</returns>
/// <exception cref="ArgumentNullException">The argument <paramref name="services"/> or <paramref name="enricher"/> is <see langword="null" />.</exception>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
public static IServiceCollection AddHttpTraceEnricher(this IServiceCollection services, IHttpTraceEnricher enricher)
{
_ = Throw.IfNull(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Compliance.Classification;
using Microsoft.Extensions.Http.Telemetry;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.AspNetCore.Telemetry;

Expand Down Expand Up @@ -51,7 +52,7 @@ public class HttpTracingOptions
/// <remarks>
/// This property is applicable when the <see cref="IncludePath"/> option is enabled.
/// </remarks>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)]
public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.AsyncState;

Expand All @@ -11,7 +12,7 @@ namespace Microsoft.Extensions.AsyncState;
/// </summary>
/// <typeparam name="T">The type of the asynchronous state.</typeparam>
/// <remarks>This type is intended for internal use. Use <see cref="IAsyncContext{T}"/> instead.</remarks>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.AsyncState, UrlFormat = Experiments.UrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable S4023 // Interfaces should not be empty
public interface IAsyncLocalContext<T> : IAsyncContext<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.Compliance.Classification;
Expand Down Expand Up @@ -153,6 +154,6 @@ public static DataClassification Combine(DataClassification left, DataClassifica
/// Gets a string representation of this object.
/// </summary>
/// <returns>A string representing the object.</returns>
[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")]
[Experimental(diagnosticId: Experiments.Compliance, UrlFormat = Experiments.UrlFormat)]
public override string ToString() => $"{TaxonomyName}:{Value:x}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using Microsoft.Shared.DiagnosticIds;

#if !NETCOREAPP3_1_OR_GREATER
using System.Buffers;
Expand Down Expand Up @@ -199,7 +200,7 @@ public int Redact<T>(T value, Span<char> destination, string? format = null, IFo
/// <returns><see langword="true"/> if the destination buffer was large enough, otherwise <see langword="false"/>.</returns>
[SkipLocalsInit]
[SuppressMessage("Minor Code Smell", "S3247:Duplicate casts should not be made", Justification = "Avoid pattern matching to improve jitted code")]
[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")]
[Experimental(diagnosticId: Experiments.Compliance, UrlFormat = Experiments.UrlFormat)]
public bool TryRedact<T>(T value, Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider = null)
{
#if NET6_0_OR_GREATER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Telemetry.Metering;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.Diagnostics.HealthChecks;
Expand All @@ -30,7 +31,7 @@ public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceC
/// <param name="section">Configuration for <see cref="TelemetryHealthCheckPublisherOptions"/>.</param>
/// <returns>The value of <paramref name="services"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="services" /> or <paramref name="section"/> is <see langword="null" />.</exception>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.HealthChecks, UrlFormat = Experiments.UrlFormat)]
public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceCollection services, IConfigurationSection section)
=> Throw.IfNull(services)
.Configure<TelemetryHealthCheckPublisherOptions>(Throw.IfNull(section))
Expand All @@ -44,7 +45,7 @@ public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceC
/// <param name="configure">Configuration for <see cref="TelemetryHealthCheckPublisherOptions"/>.</param>
/// <returns>The value of <paramref name="services"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="services" /> or <paramref name="configure"/> is <see langword="null" />.</exception>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.HealthChecks, UrlFormat = Experiments.UrlFormat)]
public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceCollection services, Action<TelemetryHealthCheckPublisherOptions> configure)
=> Throw.IfNull(services)
.Configure(Throw.IfNull(configure))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.Diagnostics.HealthChecks;

/// <summary>
/// Options for the telemetry health check publisher.
/// </summary>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.HealthChecks, UrlFormat = Experiments.UrlFormat)]
public class TelemetryHealthCheckPublisherOptions
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.Data.Validation;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring;

Expand Down Expand Up @@ -50,7 +51,7 @@ public class ResourceMonitoringOptions
/// The value needs to be less than or equal to the <see cref="CollectionWindow"/>.
/// Most importantly, this period is used to calculate <see cref="Utilization"/> instances pushed to publishers.
/// </remarks>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.ResourceMonitoring, UrlFormat = Experiments.UrlFormat)]
[TimeSpan(MinimumSamplingWindow, MaximumSamplingWindow)]
public TimeSpan CalculationPeriod { get; set; } = DefaultCollectionWindow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Shared.Data.Validation;
using Microsoft.Shared.DiagnosticIds;

namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring;

/// <summary>
/// Options for WindowsCounters.
/// </summary>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.ResourceMonitoring, UrlFormat = Experiments.UrlFormat)]
public class WindowsCountersOptions
{
internal const int MinimumCachingInterval = 100;
Expand All @@ -33,7 +34,6 @@ public class WindowsCountersOptions
/// <value>
/// The default value is 5 seconds.
/// </value>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[TimeSpan(MinimumCachingInterval, MaximumCachingInterval)]
public TimeSpan CachingInterval { get; set; } = DefaultCachingInterval;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options.Validation;
using Microsoft.Extensions.Telemetry.Metering;
using Microsoft.Shared.DiagnosticIds;
using Microsoft.Shared.Diagnostics;

namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring;
Expand Down Expand Up @@ -65,7 +66,7 @@ public static IResourceMonitorBuilder AddWindowsPerfCounterPublisher(this IResou
/// <returns>The value of <paramref name="builder" />.</returns>
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null" />.</exception>
/// <seealso cref="System.Diagnostics.Metrics.Instrument"/>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.ResourceMonitoring, UrlFormat = Experiments.UrlFormat)]
public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder)
{
_ = Throw.IfNull(builder);
Expand Down Expand Up @@ -93,7 +94,7 @@ public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBu
/// <returns>The value of <paramref name="builder"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null" />.</exception>
/// <seealso cref="System.Diagnostics.Metrics.Instrument"/>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.ResourceMonitoring, UrlFormat = Experiments.UrlFormat)]
public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder, IConfigurationSection section)
{
_ = Throw.IfNull(builder);
Expand Down Expand Up @@ -123,7 +124,7 @@ public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBu
/// <returns>The value of <paramref name="builder"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null" />.</exception>
/// <seealso cref="System.Diagnostics.Metrics.Instrument"/>
[Experimental(diagnosticId: "TBD", UrlFormat = WarningDefinitions.SharedUrlFormat)]
[Experimental(diagnosticId: Experiments.ResourceMonitoring, UrlFormat = Experiments.UrlFormat)]
public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder, Action<WindowsCountersOptions> configure)
{
_ = Throw.IfNull(builder);
Expand Down
Loading

0 comments on commit a46831c

Please sign in to comment.