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

chore: AOT support for Logging and Metrics #557

Open
wants to merge 107 commits into
base: aot-support
Choose a base branch
from

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Feb 21, 2024

Please provide the issue number

Issue number: #212

Summary

  • Logging AOT support
  • Metrics AOT support

Changes

  • Logging
    • Remove Logging lambda context reflection
    • Add PowertoolsSourceGenerationContext for types discovery at compile time
  • Metrics
    • Add MetricsSerializationContext for types discovery at compile time

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.

Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
@boring-cyborg boring-cyborg bot added area/common Core Powertools utility area/logging Core logging utility area/metrics Core metrics utility area/parameters area/tracing Core tracing utility tests labels Feb 21, 2024
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 21, 2024
@hjgraca hjgraca added aot do-not-merge PRs that are blocked for varying reasons labels Feb 21, 2024
@github-actions github-actions bot added the internal Maintenance changes label Feb 21, 2024
@hjgraca hjgraca changed the title chore: Aot support for Logging and Metrics (WIP) chore: AOT support for Logging and Metrics Feb 21, 2024
@hjgraca hjgraca changed the title chore: AOT support for Logging and Metrics chore: AOT support for Logging and Metrics Feb 21, 2024
hjgraca added 19 commits May 9, 2024 10:09
…owertools

feat(idempotency): add internal powertools JMESPath support
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
…sion-release-1-10

chore: Update idempotency version for release 1.10.0
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
…mpotency-examples

chore: Update idempotency examples for release 1..10.0
…ety-bug

chore: Metrics - Add thread safety to AddMetric
Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com>
@JDurstberger
Copy link

JDurstberger commented May 21, 2024

Hello.

I am running into issues when using the updated logging lib.
I see the following runtime error:

Unhandled Exception: System.NotSupportedException: 
'AWS.Lambda.Powertools.Common.UniversalWrapperAttribute.WrapAsync[System.Threading.Tasks.VoidTaskResult](System.Func`2[System.Object[],System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult]],System.Object[],AWS.Lambda.Powertools.Common.AspectEventArgs)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. 
Inspect and fix AOT related warnings that were generated when the app was published. 
For more information see https://aka.ms/nativeaot-compatibility

This seems to happen immediately at start up.
I am setting the logger on an .NET minimal API using

builder.Logging.ClearProviders();
builder.Logging.AddProvider(new LoggerProvider());

Where LogProvider is

using AWS.Lambda.Powertools.Logging;

public class LoggerProvider : ILoggerProvider
{
  public ILogger CreateLogger(string categoryName)
  {
    return Logger.Create(categoryName);
  }

  public void Dispose()
  {
    GC.SuppressFinalize(this);
  }
}

Any idea what could be the root cause?

@hjgraca
Copy link
Contributor Author

hjgraca commented May 22, 2024

Hey @JDurstberger what version are you using? Is this for an AOT enabled application?
The AOT version is still alpha, and I haven't tested yet with minimal apis AOT.

…ate-version-1.10.1

chore: Update version for release 1.10.1
@JDurstberger
Copy link

I was using 1.6.0-alpha with an AOT enabled application.
It looks to me like the serialization fails on messages logged by the minimal api itself.

@boring-cyborg boring-cyborg bot added area/idempotency documentation Improvements or additions to documentation github-actions Changes in GitHub workflows labels Jun 18, 2024
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aot area/common Core Powertools utility area/idempotency area/logging Core logging utility area/metrics Core metrics utility area/parameters area/tracing Core tracing utility do-not-merge PRs that are blocked for varying reasons documentation Improvements or additions to documentation github-actions Changes in GitHub workflows internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

5 participants