Skip to content

Conversation

@hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Jul 21, 2025

Please provide the issue number

Issue number: #933

Summary

Changes

This pull request introduces a new constant, AWS_SDK_UA_APP_ID, to represent a unique application ID for the User-Agent header, replacing the previous use of AWS_EXECUTION_ENV in the codebase. The changes involve updating constants, interfaces, implementations, and test cases to reflect this new environment variable.

Global configuration with Module Initializers

All projects now have these two new internal classes

  • Static Environment Variable Wrapper that sets environment variable
  • Module initializer that calls the EnvWrapper, Target template

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@boring-cyborg boring-cyborg bot added area/common Core Powertools utility tests labels Jul 21, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 21, 2025
@hjgraca hjgraca requested a review from dreamorosi July 21, 2025 09:56
@github-actions github-actions bot added the internal Maintenance changes label Jul 21, 2025
@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.88%. Comparing base (4c3c3ce) to head (531eb6a).
⚠️ Report is 45 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #934      +/-   ##
===========================================
- Coverage    77.89%   77.88%   -0.01%     
===========================================
  Files          287      298      +11     
  Lines        11444    11440       -4     
  Branches      1346     1348       +2     
===========================================
- Hits          8914     8910       -4     
+ Misses        2099     2098       -1     
- Partials       431      432       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dreamorosi dreamorosi linked an issue Jul 21, 2025 that may be closed by this pull request
2 tasks
hjgraca added 6 commits July 29, 2025 15:29
… variable handling

- Replace Microsoft.CodeAnalysis.Analyzers and CSharp with Microsoft.CodeAnalysis.Common in central package management and project files
- Add Microsoft.CodeAnalysis.Common package reference to relevant projects
- Remove unused source generator file reference from Kafka project
- Refactor PowertoolsEnvironment to improve UA environment variable string construction and PTENV placement logic
- Update UASetter test to use ITestOutputHelper and add assertions for PTENV position and output
…ate source generator output

- Introduce EnvWrapper helper in each utility for setting execution environment
- Update source generator to use EnvWrapper in generated module initializers
- Add IncludeExecutionEnvironment property to project files for conditional EnvWrapper inclusion
- Add Directory.Build.targets to automate EnvWrapper generation in Release builds
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 29, 2025
hjgraca added 13 commits July 29, 2025 15:38
…ls.SourceGenerator.Tests/AWS.Lambda.Powertools.SourceGenerator.Tests.csproj to include both:

OutputItemType="Analyzer" - to enable the source generators
ReferenceOutputAssembly="true" - to also load the actual assemblies at runtime
@@ -0,0 +1,42 @@
<Project>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each project with have a targets file - this file is executed by MsBuild, the builder and compiled with the code that references our Nuget packages, making it possible to run this on adding Powertools nuget to a project

@@ -0,0 +1,18 @@
using AWS.Lambda.Powertools.Common;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each project has an eventwrapper class

/// Cached runtime environment string
/// </summary>
private static readonly string CachedRuntimeEnvironment = $"PTENV/AWS_LAMBDA_DOTNET{Environment.Version.Major}";
private static readonly string CachedRuntimeEnvironment = $"PTENV/{Environment.GetEnvironmentVariable(Constants.AwsExecutionEnvironmentVariableName)}";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we get the value from the Execution environemtn and not hardcoded to lambda

@sonarqubecloud
Copy link

@hjgraca hjgraca merged commit 26a3084 into develop Sep 26, 2025
9 checks passed
@hjgraca hjgraca deleted the chore/ua-change-env branch September 26, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/common Core Powertools utility area/idempotency internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: UA change from AWS_EXECUTION_ENV to AWS_SDK_UA_APP_ID

2 participants