-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace /trace and /httptrace with SpringBoot3-compatible /httpexchanges
- Loading branch information
Showing
65 changed files
with
1,352 additions
and
1,773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/Management/src/Endpoint/Actuators/HttpExchanges/ConfigureHttpExchangesEndpointOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Net.Http.Headers; | ||
using Steeltoe.Management.Endpoint.Configuration; | ||
|
||
namespace Steeltoe.Management.Endpoint.Actuators.HttpExchanges; | ||
|
||
internal sealed class ConfigureHttpExchangesEndpointOptions(IConfiguration configuration) | ||
: ConfigureEndpointOptions<HttpExchangesEndpointOptions>(configuration, ManagementInfoPrefix, "httpexchanges") | ||
{ | ||
private const string ManagementInfoPrefix = "management:endpoints:httpexchanges"; | ||
private const int DefaultCapacity = 100; | ||
|
||
private static readonly string[] DefaultAllowedRequestHeaders = | ||
[ | ||
HeaderNames.Accept, | ||
HeaderNames.AcceptCharset, | ||
HeaderNames.AcceptEncoding, | ||
HeaderNames.AcceptLanguage, | ||
HeaderNames.Allow, | ||
HeaderNames.CacheControl, | ||
HeaderNames.Connection, | ||
HeaderNames.ContentEncoding, | ||
HeaderNames.ContentLength, | ||
HeaderNames.ContentType, | ||
HeaderNames.Date, | ||
HeaderNames.DNT, | ||
HeaderNames.Expect, | ||
HeaderNames.Host, | ||
HeaderNames.MaxForwards, | ||
HeaderNames.Range, | ||
HeaderNames.SecWebSocketExtensions, | ||
HeaderNames.SecWebSocketVersion, | ||
HeaderNames.TE, | ||
HeaderNames.Trailer, | ||
HeaderNames.TransferEncoding, | ||
HeaderNames.Upgrade, | ||
HeaderNames.UserAgent, | ||
HeaderNames.Warning, | ||
HeaderNames.XRequestedWith, | ||
HeaderNames.XUACompatible | ||
]; | ||
|
||
private static readonly string[] DefaultAllowedResponseHeaders = | ||
[ | ||
HeaderNames.AcceptRanges, | ||
HeaderNames.Age, | ||
HeaderNames.Allow, | ||
HeaderNames.AltSvc, | ||
HeaderNames.Connection, | ||
HeaderNames.ContentDisposition, | ||
HeaderNames.ContentLanguage, | ||
HeaderNames.ContentLength, | ||
HeaderNames.ContentLocation, | ||
HeaderNames.ContentRange, | ||
HeaderNames.ContentType, | ||
HeaderNames.Date, | ||
HeaderNames.Expires, | ||
HeaderNames.LastModified, | ||
HeaderNames.Location, | ||
HeaderNames.Server, | ||
HeaderNames.TransferEncoding, | ||
HeaderNames.Upgrade, | ||
HeaderNames.XPoweredBy | ||
]; | ||
|
||
public override void Configure(HttpExchangesEndpointOptions options) | ||
{ | ||
ArgumentNullException.ThrowIfNull(options); | ||
|
||
base.Configure(options); | ||
|
||
if (options.Capacity < 1) | ||
{ | ||
options.Capacity = DefaultCapacity; | ||
} | ||
|
||
foreach (string defaultKey in DefaultAllowedRequestHeaders) | ||
{ | ||
options.RequestHeaders.Add(defaultKey); | ||
} | ||
|
||
foreach (string defaultKey in DefaultAllowedResponseHeaders) | ||
{ | ||
options.ResponseHeaders.Add(defaultKey); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Management/src/Endpoint/Actuators/HttpExchanges/EndpointServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Steeltoe.Management.Diagnostics; | ||
|
||
namespace Steeltoe.Management.Endpoint.Actuators.HttpExchanges; | ||
|
||
public static class EndpointServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the HttpExchanges actuator to the service container. | ||
/// </summary> | ||
/// <param name="services"> | ||
/// The <see cref="IServiceCollection" /> to add services to. | ||
/// </param> | ||
/// <returns> | ||
/// The incoming <paramref name="services" /> so that additional calls can be chained. | ||
/// </returns> | ||
public static IServiceCollection AddHttpExchangesActuator(this IServiceCollection services) | ||
{ | ||
ArgumentNullException.ThrowIfNull(services); | ||
|
||
services.TryAddSingleton<IDiagnosticsManager, DiagnosticsManager>(); | ||
services.AddHostedService<DiagnosticsService>(); | ||
services.AddCommonActuatorServices(); | ||
services.AddHttpExchangesActuatorServices(); | ||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IDiagnosticObserver, HttpExchangesDiagnosticObserver>()); | ||
|
||
services.TryAddSingleton<IHttpExchangesRepository>(provider => | ||
provider.GetServices<IDiagnosticObserver>().OfType<HttpExchangesDiagnosticObserver>().Single()); | ||
|
||
return services; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Management/src/Endpoint/Actuators/HttpExchanges/HttpExchange.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Text.Json.Serialization; | ||
using System.Xml; | ||
|
||
namespace Steeltoe.Management.Endpoint.Actuators.HttpExchanges; | ||
|
||
public sealed class HttpExchange | ||
{ | ||
public DateTime Timestamp { get; } | ||
public HttpExchangePrincipal? Principal { get; } | ||
public HttpExchangeSession? Session { get; } | ||
public HttpExchangeRequest Request { get; } | ||
public HttpExchangeResponse Response { get; } | ||
|
||
[JsonIgnore] | ||
public TimeSpan TimeTaken { get; } | ||
|
||
[JsonPropertyName("TimeTaken")] | ||
internal string SerializedTimeTaken => XmlConvert.ToString(TimeTaken); | ||
|
||
public HttpExchange(HttpExchangeRequest request, HttpExchangeResponse response, DateTime timestamp, HttpExchangePrincipal? principal, | ||
HttpExchangeSession? session, TimeSpan timeTaken) | ||
{ | ||
ArgumentNullException.ThrowIfNull(request); | ||
ArgumentNullException.ThrowIfNull(response); | ||
|
||
Request = request; | ||
Response = response; | ||
Timestamp = timestamp; | ||
Principal = principal; | ||
Session = session; | ||
TimeTaken = timeTaken; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.