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

Instrumenation.AWSLambda: Drop netstandard2, lose Newtonsoft (non-)dependency #1270

Conversation

Oberon00
Copy link
Member

@Oberon00 Oberon00 commented Jul 18, 2023

Closes #1273 (alternative to that PR)

Related to a similar change in the XRay dependency: #1092

Changes

Quoting the CHANGELOG:

  • The minimum required .NET version is now .NET Core 3.1 (previously any netstandard2.0-compliant).
    As the minimum .NET version in AWS Lambda is already 6.0, no compatibility problems are expected.

    This resolves a warning that some dependency analyzers may produce where this package would transitively
    depend on a vulnerable version of Newtonsoft.Json through
    Amazon.Lambda.APIGatewayEvents.

    This also avoids a potential issue where the instrumentation would try to call a Newtonsoft.Json function
    when no other package nor the app itself depends on Newtonsoft.Json, since the transitive dependency would be
    ignored unless using application were compiled against a TargetFramework older than Core 3.1.

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • [ ] Design discussion issue # N/A
  • [ ] Changes in public API reviewed API remains identical

@github-actions github-actions bot requested a review from rypdal July 18, 2023 15:04
@Oberon00
Copy link
Member Author

Oberon00 commented Jul 18, 2023

BTW, it seems we are using an outdated tool dotnet-format instead of the built-in dotnet format subcommand in CI. The former seems to be completely confused by raw string literals.

@@ -72,6 +72,47 @@ public void ExtractParentContext_SetParentFromMessageBatchIsEnabled_ParentIsSetF
Assert.Equal(2, links.Count());
}

[Fact]
public void ExtractParentContext_SetParentFromMessageBatchIsEnabled_ParentIsSetFromSnsMessage()
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this test, while generally IMHO useful, did not catch the error about the broken Newtonsoft dependency, because the MS test framework itself pulls in a Newtonsoft.Json assembly. Probably a integration test would be needed to see the issue, but since I never added one and wouldn't know how to do it, I skipped on that.

@Oberon00
Copy link
Member Author

Oberon00 commented Jul 18, 2023

One unrelated build failure, added to #716 (comment)

@Oberon00 Oberon00 mentioned this pull request Jul 18, 2023
@Oberon00 Oberon00 marked this pull request as ready for review July 19, 2023 06:53
@Oberon00 Oberon00 requested a review from a team July 19, 2023 06:53
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change it to net6.0? netcoreapp3.1 is deprecated and might leads to issues in CI.

Copy link
Member Author

Choose a reason for hiding this comment

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

It already passed CI though (except for a timeout in the coverage build).

I wouldn't want to switch right to 6. If netcoreapp3.1 is a problem, I'd stay on netstandard2.0 and add a conditional dependency on System.Text.Json just like in #1092

Copy link
Contributor

Choose a reason for hiding this comment

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

As the minimum .NET version in AWS Lambda is already 6.0, no compatibility problems are expected.

@Oberon00 Why do you not want to target net6.0, when the minimum runtime version required by ASWLambda is net6.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

.NET 6 is not even 2 years old. And while the .NET 6 runtime is the oldest one supported by AWS, you should still be able compile your app against older versions and run them. Also, you could use a containerized runtime with an older version.

That's why I'd prefer not to use such a recent version as minimum, especially when it's only a bugfix.

Copy link
Member Author

Choose a reason for hiding this comment

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

I created PR #1273 as an alternative to this, where I do not touch the .NET version at all, staying on netstandard2.0, adding an explicit dependency on Newtonsoft.Json instead.

Probably the .NET version upgrade should be done after the next release of the package.

Copy link
Contributor

@utpilla utpilla Jul 20, 2023

Choose a reason for hiding this comment

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

.NET 6 is marked for LTS (long-term support) by .NET team and if AWS Lambda has chosen it as the minimum version, then it makes sense for its corresponding instrumentation library to do the same.

https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core

Copy link
Contributor

Choose a reason for hiding this comment

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

For AWS Lambda, is it possible for a consuming application to be targeting something lower than .NET 6? If not, then why would you be bothered by any of the lower and older targets?

Copy link
Member Author

Choose a reason for hiding this comment

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

@utpilla #1270 (comment):

you should still be able compile your app against older versions and run them. Also, you could use a containerized runtime with an older version.

To elaborate on the containerized runtime: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html

I do think we should raise the requirement to net6 eventually, but not for a bugfix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets do opposite.

  1. Create PR with .NET 6 bump.
  2. As a follow up, fix this issue.

Copy link
Member Author

@Oberon00 Oberon00 Jul 21, 2023

Choose a reason for hiding this comment

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

I'd prefer:

  1. Merge a PR without a bump to net 6 (this or Instrumentation.AWSLambda: Upgrade & explicitly depend on Newtonsoft.Json #1273)
  2. Publish a release
  3. .NET 6 bump

@utpilla utpilla added the comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants