diff --git a/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..7dc5c58110 --- /dev/null +++ b/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..1362c26ff9 --- /dev/null +++ b/src/OpenTelemetry.Instrumentation.AWS/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,8 @@ +#nullable enable +OpenTelemetry.Instrumentation.AWS.AWSClientInstrumentationOptions +OpenTelemetry.Instrumentation.AWS.AWSClientInstrumentationOptions.AWSClientInstrumentationOptions() -> void +OpenTelemetry.Instrumentation.AWS.AWSClientInstrumentationOptions.SuppressDownstreamInstrumentation.get -> bool +OpenTelemetry.Instrumentation.AWS.AWSClientInstrumentationOptions.SuppressDownstreamInstrumentation.set -> void +OpenTelemetry.Trace.TracerProviderBuilderExtensions +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAWSInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAWSInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md index a1c1add753..b64dfe884f 100644 --- a/src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AWS/CHANGELOG.md @@ -4,6 +4,10 @@ * Updated dependency on AWS .NET SDK to version 3.7.300. ([#1542](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1542)) +* Add target for `net6.0`. + ([#1547](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1547)) +* Add support for native AoT. + ([#1547](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1547)) ## 1.1.0-beta.2 diff --git a/src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSTracingPipelineHandler.cs b/src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSTracingPipelineHandler.cs index 4ec869eedb..2383c9f8ba 100644 --- a/src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSTracingPipelineHandler.cs +++ b/src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSTracingPipelineHandler.cs @@ -14,17 +14,17 @@ namespace OpenTelemetry.Instrumentation.AWS.Implementation; -internal class AWSTracingPipelineHandler : PipelineHandler +internal sealed class AWSTracingPipelineHandler : PipelineHandler { internal const string ActivitySourceName = "Amazon.AWS.AWSClientInstrumentation"; - private static readonly AWSXRayPropagator AwsPropagator = new AWSXRayPropagator(); + private static readonly AWSXRayPropagator AwsPropagator = new(); private static readonly Action, string, string> Setter = (carrier, name, value) => { carrier[name] = value; }; - private static readonly ActivitySource AWSSDKActivitySource = new ActivitySource(ActivitySourceName); + private static readonly ActivitySource AWSSDKActivitySource = new(ActivitySourceName); private readonly AWSClientInstrumentationOptions options; @@ -128,20 +128,34 @@ private static void ProcessException(Activity activity, Exception ex) } } +#if NET6_0_OR_GREATER + [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage( + "Trimming", + "IL2075", + Justification = "The reflected properties were already used by the AWS SDK's marshallers so the properties could not have been trimmed.")] +#endif private static void AddRequestSpecificInformation(Activity activity, IRequestContext requestContext, string service) { - if (AWSServiceHelper.ServiceParameterMap.TryGetValue(service, out string parameter)) + if (AWSServiceHelper.ServiceParameterMap.TryGetValue(service, out var parameter)) { AmazonWebServiceRequest request = requestContext.OriginalRequest; - var property = request.GetType().GetProperty(parameter); - if (property != null) + try { - if (AWSServiceHelper.ParameterAttributeMap.TryGetValue(parameter, out string attribute)) + var property = request.GetType().GetProperty(parameter); + if (property != null) { - activity.SetTag(attribute, property.GetValue(request)); + if (AWSServiceHelper.ParameterAttributeMap.TryGetValue(parameter, out var attribute)) + { + activity.SetTag(attribute, property.GetValue(request)); + } } } + catch (Exception) + { + // Guard against any reflection-related exceptions when running in AoT. + // See https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1543#issuecomment-1907667722. + } } if (AWSServiceType.IsDynamoDbService(service)) @@ -176,7 +190,7 @@ private static string FetchRequestId(IRequestContext requestContext, IResponseCo else { var request_headers = requestContext.Request.Headers; - if (string.IsNullOrEmpty(request_id) && request_headers.TryGetValue("x-amzn-RequestId", out string req_id)) + if (string.IsNullOrEmpty(request_id) && request_headers.TryGetValue("x-amzn-RequestId", out var req_id)) { request_id = req_id; } diff --git a/src/OpenTelemetry.Instrumentation.AWS/OpenTelemetry.Instrumentation.AWS.csproj b/src/OpenTelemetry.Instrumentation.AWS/OpenTelemetry.Instrumentation.AWS.csproj index b473eb7bbf..6d0c8c9a86 100644 --- a/src/OpenTelemetry.Instrumentation.AWS/OpenTelemetry.Instrumentation.AWS.csproj +++ b/src/OpenTelemetry.Instrumentation.AWS/OpenTelemetry.Instrumentation.AWS.csproj @@ -2,7 +2,7 @@ - netstandard2.0 + net6.0;netstandard2.0 $(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion) AWS client instrumentation for OpenTelemetry .NET Instrumentation.AWS- diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj index 0a8744bb88..7c7ca3a5dc 100644 --- a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj +++ b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj @@ -15,6 +15,7 @@ --> +