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

Enable Nulls on Contrib.Extensions.AWSXRay & Test Projects #920

Merged
merged 13 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
@@ -1,21 +1,22 @@
#nullable enable
OpenTelemetry.Contrib.Extensions.AWSXRay.AWSXRayIdGenerator
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.AWSEBSResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.AWSEC2ResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils.ResourceDetectorUtils() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.AWSXRayPropagator() -> void
OpenTelemetry.Resources.ResourceBuilderExtensions
OpenTelemetry.Trace.TracerProviderBuilderExtensions
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Extract<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func<T, string, System.Collections.Generic.IEnumerable<string>> getter) -> OpenTelemetry.Context.Propagation.PropagationContext
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Fields.get -> System.Collections.Generic.ISet<string>
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Inject<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action<T, string, string> setter) -> void
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceId(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder builder, OpenTelemetry.Trace.Sampler sampler) -> OpenTelemetry.Trace.TracerProviderBuilder
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Extract<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func<T, string!, System.Collections.Generic.IEnumerable<string!>!>! getter) -> OpenTelemetry.Context.Propagation.PropagationContext
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Fields.get -> System.Collections.Generic.ISet<string!>!
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Inject<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action<T, string!, string!>! setter) -> void
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddDetector(this OpenTelemetry.Resources.ResourceBuilder! resourceBuilder, OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector! resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceId(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder! builder, OpenTelemetry.Trace.Sampler! sampler) -> OpenTelemetry.Trace.TracerProviderBuilder!
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
@@ -1,30 +1,31 @@
#nullable enable
OpenTelemetry.Contrib.Extensions.AWSXRay.AWSXRayIdGenerator
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.AWSEBSResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.AWSEC2ResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.AWSECSResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.AWSEKSResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.AWSLambdaResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils.ResourceDetectorUtils() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.AWSXRayPropagator() -> void
OpenTelemetry.Resources.ResourceBuilderExtensions
OpenTelemetry.Trace.TracerProviderBuilderExtensions
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Extract<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func<T, string, System.Collections.Generic.IEnumerable<string>> getter) -> OpenTelemetry.Context.Propagation.PropagationContext
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Fields.get -> System.Collections.Generic.ISet<string>
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Inject<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action<T, string, string> setter) -> void
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceId(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder builder, OpenTelemetry.Trace.Sampler sampler) -> OpenTelemetry.Trace.TracerProviderBuilder
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Extract<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func<T, string!, System.Collections.Generic.IEnumerable<string!>!>! getter) -> OpenTelemetry.Context.Propagation.PropagationContext
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Fields.get -> System.Collections.Generic.ISet<string!>!
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Inject<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action<T, string!, string!>! setter) -> void
static OpenTelemetry.Resources.ResourceBuilderExtensions.AddDetector(this OpenTelemetry.Resources.ResourceBuilder! resourceBuilder, OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector! resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceId(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder! builder, OpenTelemetry.Trace.Sampler! sampler) -> OpenTelemetry.Trace.TracerProviderBuilder!
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 @@ -39,7 +39,7 @@ public static class AWSXRayIdGenerator
private static readonly Random Global = new Random();
private static object randLock = new object();

internal static void ReplaceTraceId(Sampler sampler = null)
internal static void ReplaceTraceId(Sampler? sampler = null)
{
var awsXRayActivityListener = new ActivityListener
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<Description>OpenTelemetry extensions for AWS X-Ray.</Description>
<MinVerTagPrefix>Extensions.AWSXRay-</MinVerTagPrefix>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public class AWSEBSResourceDetector : IResourceDetector
/// Detector the required and optional resource attributes from AWS ElasticBeanstalk.
/// </summary>
/// <returns>List of key-value pairs of resource attributes.</returns>
public IEnumerable<KeyValuePair<string, object>> Detect()
public IEnumerable<KeyValuePair<string, object?>>? Detect()
{
List<KeyValuePair<string, object>> resourceAttributes = null;
List<KeyValuePair<string, object?>>? resourceAttributes = null;

try
{
string filePath = null;
string? filePath = null;
#if NETSTANDARD
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Expand All @@ -67,22 +67,22 @@ public IEnumerable<KeyValuePair<string, object>> Detect()
return resourceAttributes;
}

internal List<KeyValuePair<string, object>> ExtractResourceAttributes(AWSEBSMetadataModel metadata)
internal List<KeyValuePair<string, object?>>? ExtractResourceAttributes(AWSEBSMetadataModel? metadata)
{
var resourceAttributes = new List<KeyValuePair<string, object>>()
var resourceAttributes = new List<KeyValuePair<string, object?>>()
{
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudProvider, "aws"),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudPlatform, "aws_elastic_beanstalk"),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeServiceName, "aws_elastic_beanstalk"),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeServiceNamespace, metadata.EnvironmentName),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeServiceInstanceID, metadata.DeploymentId),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeServiceVersion, metadata.VersionLabel),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudProvider, "aws"),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudPlatform, "aws_elastic_beanstalk"),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeServiceName, "aws_elastic_beanstalk"),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeServiceNamespace, metadata?.EnvironmentName),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeServiceInstanceID, metadata?.DeploymentId),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeServiceVersion, metadata?.VersionLabel),
};

