Skip to content

Commit

Permalink
Add disable HTTP metrics endpoint metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jun 3, 2024
1 parent 83573c7 commit 2ba0409
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void RequestEnd(HttpContext httpContext, Exception? exception, HostingApp
if (context.MetricsEnabled)
{
var endpoint = HttpExtensions.GetOriginalEndpoint(httpContext);
var disableHttpRequestDurationMetric = endpoint?.Metadata.GetMetadata<IDisableHttpMetricsMetadata>() != null;
var route = endpoint?.Metadata.GetMetadata<IRouteDiagnosticsMetadata>()?.Route;

Debug.Assert(context.MetricsTagsFeature != null, "MetricsTagsFeature should be set if MetricsEnabled is true.");
Expand All @@ -169,7 +170,8 @@ public void RequestEnd(HttpContext httpContext, Exception? exception, HostingApp
exception,
context.MetricsTagsFeature.TagsList,
startTimestamp,
currentTimestamp);
currentTimestamp,
disableHttpRequestDurationMetric);
}

if (reachedPipelineEnd)
Expand Down
4 changes: 2 additions & 2 deletions src/Hosting/Hosting/src/Internal/HostingMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void RequestStart(string scheme, string method)
_activeRequestsCounter.Add(1, tags);
}

public void RequestEnd(string protocol, string scheme, string method, string? route, int statusCode, bool unhandledRequest, Exception? exception, List<KeyValuePair<string, object?>>? customTags, long startTimestamp, long currentTimestamp)
public void RequestEnd(string protocol, string scheme, string method, string? route, int statusCode, bool unhandledRequest, Exception? exception, List<KeyValuePair<string, object?>>? customTags, long startTimestamp, long currentTimestamp, bool disableHttpRequestDurationMetric)
{
var tags = new TagList();
InitializeRequestTags(ref tags, scheme, method);
Expand All @@ -52,7 +52,7 @@ public void RequestEnd(string protocol, string scheme, string method, string? ro
_activeRequestsCounter.Add(-1, tags);
}

if (_requestDuration.Enabled)
if (!disableHttpRequestDurationMetric && _requestDuration.Enabled)
{
if (TryGetHttpVersion(protocol, out var httpVersion))
{
Expand Down
123 changes: 122 additions & 1 deletion src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
using System.Diagnostics.Metrics;
using System.Diagnostics.Tracing;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.InternalTesting;
using Microsoft.Extensions.Diagnostics.Metrics;
Expand Down Expand Up @@ -182,7 +184,6 @@ public void Metrics_RequestChanges_OriginalValuesUsed()

var testMeterFactory = new TestMeterFactory();
using var activeRequestsCollector = new MetricCollector<long>(testMeterFactory, HostingMetrics.MeterName, "http.server.active_requests");
using var requestDurationCollector = new MetricCollector<double>(testMeterFactory, HostingMetrics.MeterName, "http.server.request.duration");

// Act
var hostingApplication = CreateApplication(out var features, eventSource: hostingEventSource, meterFactory: testMeterFactory, configure: c =>
Expand Down Expand Up @@ -233,6 +234,126 @@ public void Metrics_RequestChanges_OriginalValuesUsed()
Assert.Null(context.MetricsTagsFeature.Protocol);
}

[Fact]
public void Metrics_Route_RouteTagReported()
{
// Arrange
var hostingEventSource = new HostingEventSource(Guid.NewGuid().ToString());

var testMeterFactory = new TestMeterFactory();
using var activeRequestsCollector = new MetricCollector<long>(testMeterFactory, HostingMetrics.MeterName, "http.server.active_requests");
using var requestDurationCollector = new MetricCollector<double>(testMeterFactory, HostingMetrics.MeterName, "http.server.request.duration");

// Act
var hostingApplication = CreateApplication(out var features, eventSource: hostingEventSource, meterFactory: testMeterFactory, configure: c =>
{
c.Request.Protocol = "1.1";
c.Request.Scheme = "http";
c.Request.Method = "POST";
c.Request.Host = new HostString("localhost");
c.Request.Path = "/hello";
c.Request.ContentType = "text/plain";
c.Request.ContentLength = 1024;
});
var context = hostingApplication.CreateContext(features);

Assert.Collection(activeRequestsCollector.GetMeasurementSnapshot(),
m =>
{
Assert.Equal(1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
});

context.HttpContext.SetEndpoint(new Endpoint(
c => Task.CompletedTask,
new EndpointMetadataCollection(new TestRouteDiagnosticsMetadata()),
"Test endpoint"));

hostingApplication.DisposeContext(context, null);

// Assert
Assert.Collection(activeRequestsCollector.GetMeasurementSnapshot(),
m =>
{
Assert.Equal(1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
},
m =>
{
Assert.Equal(-1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
});
Assert.Collection(requestDurationCollector.GetMeasurementSnapshot(),
m =>
{
Assert.True(m.Value > 0);
Assert.Equal("hello/{name}", m.Tags["http.route"]);
});
}

[Fact]
public void Metrics_DisableHttpMetrics_NoMetrics()
{
// Arrange
var hostingEventSource = new HostingEventSource(Guid.NewGuid().ToString());

var testMeterFactory = new TestMeterFactory();
using var activeRequestsCollector = new MetricCollector<long>(testMeterFactory, HostingMetrics.MeterName, "http.server.active_requests");
using var requestDurationCollector = new MetricCollector<double>(testMeterFactory, HostingMetrics.MeterName, "http.server.request.duration");

// Act
var hostingApplication = CreateApplication(out var features, eventSource: hostingEventSource, meterFactory: testMeterFactory, configure: c =>
{
c.Request.Protocol = "1.1";
c.Request.Scheme = "http";
c.Request.Method = "POST";
c.Request.Host = new HostString("localhost");
c.Request.Path = "/hello";
c.Request.ContentType = "text/plain";
c.Request.ContentLength = 1024;
});
var context = hostingApplication.CreateContext(features);

Assert.Collection(activeRequestsCollector.GetMeasurementSnapshot(),
m =>
{
Assert.Equal(1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
});

context.HttpContext.SetEndpoint(new Endpoint(
c => Task.CompletedTask,
new EndpointMetadataCollection(new TestRouteDiagnosticsMetadata(), new DisableHttpMetricsAttribute()),
"Test endpoint"));

hostingApplication.DisposeContext(context, null);

// Assert
Assert.Collection(activeRequestsCollector.GetMeasurementSnapshot(),
m =>
{
Assert.Equal(1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
},
m =>
{
Assert.Equal(-1, m.Value);
Assert.Equal("http", m.Tags["url.scheme"]);
Assert.Equal("POST", m.Tags["http.request.method"]);
});
Assert.Empty(requestDurationCollector.GetMeasurementSnapshot());
}

private sealed class TestRouteDiagnosticsMetadata : IRouteDiagnosticsMetadata
{
public string Route { get; } = "hello/{name}";
}

[Fact]
public void DisposeContextDoesNotThrowWhenContextScopeIsNull()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Http.Metadata;

public interface IDisableHttpMetricsMetadata

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error CS1591: (NETCORE_ENGINEERING_TELEMETRY=Build) Missing XML comment for publicly visible type or member 'IDisableHttpMetricsMetadata'

Check failure on line 6 in src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs#L6

src/Http/Http.Abstractions/src/Metadata/IDisableHttpMetricsMetadata.cs(6,18): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'IDisableHttpMetricsMetadata' is not part of the declared API (https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/PublicApiAnalyzers.Help.md)
{
}
10 changes: 10 additions & 0 deletions src/Http/Http.Extensions/src/DisableHttpMetricsAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http.Metadata;

namespace Microsoft.AspNetCore.Http;

public sealed class DisableHttpMetricsAttribute : Attribute, IDisableHttpMetricsMetadata
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http;

namespace Microsoft.AspNetCore.Builder;

/// <summary>
/// HTTP metrics extension methods for <see cref="IEndpointConventionBuilder"/>.
/// </summary>
public static class HttpMetricsEndpointConventionBuilderExtensions
{
public static IEndpointConventionBuilder DisableHttpMetrics(this IEndpointConventionBuilder builder, int? statusCode = null)
{
builder.Add(b => b.Metadata.Add(new DisableHttpMetricsAttribute()));
return builder;
}
}
2 changes: 1 addition & 1 deletion src/Http/Routing/src/EndpointNameAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http;
Expand Down

0 comments on commit 2ba0409

Please sign in to comment.