diff --git a/libraries/AWS.Lambda.Powertools.sln b/libraries/AWS.Lambda.Powertools.sln
index 325c683e0..5f7ccf18e 100644
--- a/libraries/AWS.Lambda.Powertools.sln
+++ b/libraries/AWS.Lambda.Powertools.sln
@@ -123,6 +123,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.Kafka
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.Kafka.Protobuf", "src\AWS.Lambda.Powertools.Kafka.Protobuf\AWS.Lambda.Powertools.Kafka.Protobuf.csproj", "{B640DB80-C982-407B-A2EC-CD29AC77DDB8}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWS.Lambda.Powertools.SourceGenerator.Tests", "tests\AWS.Lambda.Powertools.SourceGenerator.Tests\AWS.Lambda.Powertools.SourceGenerator.Tests.csproj", "{D94F60B1-B65B-451B-BFB4-EAC63881B17E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -688,6 +690,18 @@ Global
{B640DB80-C982-407B-A2EC-CD29AC77DDB8}.Release|x64.Build.0 = Release|Any CPU
{B640DB80-C982-407B-A2EC-CD29AC77DDB8}.Release|x86.ActiveCfg = Release|Any CPU
{B640DB80-C982-407B-A2EC-CD29AC77DDB8}.Release|x86.Build.0 = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|x64.Build.0 = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Debug|x86.Build.0 = Debug|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|x64.ActiveCfg = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|x64.Build.0 = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|x86.ActiveCfg = Release|Any CPU
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
@@ -746,5 +760,6 @@ Global
{25F0929B-2E04-4ED6-A0ED-5379A0A755B0} = {73C9B1E5-3893-47E8-B373-17E5F5D7E6F5}
{9E2B8160-3E76-4B33-86AB-DE35A5FCDB1E} = {73C9B1E5-3893-47E8-B373-17E5F5D7E6F5}
{B640DB80-C982-407B-A2EC-CD29AC77DDB8} = {73C9B1E5-3893-47E8-B373-17E5F5D7E6F5}
+ {D94F60B1-B65B-451B-BFB4-EAC63881B17E} = {1CFF5568-8486-475F-81F6-06105C437528}
EndGlobalSection
EndGlobal
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
index 54af16708..21d7abf41 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/AWS.Lambda.Powertools.BatchProcessing.csproj
@@ -6,6 +6,7 @@
AWS.Lambda.Powertools.BatchProcessing
AWS.Lambda.Powertools.BatchProcessing
true
+ true
@@ -13,6 +14,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/BatchProcessor.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/BatchProcessor.cs
index 6afeebfa6..d8583207e 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/BatchProcessor.cs
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/BatchProcessor.cs
@@ -5,7 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using AWS.Lambda.Powertools.BatchProcessing.Exceptions;
-using AWS.Lambda.Powertools.Common;
namespace AWS.Lambda.Powertools.BatchProcessing;
@@ -16,14 +15,6 @@ namespace AWS.Lambda.Powertools.BatchProcessing;
/// Type of batch record.
public abstract class BatchProcessor : IBatchProcessor
{
- ///
- /// Default constructor
- ///
- protected BatchProcessor(IPowertoolsConfigurations powertoolsConfigurations)
- {
- powertoolsConfigurations.SetExecutionEnvironment(this);
- }
-
///
public ProcessingResult ProcessingResult { get; protected set; }
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/DynamoDbStreamBatchProcessor.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/DynamoDbStreamBatchProcessor.cs
index c19b4a44f..1e59423ff 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/DynamoDbStreamBatchProcessor.cs
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/DynamoDb/DynamoDbStreamBatchProcessor.cs
@@ -15,7 +15,6 @@
using System.Collections.Generic;
using Amazon.Lambda.DynamoDBEvents;
-using AWS.Lambda.Powertools.Common;
namespace AWS.Lambda.Powertools.BatchProcessing.DynamoDb;
@@ -33,23 +32,16 @@ public class DynamoDbStreamBatchProcessor : BatchProcessor
public static IDynamoDbStreamBatchProcessor Instance =>
- _instance ??= new DynamoDbStreamBatchProcessor(PowertoolsConfigurations.Instance);
+ _instance ??= new DynamoDbStreamBatchProcessor();
+
- ///
- /// This is the default constructor
- ///
- ///
- public DynamoDbStreamBatchProcessor(IPowertoolsConfigurations powertoolsConfigurations) : base(powertoolsConfigurations)
- {
- _instance = this;
- }
-
///
/// Need default constructor for when consumers create a custom batch processor
///
// ReSharper disable once MemberCanBePrivate.Global
- protected DynamoDbStreamBatchProcessor() : this(PowertoolsConfigurations.Instance)
+ protected DynamoDbStreamBatchProcessor()
{
+ _instance = this;
}
///
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..ad25349cd
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.BatchProcessing.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/KinesisEventBatchProcessor.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/KinesisEventBatchProcessor.cs
index 6c3323080..eb5185985 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/KinesisEventBatchProcessor.cs
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Kinesis/KinesisEventBatchProcessor.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Amazon.Lambda.KinesisEvents;
-using AWS.Lambda.Powertools.Common;
namespace AWS.Lambda.Powertools.BatchProcessing.Kinesis;
@@ -18,25 +17,16 @@ public class KinesisEventBatchProcessor : BatchProcessor
public static IKinesisEventBatchProcessor Instance =>
- _instance ??= new KinesisEventBatchProcessor(PowertoolsConfigurations.Instance);
-
- ///
- /// This is the default constructor
- ///
- ///
- public KinesisEventBatchProcessor(IPowertoolsConfigurations powertoolsConfigurations) : base(powertoolsConfigurations)
- {
- _instance = this;
- }
+ _instance ??= new KinesisEventBatchProcessor();
///
/// Need default constructor for when consumers create a custom batch processor
///
- // ReSharper disable once MemberCanBePrivate.Global
- protected KinesisEventBatchProcessor() : this(PowertoolsConfigurations.Instance)
+ protected KinesisEventBatchProcessor()
{
+ _instance = this;
}
-
+
///
/// Return the instance ProcessingResult
///
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..a5faf7665
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,44 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.BatchProcessing.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.BatchProcessing.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/SqsBatchProcessor.cs b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/SqsBatchProcessor.cs
index f7741e522..0f6201534 100644
--- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/SqsBatchProcessor.cs
+++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/Sqs/SqsBatchProcessor.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using Amazon.Lambda.SQSEvents;
-using AWS.Lambda.Powertools.Common;
namespace AWS.Lambda.Powertools.BatchProcessing.Sqs;
@@ -20,22 +19,14 @@ public class SqsBatchProcessor : BatchProcessor,
/// Gets the instance.
///
/// The instance.
- public static ISqsBatchProcessor Instance => _instance ??= new SqsBatchProcessor(PowertoolsConfigurations.Instance);
-
- ///
- /// This is the default constructor
- ///
- ///
- public SqsBatchProcessor(IPowertoolsConfigurations powertoolsConfigurations) : base(powertoolsConfigurations)
- {
- _instance = this;
- }
-
+ public static ISqsBatchProcessor Instance => _instance ??= new SqsBatchProcessor();
+
///
/// Need default constructor for when consumers create a custom batch processor
///
- protected SqsBatchProcessor() : this(PowertoolsConfigurations.Instance)
+ public SqsBatchProcessor()
{
+ _instance = this;
}
///
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj b/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
index 9d3e66822..83378debc 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Common/AWS.Lambda.Powertools.Common.csproj
@@ -2,16 +2,17 @@
- AWS.Lambda.Powertools.Common
- Powertools for AWS Lambda (.NET) - Core package.
- AWS.Lambda.Powertools.Common
- AWS.Lambda.Powertools.Common
- false
+ AWS.Lambda.Powertools.Common
+ Powertools for AWS Lambda (.NET) - Core package.
+ AWS.Lambda.Powertools.Common
+ AWS.Lambda.Powertools.Common
+ false
-
-
+
+
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Core/Constants.cs b/libraries/src/AWS.Lambda.Powertools.Common/Core/Constants.cs
index 456a50921..c48e9b115 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Core/Constants.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Core/Constants.cs
@@ -13,6 +13,7 @@
* permissions and limitations under the License.
*/
+// ReSharper disable InconsistentNaming
namespace AWS.Lambda.Powertools.Common;
///
@@ -143,4 +144,12 @@ internal static class Constants
/// Constant for POWERTOOLS_METRICS_DISABLED environment variable
///
internal const string PowertoolsMetricsDisabledEnv = "POWERTOOLS_METRICS_DISABLED";
+
+ ///
+ /// A unique and opaque application ID that is appended to the
+ /// User-Agent header as app/sdk_ua_app_id. It should have a
+ /// maximum length of 50. This variable is sourced from environment
+ /// variable AWS_SDK_UA_APP_ID
+ ///
+ internal const string AWSSdkUAAppId = "AWS_SDK_UA_APP_ID";
}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsConfigurations.cs b/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsConfigurations.cs
index 755d33ef7..9263c6bf0 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsConfigurations.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsConfigurations.cs
@@ -127,12 +127,6 @@ public interface IPowertoolsConfigurations
/// true if XXXX, false otherwise.
bool GetEnvironmentVariableOrDefault(string variable, bool defaultValue);
- ///
- /// Sets the execution Environment Variable (AWS_EXECUTION_ENV)
- ///
- ///
- void SetExecutionEnvironment(T type);
-
///
/// Gets a value indicating whether [Idempotency is disabled].
///
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsEnvironment.cs b/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsEnvironment.cs
index 6f57aabb3..23e2c179d 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsEnvironment.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Core/IPowertoolsEnvironment.cs
@@ -34,10 +34,11 @@ public interface IPowertoolsEnvironment
///
/// Assembly Version in the Major.Minor.Build format
string GetAssemblyVersion(T type);
-
+
///
- /// Sets the execution Environment Variable (AWS_EXECUTION_ENV)
+ /// Sets the execution Environment Variable (AWS_SDK_UA_APP_ID)
///
///
- void SetExecutionEnvironment(T type);
+ ///
+ void SetExecutionEnvironment(T type, string utilityName = null);
}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsConfigurations.cs b/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsConfigurations.cs
index e6b6f6446..051c5c339 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsConfigurations.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsConfigurations.cs
@@ -182,12 +182,6 @@ public bool GetEnvironmentVariableOrDefault(string variable, bool defaultValue)
public bool TracingDisabled =>
GetEnvironmentVariableOrDefault(Constants.TracingDisabledEnv, false);
- ///
- public void SetExecutionEnvironment(T type)
- {
- _powertoolsEnvironment.SetExecutionEnvironment(type);
- }
-
///
public bool IdempotencyDisabled =>
GetEnvironmentVariableOrDefault(Constants.IdempotencyDisabledEnv, false);
diff --git a/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsEnvironment.cs b/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsEnvironment.cs
index afc796b6a..cf0279fe5 100644
--- a/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsEnvironment.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Common/Core/PowertoolsEnvironment.cs
@@ -69,43 +69,34 @@ public string GetAssemblyVersion(T type)
}
///
- public void SetExecutionEnvironment(T type)
+ public void SetExecutionEnvironment(T type, string utilityName = null)
{
- const string envName = Constants.AwsExecutionEnvironmentVariableName;
+ const string envName = Constants.AWSSdkUAAppId;
var currentEnvValue = GetEnvironmentVariable(envName);
- var assemblyName = ParseAssemblyName(GetAssemblyName(type));
+ var assemblyName = utilityName != null ? $"{Constants.FeatureContextIdentifier}/{utilityName}" : ParseAssemblyName(GetAssemblyName(type));
+ var assemblyVersion = GetAssemblyVersion(type);
+ var newEntry = $"{assemblyName}/{assemblyVersion}";
- // Check for duplication early
if (!string.IsNullOrEmpty(currentEnvValue) && currentEnvValue.Contains(assemblyName))
{
return;
}
- var assemblyVersion = GetAssemblyVersion(type);
- var newEntry = $"{assemblyName}/{assemblyVersion}";
-
string finalValue;
-
+ var ptenvIndex = currentEnvValue?.IndexOf("PTENV/") ?? -1;
+
if (string.IsNullOrEmpty(currentEnvValue))
{
- // First entry: "PT/Assembly/1.0.0 PTENV/AWS_LAMBDA_DOTNET8"
finalValue = $"{newEntry} {CachedRuntimeEnvironment}";
}
+ else if (ptenvIndex >= 0)
+ {
+ // Insert newEntry before PTENV
+ finalValue = $"{currentEnvValue.Substring(0, ptenvIndex).TrimEnd()} {newEntry} {currentEnvValue.Substring(ptenvIndex)}".Trim();
+ }
else
{
- // Check if PTENV already exists in one pass
- var containsPtenv = currentEnvValue.Contains("PTENV/");
-
- if (containsPtenv)
- {
- // Just append the new entry: "existing PT/Assembly/1.0.0"
- finalValue = $"{currentEnvValue} {newEntry}";
- }
- else
- {
- // Append new entry + PTENV: "existing PT/Assembly/1.0.0 PTENV/AWS_LAMBDA_DOTNET8"
- finalValue = $"{currentEnvValue} {newEntry} {CachedRuntimeEnvironment}";
- }
+ finalValue = $"{currentEnvValue} {newEntry} {CachedRuntimeEnvironment}";
}
SetEnvironmentVariable(envName, finalValue);
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore.csproj b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore.csproj
index 5e5c66660..35757a762 100644
--- a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.AspNetCore.csproj
@@ -15,6 +15,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.csproj b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.csproj
index b0a7db73a..d403653fc 100644
--- a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.csproj
@@ -10,11 +10,13 @@
enable
true
true
+ true
+
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..09aa077a0
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..bb7f3045b
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,41 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.EventHandler.Resolvers.BedrockAgentFunction.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler/AWS.Lambda.Powertools.EventHandler.csproj b/libraries/src/AWS.Lambda.Powertools.EventHandler/AWS.Lambda.Powertools.EventHandler.csproj
index 04f632feb..2e5d5400a 100644
--- a/libraries/src/AWS.Lambda.Powertools.EventHandler/AWS.Lambda.Powertools.EventHandler.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler/AWS.Lambda.Powertools.EventHandler.csproj
@@ -11,10 +11,13 @@
enable
enable
true
+ true
+
+
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..b3d4b1e80
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.EventHandler.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.EventHandler/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.EventHandler/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..d74897cf4
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.EventHandler/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,41 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.EventHandler.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.EventHandler.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj b/libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj
index 00150b724..1f0fc14e3 100644
--- a/libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj
@@ -7,6 +7,7 @@
AWS.Lambda.Powertools.Idempotency
AWS.Lambda.Powertools.Idempotency
true
+ true
@@ -15,6 +16,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs
index 3e953e73e..d8dcdf752 100644
--- a/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Idempotency.cs
@@ -26,15 +26,6 @@ public sealed class Idempotency
///
public BasePersistenceStore PersistenceStore { get; private set; } = null!;
- ///
- /// Idempotency Constructor
- ///
- ///
- internal Idempotency(IPowertoolsConfigurations powertoolsConfigurations)
- {
- powertoolsConfigurations.SetExecutionEnvironment(this);
- }
-
///
/// Set Idempotency options
///
@@ -56,7 +47,7 @@ private void SetPersistenceStore(BasePersistenceStore persistenceStore)
///
/// Holds the idempotency Instance:
///
- internal static Idempotency Instance { get; } = new(PowertoolsConfigurations.Instance);
+ internal static Idempotency Instance { get; } = new();
///
/// Use this method to configure persistence layer (mandatory) and idempotency options (optional)
diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..392d6f2e4
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.Idempotency.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Idempotency/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..613932f4e
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,45 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Idempotency.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Idempotency.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/AWS.Lambda.Powertools.Kafka.Avro.csproj b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/AWS.Lambda.Powertools.Kafka.Avro.csproj
index bb0741616..a72f0e7ce 100644
--- a/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/AWS.Lambda.Powertools.Kafka.Avro.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/AWS.Lambda.Powertools.Kafka.Avro.csproj
@@ -11,6 +11,7 @@
false
enable
enable
+ true
@@ -21,6 +22,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..a7dde23f7
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.Kafka.Avro.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Avro");
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..4adc0dd76
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Avro/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,40 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Kafka.Avro.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Kafka.Avro.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Json/AWS.Lambda.Powertools.Kafka.Json.csproj b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/AWS.Lambda.Powertools.Kafka.Json.csproj
index 3c5ec81c4..1a26f5f97 100644
--- a/libraries/src/AWS.Lambda.Powertools.Kafka.Json/AWS.Lambda.Powertools.Kafka.Json.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/AWS.Lambda.Powertools.Kafka.Json.csproj
@@ -10,6 +10,7 @@
false
enable
enable
+ true
@@ -18,6 +19,10 @@
$(DefineConstants);KAFKA_JSON
+
+
+
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Json/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..1bdc5e4cf
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.Kafka.Json.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Json");
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Json/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..599d72032
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Json/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,40 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Kafka.Json.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Kafka.Json.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/AWS.Lambda.Powertools.Kafka.Protobuf.csproj b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/AWS.Lambda.Powertools.Kafka.Protobuf.csproj
index eef178732..d424ebfa9 100644
--- a/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/AWS.Lambda.Powertools.Kafka.Protobuf.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/AWS.Lambda.Powertools.Kafka.Protobuf.csproj
@@ -10,6 +10,7 @@
false
enable
enable
+ true
@@ -20,6 +21,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..92734b67e
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/Internal/EnvWrapper.cs
@@ -0,0 +1,12 @@
+using AWS.Lambda.Powertools.Common;
+
+namespace AWS.Lambda.Powertools.Kafka.Protobuf.Internal
+{
+ public static class EnvWrapper
+ {
+ public static void SetExecutionEnvironment()
+ {
+ PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper), "Kafka.Protobuf");
+ }
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..cd07ebd8c
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka.Protobuf/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,40 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Kafka.Protobuf.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Kafka.Protobuf.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Kafka/AWS.Lambda.Powertools.Kafka.csproj b/libraries/src/AWS.Lambda.Powertools.Kafka/AWS.Lambda.Powertools.Kafka.csproj
index d947528d6..040a27349 100644
--- a/libraries/src/AWS.Lambda.Powertools.Kafka/AWS.Lambda.Powertools.Kafka.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Kafka/AWS.Lambda.Powertools.Kafka.csproj
@@ -17,5 +17,4 @@
-
diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj b/libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj
index ccf8c3ead..dd19b43bf 100644
--- a/libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Logging/AWS.Lambda.Powertools.Logging.csproj
@@ -7,6 +7,7 @@
AWS.Lambda.Powertools.Logging
AWS.Lambda.Powertools.Logging
true
+ true
@@ -16,6 +17,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..5a50f7be2
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/EnvWrapper.cs
@@ -0,0 +1,11 @@
+using AWS.Lambda.Powertools.Common;
+namespace AWS.Lambda.Powertools.Logging.Internal
+{
+public static class EnvWrapper
+{
+public static void SetExecutionEnvironment()
+{
+PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+}
+}
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLoggerProvider.cs b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLoggerProvider.cs
index 8c16a0ac5..e9ec415e6 100644
--- a/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLoggerProvider.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Logging/Internal/PowertoolsLoggerProvider.cs
@@ -24,10 +24,7 @@ public PowertoolsLoggerProvider(
{
_powertoolsConfigurations = powertoolsConfigurations;
_currentConfig = config;
-
- // Set execution environment
- _powertoolsConfigurations.SetExecutionEnvironment(this);
-
+
// Apply environment configurations if available
ConfigureFromEnvironment();
}
diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Logging/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..b5f7a0f14
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Logging/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,45 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Logging.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+ using AWS.Lambda.Powertools.Common;
+
+ namespace AWS.Lambda.Powertools.Logging.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj b/libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj
index 77ec07a3a..60e71bb31 100644
--- a/libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Metrics/AWS.Lambda.Powertools.Metrics.csproj
@@ -6,9 +6,11 @@
AWS.Lambda.Powertools.Metrics
AWS.Lambda.Powertools.Metrics
true
+ true
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..ecd156499
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Metrics/Internal/EnvWrapper.cs
@@ -0,0 +1,11 @@
+using AWS.Lambda.Powertools.Common;
+namespace AWS.Lambda.Powertools.Metrics.Internal
+{
+public static class EnvWrapper
+{
+public static void SetExecutionEnvironment()
+{
+PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+}
+}
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs
index 9cf95ec51..60baa3623 100644
--- a/libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs
@@ -163,7 +163,6 @@ internal Metrics(IPowertoolsConfigurations powertoolsConfigurations, string name
_disabled = _powertoolsConfigurations.MetricsDisabled;
Instance = this;
- _powertoolsConfigurations.SetExecutionEnvironment(this);
// set namespace and service always
SetNamespace(nameSpace);
diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Metrics/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..e7117d767
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Metrics/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,44 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Metrics.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Metrics.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/AWS.Lambda.Powertools.Parameters.csproj b/libraries/src/AWS.Lambda.Powertools.Parameters/AWS.Lambda.Powertools.Parameters.csproj
index 526f66943..2d06227eb 100644
--- a/libraries/src/AWS.Lambda.Powertools.Parameters/AWS.Lambda.Powertools.Parameters.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Parameters/AWS.Lambda.Powertools.Parameters.csproj
@@ -9,6 +9,7 @@
AWS.Lambda.Powertools.Parameters
AWS.Lambda.Powertools.Parameters
true
+ true
@@ -20,6 +21,7 @@
+
diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..fdae6c84f
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/EnvWrapper.cs
@@ -0,0 +1,11 @@
+using AWS.Lambda.Powertools.Common;
+namespace AWS.Lambda.Powertools.Parameters.Internal
+{
+public static class EnvWrapper
+{
+public static void SetExecutionEnvironment()
+{
+PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+}
+}
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/Provider/ParameterProviderBaseHandler.cs b/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/Provider/ParameterProviderBaseHandler.cs
index 05bc237c6..43ed80db2 100644
--- a/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/Provider/ParameterProviderBaseHandler.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Parameters/Internal/Provider/ParameterProviderBaseHandler.cs
@@ -13,7 +13,6 @@
* permissions and limitations under the License.
*/
-using AWS.Lambda.Powertools.Common;
using AWS.Lambda.Powertools.Parameters.Cache;
using AWS.Lambda.Powertools.Parameters.Configuration;
using AWS.Lambda.Powertools.Parameters.Internal.Cache;
@@ -90,16 +89,13 @@ internal class ParameterProviderBaseHandler : IParameterProviderBaseHandler
/// The parameter provider GetAsync callback handler.
/// The parameter provider GetMultipleAsync callback handler.
/// The CacheMode.
- /// The Powertools for AWS Lambda (.NET) configurations.
internal ParameterProviderBaseHandler(GetAsyncDelegate getAsyncHandler,
GetMultipleAsyncDelegate getMultipleAsyncHandler,
- ParameterProviderCacheMode cacheMode,
- IPowertoolsConfigurations powertoolsConfigurations)
+ ParameterProviderCacheMode cacheMode)
{
_getAsyncHandler = getAsyncHandler;
_getMultipleAsyncHandler = getMultipleAsyncHandler;
_cacheMode = cacheMode;
- powertoolsConfigurations.SetExecutionEnvironment(this);
}
///
diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/Provider/ParameterProvider.cs b/libraries/src/AWS.Lambda.Powertools.Parameters/Provider/ParameterProvider.cs
index e2f6c1f4f..f7e43589b 100644
--- a/libraries/src/AWS.Lambda.Powertools.Parameters/Provider/ParameterProvider.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Parameters/Provider/ParameterProvider.cs
@@ -13,7 +13,6 @@
* permissions and limitations under the License.
*/
-using AWS.Lambda.Powertools.Common;
using AWS.Lambda.Powertools.Parameters.Cache;
using AWS.Lambda.Powertools.Parameters.Transform;
using AWS.Lambda.Powertools.Parameters.Configuration;
@@ -38,8 +37,7 @@ public abstract class ParameterProvider : IParameterProvider
_handler ??= new ParameterProviderBaseHandler(
GetAsync,
GetMultipleAsync,
- CacheMode,
- PowertoolsConfigurations.Instance
+ CacheMode
);
///
diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Parameters/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..85c069162
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Parameters/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,44 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Parameters.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Parameters.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj b/libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj
index 550a8e832..7c4a24916 100644
--- a/libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj
+++ b/libraries/src/AWS.Lambda.Powertools.Tracing/AWS.Lambda.Powertools.Tracing.csproj
@@ -6,8 +6,8 @@
Powertools for AWS Lambda (.NET) - Tracing package.
AWS.Lambda.Powertools.Tracing
AWS.Lambda.Powertools.Tracing
-
true
+ true
@@ -17,8 +17,7 @@
+
-
-
\ No newline at end of file
diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/EnvWrapper.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/EnvWrapper.cs
new file mode 100644
index 000000000..568ccfa96
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/EnvWrapper.cs
@@ -0,0 +1,11 @@
+using AWS.Lambda.Powertools.Common;
+namespace AWS.Lambda.Powertools.Tracing.Internal
+{
+public static class EnvWrapper
+{
+public static void SetExecutionEnvironment()
+{
+PowertoolsEnvironment.Instance.SetExecutionEnvironment(typeof(EnvWrapper));
+}
+}
+}
diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/XRayRecorder.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/XRayRecorder.cs
index 0d4aa658b..0c546da22 100644
--- a/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/XRayRecorder.cs
+++ b/libraries/src/AWS.Lambda.Powertools.Tracing/Internal/XRayRecorder.cs
@@ -15,8 +15,6 @@ namespace AWS.Lambda.Powertools.Tracing.Internal;
internal class XRayRecorder : IXRayRecorder
{
private static IAWSXRayRecorder _awsxRayRecorder;
- private static IPowertoolsConfigurations _powertoolsConfigurations;
-
///
/// The instance
///
@@ -32,9 +30,7 @@ internal class XRayRecorder : IXRayRecorder
public XRayRecorder(IAWSXRayRecorder awsxRayRecorder, IPowertoolsConfigurations powertoolsConfigurations)
{
_instance = this;
- _powertoolsConfigurations = powertoolsConfigurations;
- _powertoolsConfigurations.SetExecutionEnvironment(this);
- _isLambda = _powertoolsConfigurations.IsLambdaEnvironment;
+ _isLambda = powertoolsConfigurations.IsLambdaEnvironment;
_awsxRayRecorder = awsxRayRecorder;
}
@@ -42,7 +38,7 @@ public XRayRecorder(IAWSXRayRecorder awsxRayRecorder, IPowertoolsConfigurations
/// Checks whether current execution is in AWS Lambda.
///
/// Returns true if current execution is in AWS Lambda.
- private static bool _isLambda;
+ private readonly bool _isLambda;
///
/// Gets the emitter.
diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/SourceGenerators/UASourceGenerator.cs b/libraries/src/AWS.Lambda.Powertools.Tracing/SourceGenerators/UASourceGenerator.cs
new file mode 100644
index 000000000..5250b33c2
--- /dev/null
+++ b/libraries/src/AWS.Lambda.Powertools.Tracing/SourceGenerators/UASourceGenerator.cs
@@ -0,0 +1,44 @@
+#if NET8_0_OR_GREATER
+
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace AWS.Lambda.Powertools.Tracing.SourceGenerators;
+
+///
+/// Source generator that automatically sets the AWS_SDK_UA_APP_ID environment variable
+///
+[Generator]
+public class UASourceGenerator : IIncrementalGenerator
+{
+ ///
+ /// Initializes the source generator.
+ ///
+ ///
+ public void Initialize(IncrementalGeneratorInitializationContext context)
+ {
+ context.RegisterPostInitializationOutput(ctx =>
+ {
+ var source = """
+ //
+ using System.Runtime.CompilerServices;
+
+ namespace AWS.Lambda.Powertools.Tracing.Internal
+ {
+ internal static class UAModuleInitializer
+ {
+ [ModuleInitializer]
+ internal static void Initialize()
+ {
+ EnvWrapper.SetExecutionEnvironment();
+ }
+ }
+ }
+ """;
+ ctx.AddSource("UAModuleInitializer.g.cs", SourceText.From(source, Encoding.UTF8));
+ });
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/libraries/src/DIrectory.Build.targets b/libraries/src/DIrectory.Build.targets
new file mode 100644
index 000000000..e0de40b80
--- /dev/null
+++ b/libraries/src/DIrectory.Build.targets
@@ -0,0 +1,30 @@
+
+
+
+ $(RootNamespace)
+ $(ProjectDir)Internal/EnvWrapper.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props
index 7d1e38a66..82e9bd0be 100644
--- a/libraries/src/Directory.Build.props
+++ b/libraries/src/Directory.Build.props
@@ -17,7 +17,8 @@
true
true
$(VersionSuffix)
-
+ RS1041
+ RS1036
@@ -39,6 +40,7 @@
+
Common\%(RecursiveDir)%(Filename)%(Extension)
diff --git a/libraries/src/Directory.Packages.props b/libraries/src/Directory.Packages.props
index be5d56855..c75c47b2f 100644
--- a/libraries/src/Directory.Packages.props
+++ b/libraries/src/Directory.Packages.props
@@ -16,6 +16,7 @@
+
diff --git a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/BatchProcessingTests.cs b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/BatchProcessingTests.cs
index a59866e76..e1738657e 100644
--- a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/BatchProcessingTests.cs
+++ b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/BatchProcessingTests.cs
@@ -61,8 +61,8 @@ public async Task SqsBatchProcessor_StandardQueue_ContinueOnBatchItemFailure()
}
}
};
- var configurations = Substitute.For();
- var batchProcessor = new SqsBatchProcessor(configurations);
+
+ var batchProcessor = new SqsBatchProcessor();
var recordHandler = Substitute.For>();
recordHandler.WhenForAnyArgs(x => x.HandleAsync(Arg.Any(), Arg.Any()))
@@ -108,8 +108,8 @@ public async Task SqsBatchProcessor_FifoQueue_StopOnFirstBatchItemFailure_FirstI
}
}
};
- var configurations = Substitute.For();
- var batchProcessor = new SqsBatchProcessor(configurations);
+
+ var batchProcessor = new SqsBatchProcessor();
var recordHandler = Substitute.For>();
@@ -159,8 +159,8 @@ public async Task SqsBatchProcessor_FifoQueue_StopOnFirstBatchItemFailure_Second
}
}
};
- var configurations = Substitute.For();
- var batchProcessor = new SqsBatchProcessor(configurations);
+
+ var batchProcessor = new SqsBatchProcessor();
var recordHandler = Substitute.For>();
recordHandler.WhenForAnyArgs(x => x.HandleAsync(Arg.Any(), Arg.Any()))
@@ -209,8 +209,8 @@ public async Task SqsBatchProcessor_Parallel_StandardQueue_ContinueOnBatchItemFa
}
}
};
- var configurations = Substitute.For();
- var batchProcessor = new SqsBatchProcessor(configurations);
+
+ var batchProcessor = new SqsBatchProcessor();
var recordHandler = Substitute.For>();
recordHandler.WhenForAnyArgs(x => x.HandleAsync(Arg.Any(), Arg.Any()))
diff --git a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Internal/BatchProcessingInternalTests.cs b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Internal/BatchProcessingInternalTests.cs
deleted file mode 100644
index ed12994a4..000000000
--- a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/Internal/BatchProcessingInternalTests.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using AWS.Lambda.Powertools.BatchProcessing.DynamoDb;
-using AWS.Lambda.Powertools.BatchProcessing.Kinesis;
-using AWS.Lambda.Powertools.BatchProcessing.Sqs;
-using AWS.Lambda.Powertools.Common;
-using NSubstitute;
-using Xunit;
-
-namespace AWS.Lambda.Powertools.BatchProcessing.Tests.Internal;
-
-public class BatchProcessingInternalTests
-{
- [Fact]
- public void BatchProcessing_Set_Execution_Environment_Context_SQS()
- {
- // Arrange
- var env = new PowertoolsEnvironment();
- var conf = new PowertoolsConfigurations(env);
-
- // Act
- var sqsBatchProcessor = new SqsBatchProcessor(conf);
-
- // Assert
- Assert.Contains($"{Constants.FeatureContextIdentifier}/BatchProcessing/",
- env.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
-
- Assert.NotNull(sqsBatchProcessor);
- }
-
- [Fact]
- public void BatchProcessing_Set_Execution_Environment_Context_Kinesis()
- {
- // Arrange
- var env = new PowertoolsEnvironment();
- var conf = new PowertoolsConfigurations(env);
-
- // Act
- var KinesisEventBatchProcessor = new KinesisEventBatchProcessor(conf);
-
- // Assert
- Assert.Contains($"{Constants.FeatureContextIdentifier}/BatchProcessing/",
- env.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
-
- Assert.NotNull(KinesisEventBatchProcessor);
- }
-
- [Fact]
- public void BatchProcessing_Set_Execution_Environment_Context_DynamoDB()
- {
- // Arrange
- var env = new PowertoolsEnvironment();
- var conf = new PowertoolsConfigurations(env);
-
- // Act
- var dynamoDbStreamBatchProcessor = new DynamoDbStreamBatchProcessor(conf);
-
- // Assert
- Assert.Contains($"{Constants.FeatureContextIdentifier}/BatchProcessing/",
- env.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
-
- Assert.NotNull(dynamoDbStreamBatchProcessor);
- }
-}
\ No newline at end of file
diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsConfigurationsTest.cs b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsConfigurationsTest.cs
index 934a162cd..5e4503072 100644
--- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsConfigurationsTest.cs
+++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsConfigurationsTest.cs
@@ -533,27 +533,6 @@ public void IsLambdaEnvironment_WhenEnvironmentHasValue_ReturnsTrue()
Assert.True(result);
}
- [Fact]
- public void Set_Lambda_Execution_Context()
- {
- // Arrange
- var environment = Substitute.For();
-
- // environment.Setup(c =>
- // c.SetExecutionEnvironment(GetType())
- // );
-
- var configurations = new PowertoolsConfigurations(environment);
-
- // Act
- configurations.SetExecutionEnvironment(typeof(PowertoolsConfigurations));
-
- // Assert
- // method with correct type was called
- environment.Received(1)
- .SetExecutionEnvironment(Arg.Is(i => i == typeof(PowertoolsConfigurations)));
- }
-
#endregion
}
}
\ No newline at end of file
diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs
index 9f9e153cb..1b3adbe1e 100644
--- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs
+++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs
@@ -20,7 +20,7 @@ public void Set_Execution_Environment()
powertoolsEnv.SetExecutionEnvironment(this);
// Assert
- Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
+ Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_SDK_UA_APP_ID"));
}
[Fact]
@@ -29,13 +29,13 @@ public void Set_Execution_Environment_WhenEnvironmentHasValue()
// Arrange
var powertoolsEnv = new PowertoolsEnvironment();
- powertoolsEnv.SetEnvironmentVariable("AWS_EXECUTION_ENV", "ExistingValuesInUserAgent");
+ powertoolsEnv.SetEnvironmentVariable("AWS_SDK_UA_APP_ID", "ExistingValuesInUserAgent");
// Act
powertoolsEnv.SetExecutionEnvironment(this);
// Assert
- Assert.Equal($"ExistingValuesInUserAgent {Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
+ Assert.Equal($"ExistingValuesInUserAgent {Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_SDK_UA_APP_ID"));
}
[Fact]
@@ -49,7 +49,7 @@ public void Set_Same_Execution_Environment_Multiple_Times_Should_Only_Set_Once()
powertoolsEnv.SetExecutionEnvironment(this);
// Assert
- Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
+ Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}", powertoolsEnv.GetEnvironmentVariable("AWS_SDK_UA_APP_ID"));
}
[Fact]
@@ -63,8 +63,8 @@ public void Set_Multiple_Execution_Environment()
powertoolsEnv.SetExecutionEnvironment(powertoolsEnv.GetType());
// Assert
- Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major} {Constants.FeatureContextIdentifier}/Common/1.0.0",
- powertoolsEnv.GetEnvironmentVariable("AWS_EXECUTION_ENV"));
+ Assert.Equal($"{Constants.FeatureContextIdentifier}/Tests/1.0.0 {Constants.FeatureContextIdentifier}/Common/1.0.0 PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}",
+ powertoolsEnv.GetEnvironmentVariable("AWS_SDK_UA_APP_ID"));
}
[Fact]
@@ -95,7 +95,7 @@ public void SetExecutionEnvironment_Should_Format_Strings_Correctly_With_Mocked_
// Mock the dependencies to return controlled values
mockEnvironment.GetAssemblyName(Arg.Any