return resourceAttributes;
}

internal AWSEBSMetadataModel GetEBSMetadata(string filePath)
internal AWSEBSMetadataModel? GetEBSMetadata(string filePath)
{
return ResourceDetectorUtils.DeserializeFromFile<AWSEBSMetadataModel>(filePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class AWSEC2ResourceDetector : IResourceDetector
/// Detector the required and optional resource attributes from AWS EC2.
/// </summary>
/// <returns>List of key-value pairs of resource attributes.</returns>
public IEnumerable<KeyValuePair<string, object>> Detect()
public IEnumerable<KeyValuePair<string, object?>>? Detect()
{
List<KeyValuePair<string, object>> resourceAttributes = null;
List<KeyValuePair<string, object?>>? resourceAttributes = null;

try
{
Expand All @@ -55,24 +55,24 @@ public IEnumerable<KeyValuePair<string, object>> Detect()
return resourceAttributes;
}

internal List<KeyValuePair<string, object>> ExtractResourceAttributes(AWSEC2IdentityDocumentModel identity, string hostName)
internal List<KeyValuePair<string, object?>> ExtractResourceAttributes(AWSEC2IdentityDocumentModel? identity, string hostName)
{
var resourceAttributes = new List<KeyValuePair<string, object>>()
var resourceAttributes = new List<KeyValuePair<string, object?>>()
{
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudProvider, "aws"),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudPlatform, "aws_ec2"),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudAccountID, identity.AccountId),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudAvailableZone, identity.AvailabilityZone),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeHostID, identity.InstanceId),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeHostType, identity.InstanceType),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeCloudRegion, identity.Region),
new KeyValuePair<string, object>(AWSSemanticConventions.AttributeHostName, hostName),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudProvider, "aws"),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudPlatform, "aws_ec2"),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudAccountID, identity?.AccountId),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudAvailableZone, identity?.AvailabilityZone),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeHostID, identity?.InstanceId),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeHostType, identity?.InstanceType),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeCloudRegion, identity?.Region),
new KeyValuePair<string, object?>(AWSSemanticConventions.AttributeHostName, hostName),
};

return resourceAttributes;
}

internal AWSEC2IdentityDocumentModel DeserializeResponse(string response)
internal AWSEC2IdentityDocumentModel? DeserializeResponse(string response)
{
return ResourceDetectorUtils.DeserializeFromString<AWSEC2IdentityDocumentModel>(response);
}
Expand All @@ -82,7 +82,7 @@ private string GetAWSEC2Token()
return ResourceDetectorUtils.SendOutRequest(AWSEC2MetadataTokenUrl, "PUT", new KeyValuePair<string, string>(AWSEC2MetadataTokenTTLHeader, "60")).Result;
}

private AWSEC2IdentityDocumentModel GetAWSEC2Identity(string token)
private AWSEC2IdentityDocumentModel? GetAWSEC2Identity(string token)
{
var identity = this.GetIdentityResponse(token);
var identityDocument = this.DeserializeResponse(identity);
Expand Down
Loading