Skip to content

Commit

Permalink
AWS Provider Bugfixes (#44)
Browse files Browse the repository at this point in the history
* Give AWS trace listener a name

Without it, removal is not possible, i.e.
AWSConfigs.RemoveTraceListener("Amazon", "AwsEvent")
would have no effect.

Turns out, this is ["by design"](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Amazon/MAWSConfigsAddTraceListenerStringTraceListener.html)

* Allow AWS API response logging to be disabled

Previously, could only set to Always/OnError (and neither was actually wired up!)
  • Loading branch information
chris-peterson authored Nov 7, 2024
1 parent 5bbbc4b commit b78f176
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Spiffy.Monitoring.Aws/AwsConfigurationApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public void OnlyErrors()
{
ResponseLoggingOption = ResponseLoggingOption.OnError;
}

public void Never()
{
ResponseLoggingOption = ResponseLoggingOption.Never;
}
}

public class AwsConfigurationApi
{
public ResponseLoggingApi LogResponses { get; } = new ResponseLoggingApi();
Expand Down
19 changes: 15 additions & 4 deletions src/Spiffy.Monitoring.Aws/AwsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ public static InitializationApi.ProvidersApi Aws(this InitializationApi.Provider
{
AWSConfigs.LoggingConfig.LogTo = LoggingOptions.SystemDiagnostics;
AWSConfigs.AddTraceListener("Amazon", new AwsEvent());
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.OnError;

if (configure != null)
var config = new AwsConfigurationApi();
configure?.Invoke(config);

switch (config.LogResponses.ResponseLoggingOption)
{
var config = new AwsConfigurationApi();
configure(config);
case ResponseLoggingOption.Never:
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Never;
break;
case ResponseLoggingOption.OnError:
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.OnError;
break;
case ResponseLoggingOption.Always:
AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.Always;
break;
}

return providers;
Expand Down Expand Up @@ -74,6 +83,8 @@ static bool IsSdkSpam(string message)

return false;
}

public override string Name { get; set; } = nameof(AwsEvent);
}
}
}
4 changes: 2 additions & 2 deletions src/Spiffy.Monitoring.Aws/Spiffy.Monitoring.Aws.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Copyright>2021-2023</Copyright>
<Copyright>2021-2024</Copyright>
<Authors>Chris Peterson</Authors>
<Description>AWS provider for Spiffy.Monitoring</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand All @@ -13,7 +13,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>2.0.2</Version>
<Version>2.0.3</Version>
<RootNamespace>Spiffy.Monitoring.Aws</RootNamespace>
</PropertyGroup>

Expand Down

0 comments on commit b78f176

Please sign in to comment.