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

[Instrumentation.AWSLambda] Update to net6.0 #1545

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public static class AWSLambdaWrapper
private static readonly AssemblyName AssemblyName = typeof(AWSLambdaWrapper).Assembly.GetName();

[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Initialization order.")]
internal static readonly string ActivitySourceName = AssemblyName.Name;
internal static readonly string? ActivitySourceName = AssemblyName.Name;

private static readonly Version Version = AssemblyName.Version;
private static readonly ActivitySource AWSLambdaActivitySource = new(ActivitySourceName, Version.ToString());
private static readonly Version? Version = AssemblyName.Version;
private static readonly ActivitySource AWSLambdaActivitySource = new(ActivitySourceName ?? "OpenTelemetry.Instrumentation.AWSLambda", Version?.ToString());
martincostello marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets or sets a value indicating whether AWS X-Ray propagation should be ignored. Default value is false.
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.Instrumentation.AWSLambda/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
If null state analysis is enabled in your depending project, you may encounter
new warnings.
([#1295](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1295))
* BREAKING: Target `net6.0` instead of `netstandard2.0`
([#1545](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1545))

## 1.2.0-beta.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ internal sealed class AWSLambdaResourceDetector : IResourceDetector
/// <returns>Detected resource.</returns>
public Resource Detect()
{
var resourceAttributes = new List<KeyValuePair<string, object>>
var resourceAttributes = new List<KeyValuePair<string, object>>(4)
{
new(AWSLambdaSemanticConventions.AttributeCloudProvider, AWSLambdaUtils.GetCloudProvider()),
new(AWSLambdaSemanticConventions.AttributeCloudRegion, AWSLambdaUtils.GetAWSRegion()),
new(AWSLambdaSemanticConventions.AttributeFaasName, AWSLambdaUtils.GetFunctionName()),
new(AWSLambdaSemanticConventions.AttributeFaasVersion, AWSLambdaUtils.GetFunctionVersion()),
};

if (AWSLambdaUtils.GetAWSRegion() is { } region)
martincostello marked this conversation as resolved.
Show resolved Hide resolved
{
resourceAttributes.Add(new(AWSLambdaSemanticConventions.AttributeCloudRegion, region));
}

if (AWSLambdaUtils.GetFunctionName() is { } functionName)
{
resourceAttributes.Add(new(AWSLambdaSemanticConventions.AttributeFaasName, functionName));
}

if (AWSLambdaUtils.GetFunctionVersion() is { } functionVersion)
{
resourceAttributes.Add(new(AWSLambdaSemanticConventions.AttributeFaasVersion, functionVersion));
}

return new Resource(resourceAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ internal static string GetCloudProvider()
return CloudProvider;
}

internal static string GetAWSRegion()
internal static string? GetAWSRegion()
{
return Environment.GetEnvironmentVariable(AWSRegion);
}

internal static string GetFunctionName(ILambdaContext? context = null)
internal static string? GetFunctionName(ILambdaContext? context = null)
{
return context?.FunctionName ?? Environment.GetEnvironmentVariable(FunctionName);
}

internal static string GetFunctionVersion()
internal static string? GetFunctionVersion()
{
return Environment.GetEnvironmentVariable(FunctionVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ internal static PropagationContext ExtractParentContext(SNSEvent.SNSMessage? mes

var body = sqsMessage.Body;
if (body != null &&
body.TrimStart().StartsWith("{", StringComparison.Ordinal) &&
body.Contains(SnsMessageAttributes))
body.TrimStart().StartsWith('{') &&
body.Contains(SnsMessageAttributes, StringComparison.Ordinal))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>AWS Lambda tracing wrapper for OpenTelemetry .NET</Description>
<PackageTags>$(PackageTags);AWS Lambda</PackageTags>
<MinVerTagPrefix>Instrumentation.AWSLambda-</MinVerTagPrefix>
Expand Down
Loading