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

Misc Monitoring and ExposeApi cleanups #4002

Merged
merged 5 commits into from Mar 15, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -57,7 +57,6 @@ async Task InitializeServiceControl(ScenarioContext context)
MaximumConcurrencyLevel = 2,
HttpDefaultConnectionLimit = int.MaxValue,
DisableHealthChecks = true,
ExposeApi = true,
MessageFilter = messageContext =>
{
var headers = messageContext.Headers;
Expand Down
Expand Up @@ -55,7 +55,6 @@ async Task InitializeServiceControl(ScenarioContext context)
TransportConnectionString = transportToUse.ConnectionString,
MaximumConcurrencyLevel = 2,
HttpDefaultConnectionLimit = int.MaxValue,
ExposeApi = false,
ServiceControlQueueAddress = "SHOULDNOTBEUSED",
MessageFilter = messageContext =>
{
Expand Down
Expand Up @@ -24,6 +24,5 @@
"DataSpaceRemainingThreshold": 20,
"ServiceControlQueueAddress": "Particular.ServiceControl",
"TimeToRestartAuditIngestionAfterFailure": "00:01:00",
"EnableFullTextSearchOnBodies": true,
"ExposeApi": true
"EnableFullTextSearchOnBodies": true
}
Expand Up @@ -141,7 +141,6 @@ public int MaxBodySizeToStore
public TimeSpan TimeToRestartAuditIngestionAfterFailure { get; set; }

public bool EnableFullTextSearchOnBodies { get; set; }
public bool ExposeApi { get; set; } = true;

public ITransportCustomization LoadTransportCustomization()
{
Expand Down
4 changes: 1 addition & 3 deletions src/ServiceControl.Audit/WebApplicationBuilderExtension.cs
Expand Up @@ -68,9 +68,7 @@ static class WebApplicationBuilderExtension

services.AddHttpLogging(options =>
{
// TODO Do we need to expose the host?
// we could also include the time it took to process the request
options.LoggingFields = HttpLoggingFields.RequestPath | HttpLoggingFields.RequestMethod | HttpLoggingFields.ResponseStatusCode;
options.LoggingFields = HttpLoggingFields.RequestPath | HttpLoggingFields.RequestMethod | HttpLoggingFields.ResponseStatusCode | HttpLoggingFields.Duration;
});

// Core registers the message dispatcher to be resolved from the transport seam. The dispatcher
Expand Down
Expand Up @@ -43,7 +43,6 @@ async Task InitializeServiceControl(ScenarioContext context)
TransportType = transportToUse.TypeName,
ConnectionString = transportToUse.ConnectionString,
HttpHostName = "localhost",
ExposeApi = true,
OnMessage = (id, headers, body, @continue) =>
{
var log = LogManager.GetLogger<ServiceControlComponentRunner>();
Expand Down
Expand Up @@ -18,6 +18,5 @@
"SkipQueueCreation": false,
"RootUrl": "http://localhost:9999/",
"MaximumConcurrencyLevel": 32,
"LicenseFileText": null,
"ExposeApi": true
"LicenseFileText": null
}
Expand Up @@ -7,6 +7,7 @@
using NServiceBus.MessageInterfaces;
using NServiceBus.Serialization;
using NServiceBus.Settings;
using ServiceControl.Infrastructure;

class TaggedLongValueWriterOccurrenceSerializerDefinition : SerializationDefinition
{
Expand Down Expand Up @@ -36,8 +37,7 @@ public void Serialize(object message, Stream stream)
//+-------+---------------+-------+---------------+-------+-------+
public object[] Deserialize(ReadOnlyMemory<byte> body, IList<Type> messageTypes = null)
{
//TODO clean up ReadOnlyMemory conversion
var reader = new BinaryReader(new MemoryStream(body.ToArray(), 0, body.Length));
var reader = new BinaryReader(new ReadOnlyStream(body));

var version = reader.ReadInt64();

Expand All @@ -53,10 +53,10 @@ public object[] Deserialize(ReadOnlyMemory<byte> body, IList<Type> messageTypes

if (count == 0)
{
return NoMessages;
return Array.Empty<object>();
}

var tagKeyToMessage = new Dictionary<int, TaggedLongValueOccurrence>();
var tagKeyToMessage = new Dictionary<int, TaggedLongValueOccurrence>(tagsCount);

foreach (var keyToValue in tagKeyToValue)
{
Expand Down Expand Up @@ -125,8 +125,6 @@ static TaggedLongValueOccurrence CreateMessageForTag(string keyValue)
return tagKeyToValue;
}

static readonly object[] NoMessages = new object[0];

static UTF8Encoding TagDecoder = new UTF8Encoding(false);
static UTF8Encoding TagDecoder = new(false);
}
}
Expand Up @@ -15,6 +15,7 @@

<ItemGroup>
<ProjectReference Include="..\ServiceControl.Configuration\ServiceControl.Configuration.csproj" />
<ProjectReference Include="..\ServiceControl.Infrastructure\ServiceControl.Infrastructure.csproj" />
<ProjectReference Include="..\ServiceControl.LicenseManagement\ServiceControl.LicenseManagement.csproj" />
<ProjectReference Include="..\ServiceControl.Transports\ServiceControl.Transports.csproj" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/ServiceControl.Monitoring/Settings.cs
Expand Up @@ -51,7 +51,6 @@ public string EndpointName
public string RootUrl => $"http://{HttpHostName}:{HttpPort}/";
public int MaximumConcurrencyLevel { get; set; }
public string LicenseFileText { get; set; }
public bool ExposeApi { get; set; } = true;

// SC installer always populates LogPath in app.config on installation/change/upgrade so this will only be used when
// debugging or if the entry is removed manually. In those circumstances default to the folder containing the exe
Expand Down
Expand Up @@ -56,9 +56,7 @@ public static class WebApplicationBuilderExtensions

services.AddHttpLogging(options =>
{
// TODO Do we need to expose the host?
// we could also include the time it took to process the request
options.LoggingFields = HttpLoggingFields.RequestPath | HttpLoggingFields.RequestMethod | HttpLoggingFields.ResponseStatusCode;
options.LoggingFields = HttpLoggingFields.RequestPath | HttpLoggingFields.RequestMethod | HttpLoggingFields.ResponseStatusCode | HttpLoggingFields.Duration;
});

// Core registers the message dispatcher to be resolved from the transport seam. The dispatcher
Expand All @@ -70,7 +68,6 @@ public static class WebApplicationBuilderExtensions
ConfigureEndpoint(endpointConfiguration, onCriticalError, transportCustomization, settings);
hostBuilder.UseNServiceBus(endpointConfiguration);

// TODO Verify if that we need to check the expose API flag
// We also don't do this in the primary instance
hostBuilder.WebHost.UseUrls(settings.RootUrl);
var controllers = hostBuilder.Services.AddControllers(options =>
Expand Down
Expand Up @@ -38,6 +38,5 @@
"RetryHistoryDepth": 10,
"RemoteInstances": [],
"DataSpaceRemainingThreshold": 20,
"DisableHealthChecks": false,
"ExposeApi": true
"DisableHealthChecks": false
}
2 changes: 0 additions & 2 deletions src/ServiceControl/Infrastructure/Settings/Settings.cs
Expand Up @@ -170,8 +170,6 @@ public TimeSpan HeartbeatGracePeriod

public bool DisableHealthChecks { get; set; }

public bool ExposeApi { get; set; } = true;

public ITransportCustomization LoadTransportCustomization()
{
try
Expand Down