-
Notifications
You must be signed in to change notification settings - Fork 288
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
[Instrumentation.AWSLambda] Fix AoT warnings #1544
Merged
Kielek
merged 2 commits into
open-telemetry:main
from
martincostello:instrumentation-awslambda-aot
Jan 24, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/OpenTelemetry.Instrumentation.AWSLambda/SourceGenerationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Text.Json.Serialization; | ||
using Amazon.Lambda.SNSEvents; | ||
|
||
namespace OpenTelemetry.Instrumentation.AWSLambda; | ||
|
||
/// <summary> | ||
/// "Source Generation" is feature added to System.Text.Json in .NET 6.0. | ||
/// This is a performance optimization that avoids runtime reflection when performing serialization. | ||
/// Serialization metadata will be computed at compile-time and included in the assembly. | ||
/// <see href="https://learn.microsoft.com/dotnet/standard/serialization/system-text-json/source-generation-modes" />. | ||
/// <see href="https://learn.microsoft.com/dotnet/standard/serialization/system-text-json/source-generation" />. | ||
/// <see href="https://devblogs.microsoft.com/dotnet/try-the-new-system-text-json-source-generator/" />. | ||
/// </summary> | ||
[JsonSerializable(typeof(SNSEvent.SNSMessage))] | ||
martincostello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
internal sealed partial class SourceGenerationContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is raising the lower bound of these dependencies necessary? In particular this one from major version 1 to 2? After all, these define which versions we can instrument. If so, please add a changelog entry (Sth like: Amazon Lambda package Versions below 2.1 no longer supported, see package dependencies for details)
(Or maybe this dependency was even already overridden by a transitive dependency through another Amazon.Lambda.* dependency where we were already using 2.x?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These versions all correlate to the versions that first introduced support for native AoT: CHANGELOG.
Version 2.1.0 of Amazon.Lambda.Core is the first version that added explicit support for
net6.0
, which was required by the changes asked for in #1545, and the only release since then was the 2.2.0 release fornet8.0
support that resolves the native AoT warnings.Based on that, I think these are reasonable increases to require of users while also making this assembly usable without trim warnings in native AoT applications. There were also already breaking changes listed in the CHANGELOG for this library before this PR or #1545.
Thoughts @normj?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, because I assume the following:
Based on what you write with the .NET 6 support, an upgrade to 2.1 is totally reasonable without question, but I wonder about 2.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can downgrade it a bit in my native AoT Lambda using .NET 8 and see if I get any IL warnings (martincostello/alexa-london-travel#1020) or not.
My library does already specify its own dependencies for the Lambda assemblies it needs, but I don't use API Gateway, SNS or SQS, but I get all of those dependencies via this library transiently. Needing the end-user to manually upgrade the transient dependencies to get it to work properly for native AoT isn't ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This is not ideal anyway. I don't think there is a way to have these as compile-only dependencies and then check at runtime if they are actually present? (But this of course goes way beyond the scope of this PR anyways)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Norm might know some tricks for dealing with that as the core AWS SDKs have to do similar things for things like STS authentication via the built-in fallback credential providers, but yeah that's a bit of a spiral out of the original scope here 😅.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I can't think of any special tricks here. The only difference between 2.1 and 2.2 for Amazon.Lambda.Core is updates to the project file to have the .NET 8 target and mark the package trimmable for .NET 8 if that makes you feel better taking the updated dependency.