diff --git a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Unshipped.txt index 1fd1f60339..f09de33268 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/net462/PublicAPI.Unshipped.txt @@ -2,22 +2,22 @@ OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ExportInterval.get -> System.TimeSpan OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ExportInterval.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.get -> Google.Apis.Auth.OAuth2.GoogleCredential +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.get -> Google.Apis.Auth.OAuth2.GoogleCredential? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.get -> string +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.get -> string? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.get -> Google.Api.MonitoredResource +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.get -> Google.Api.MonitoredResource? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.get -> string +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.get -> string? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.set -> void OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.StackdriverStatsConfiguration() -> void OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter -OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.StackdriverTraceExporter(string projectId) -> void +OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.StackdriverTraceExporter(string! projectId) -> void OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils OpenTelemetry.Trace.TracerProviderBuilderExtensions -override OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult -static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetDefaultResource(string projectId) -> Google.Api.MonitoredResource -static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetProjectId() -> string -static OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.Default.get -> OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration -static OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils.Partition(this System.Collections.Generic.IEnumerable source, int size) -> System.Collections.Generic.IEnumerable> -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.UseStackdriverExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string projectId) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +override OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult +static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetDefaultResource(string? projectId) -> Google.Api.MonitoredResource! +static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetProjectId() -> string? +static OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.Default.get -> OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration! +static OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils.Partition(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.UseStackdriverExporter(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string! projectId) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 1fd1f60339..f09de33268 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Stackdriver/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -2,22 +2,22 @@ OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ExportInterval.get -> System.TimeSpan OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ExportInterval.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.get -> Google.Apis.Auth.OAuth2.GoogleCredential +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.get -> Google.Apis.Auth.OAuth2.GoogleCredential? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.GoogleCredential.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.get -> string +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.get -> string? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MetricNamePrefix.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.get -> Google.Api.MonitoredResource +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.get -> Google.Api.MonitoredResource? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.MonitoredResource.set -> void -OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.get -> string +OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.get -> string? OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.ProjectId.set -> void OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.StackdriverStatsConfiguration() -> void OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter -OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.StackdriverTraceExporter(string projectId) -> void +OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.StackdriverTraceExporter(string! projectId) -> void OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils OpenTelemetry.Trace.TracerProviderBuilderExtensions -override OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult -static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetDefaultResource(string projectId) -> Google.Api.MonitoredResource -static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetProjectId() -> string -static OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.Default.get -> OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration -static OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils.Partition(this System.Collections.Generic.IEnumerable source, int size) -> System.Collections.Generic.IEnumerable> -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.UseStackdriverExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string projectId) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +override OpenTelemetry.Exporter.Stackdriver.StackdriverTraceExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult +static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetDefaultResource(string? projectId) -> Google.Api.MonitoredResource! +static OpenTelemetry.Exporter.Stackdriver.Implementation.GoogleCloudResourceUtils.GetProjectId() -> string? +static OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration.Default.get -> OpenTelemetry.Exporter.Stackdriver.Implementation.StackdriverStatsConfiguration! +static OpenTelemetry.Exporter.Stackdriver.Utils.CommonUtils.Partition(this System.Collections.Generic.IEnumerable! source, int size) -> System.Collections.Generic.IEnumerable!>! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.UseStackdriverExporter(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string! projectId) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ActivityExtensions.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ActivityExtensions.cs index 240c2af077..36aa1f032f 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ActivityExtensions.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ActivityExtensions.cs @@ -14,8 +14,6 @@ // limitations under the License. // -#nullable enable - using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -136,25 +134,25 @@ public static AttributeValue ToAttributeValue(this object? av) switch (av) { case string s: - return new AttributeValue() + return new AttributeValue { - StringValue = new TruncatableString() { Value = s }, + StringValue = new TruncatableString { Value = s }, }; case bool b: - return new AttributeValue() { BoolValue = b }; + return new AttributeValue { BoolValue = b }; case long l: - return new AttributeValue() { IntValue = l }; + return new AttributeValue { IntValue = l }; case double d: - return new AttributeValue() + return new AttributeValue { - StringValue = new TruncatableString() { Value = d.ToString(CultureInfo.InvariantCulture) }, + StringValue = new TruncatableString { Value = d.ToString(CultureInfo.InvariantCulture) }, }; case null: return new AttributeValue(); default: - return new AttributeValue() + return new AttributeValue { - StringValue = new TruncatableString() { Value = av.ToString() }, + StringValue = new TruncatableString { Value = av.ToString() }, }; } } diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/Constants.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/Constants.cs index 800a31aa74..ee3797181e 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/Constants.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/Constants.cs @@ -14,41 +14,13 @@ // limitations under the License. // -using System; - namespace OpenTelemetry.Exporter.Stackdriver.Implementation; internal class Constants { public const string PackagVersionUndefined = "undefined"; - public const string LabelDescription = "OpenTelemetry string"; - public const string OpenTelemetryTask = "OpenTelemetry_task"; - public const string OpenTelemetryTaskDescription = "OpenTelemetry task identifier"; - - public const string GcpGkeContainer = "k8s_container"; - public const string GcpGceInstance = "gce_instance"; - public const string AwsEc2Instance = "aws_ec2_instance"; public const string Global = "global"; public const string ProjectIdLabelKey = "project_id"; - - public const string GceGcpInstanceType = "cloud.google.com/gce/instance"; - public const string GcpInstanceIdKey = "cloud.google.com/gce/instance_id"; - public const string GcpAccountIdKey = "cloud.google.com/gce/project_id"; - public const string GcpZoneKey = "cloud.google.com/gce/zone"; - - public const string K8sContainerType = "k8s.io/container"; - public const string K8sClusterNameKey = "k8s.io/cluster/name"; - public const string K8sContainerNameKey = "k8s.io/container/name"; - public const string K8sNamespaceNameKey = "k8s.io/namespace/name"; - public const string K8sPodNameKey = "k8s.io/pod/name"; - - public static readonly string OpenTelemetryTaskValueDefault = GenerateDefaultTaskValue(); - - private static string GenerateDefaultTaskValue() - { - // Something like '@' - return $"dotnet-{System.Diagnostics.Process.GetCurrentProcess().Id}@{Environment.MachineName}"; - } } diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ExporterStackdriverEventSource.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ExporterStackdriverEventSource.cs index 118f88aac5..818383e680 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ExporterStackdriverEventSource.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/ExporterStackdriverEventSource.cs @@ -23,7 +23,7 @@ namespace OpenTelemetry.Exporter.Stackdriver.Implementation; [EventSource(Name = "OpenTelemetry-Exporter-Stackdriver")] internal class ExporterStackdriverEventSource : EventSource { - public static readonly ExporterStackdriverEventSource Log = new ExporterStackdriverEventSource(); + public static readonly ExporterStackdriverEventSource Log = new(); [NonEvent] public void ExportMethodException(Exception ex) diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/GoogleCloudResourceUtils.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/GoogleCloudResourceUtils.cs index 8f924ccf0e..2dfb3e0270 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/GoogleCloudResourceUtils.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/GoogleCloudResourceUtils.cs @@ -32,7 +32,7 @@ public static class GoogleCloudResourceUtils /// the method returns null. /// /// Google Cloud Project ID. - public static string GetProjectId() + public static string? GetProjectId() { // Try to detect projectId from the environment where the code is running var instance = Google.Api.Gax.Platform.Instance(); @@ -60,7 +60,7 @@ public static string GetProjectId() /// /// The project id. /// Stackdriver Monitored Resource. - public static MonitoredResource GetDefaultResource(string projectId) + public static MonitoredResource GetDefaultResource(string? projectId) { var resource = new MonitoredResource(); resource.Type = Constants.Global; diff --git a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/StackdriverStatsConfiguration.cs b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/StackdriverStatsConfiguration.cs index 2ebe727993..8d436432a5 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/Implementation/StackdriverStatsConfiguration.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/Implementation/StackdriverStatsConfiguration.cs @@ -54,17 +54,17 @@ public static StackdriverStatsConfiguration Default /// /// Gets or sets the prefix to append to every OpenTelemetry metric name in Stackdriver. /// - public string MetricNamePrefix { get; set; } + public string? MetricNamePrefix { get; set; } /// /// Gets or sets google Cloud Project Id. /// - public string ProjectId { get; set; } + public string? ProjectId { get; set; } /// /// Gets or sets credential used to authenticate against Google Stackdriver Monitoring APIs. /// - public GoogleCredential GoogleCredential { get; set; } + public GoogleCredential? GoogleCredential { get; set; } /// /// Gets or sets monitored Resource associated with metrics collection. @@ -72,5 +72,5 @@ public static StackdriverStatsConfiguration Default /// such as GKE/AWS/GCE. If the exporter is running on a different environment, /// monitored resource will be identified as "general". /// - public MonitoredResource MonitoredResource { get; set; } + public MonitoredResource? MonitoredResource { get; set; } } diff --git a/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj b/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj index 025d4ddd29..515cde9d2a 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj +++ b/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj @@ -6,6 +6,7 @@ $(PackageTags);Stackdriver;Google;GCP;distributed-tracing Exporter.Stackdriver- true + enable diff --git a/src/OpenTelemetry.Exporter.Stackdriver/README.md b/src/OpenTelemetry.Exporter.Stackdriver/README.md index 911543af79..4f26b1e07a 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/README.md +++ b/src/OpenTelemetry.Exporter.Stackdriver/README.md @@ -22,7 +22,7 @@ constructor for specifying path to the service account credential. ## Installation ```shell -dotnet add package OpenTelemetry.Contrib.Instrumentation.Stackdriver +dotnet add package OpenTelemetry.Contrib.Instrumentation.Stackdriver --prerelease ``` ## Traces diff --git a/src/OpenTelemetry.Exporter.Stackdriver/StackdriverTraceExporter.cs b/src/OpenTelemetry.Exporter.Stackdriver/StackdriverTraceExporter.cs index e109388329..22d3b57418 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/StackdriverTraceExporter.cs +++ b/src/OpenTelemetry.Exporter.Stackdriver/StackdriverTraceExporter.cs @@ -35,7 +35,7 @@ public class StackdriverTraceExporter : BaseExporter private readonly Google.Api.Gax.ResourceNames.ProjectName googleCloudProjectId; private readonly TraceServiceSettings traceServiceSettings; - private readonly TraceServiceClient traceServiceClient; + private readonly TraceServiceClient? traceServiceClient; #pragma warning disable CA1810 // Initialize reference type static fields inline static StackdriverTraceExporter() @@ -91,8 +91,8 @@ internal StackdriverTraceExporter(string projectId, TraceServiceClient traceServ /// public override ExportResult Export(in Batch batch) { - TraceServiceClient traceWriter = this.traceServiceClient; - if (this.traceServiceClient == null) + TraceServiceClient? traceWriter = this.traceServiceClient; + if (traceWriter == null) { traceWriter = new TraceServiceClientBuilder { diff --git a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj index 52327d652c..bb8e66d5b6 100644 --- a/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Stackdriver.Tests/OpenTelemetry.Exporter.Stackdriver.Tests.csproj @@ -4,6 +4,7 @@ net7.0;net6.0 $(TargetFrameworks);net462 + enable diff --git a/test/OpenTelemetry.Exporter.Stackdriver.Tests/StackdriverExporterTests.cs b/test/OpenTelemetry.Exporter.Stackdriver.Tests/StackdriverExporterTests.cs index c9ac11bebd..3c9a7fb4d0 100644 --- a/test/OpenTelemetry.Exporter.Stackdriver.Tests/StackdriverExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Stackdriver.Tests/StackdriverExporterTests.cs @@ -46,13 +46,6 @@ static StackdriverExporterTests() ActivitySource.AddActivityListener(listener); } - [Fact] - public void StackdriverExporter_BadArgs() - { - TracerProviderBuilder builder = null; - Assert.Throws(() => builder.UseStackdriverExporter(string.Empty)); - } - [Fact] public void StackdriverExporter_CustomActivityProcessor() { @@ -91,7 +84,7 @@ public void StackdriverExporter_CustomActivityProcessor() [Fact] public void StackdriverExporter_TraceClientThrows_ExportResultFailure() { - Exception exception = null; + Exception? exception; ExportResult result = ExportResult.Success; var exportedItems = new List(); const string ActivitySourceName = "stackdriver.test"; @@ -132,7 +125,7 @@ void RunTest(Batch batch) [Fact] public void StackdriverExporter_TraceClientDoesNotTrow_ExportResultSuccess() { - Exception exception = null; + Exception? exception; ExportResult result = ExportResult.Failure; var exportedItems = new List(); const string ActivitySourceName = "stackdriver.test"; @@ -171,10 +164,10 @@ void RunTest(Batch batch) internal static Activity CreateTestActivity( bool setAttributes = true, - Dictionary additionalAttributes = null, + Dictionary? additionalAttributes = null, bool addEvents = true, bool addLinks = true, - Resource resource = null, + Resource? resource = null, ActivityKind kind = ActivityKind.Client) { var startTimestamp = DateTime.UtcNow; @@ -184,7 +177,7 @@ internal static Activity CreateTestActivity( var parentSpanId = ActivitySpanId.CreateFromBytes(new byte[] { 12, 23, 34, 45, 56, 67, 78, 89 }); - var attributes = new Dictionary + var attributes = new Dictionary { { "stringKey", "value" }, { "longKey", 1L }, @@ -205,14 +198,14 @@ internal static Activity CreateTestActivity( var events = new List { - new ActivityEvent( + new( "Event1", eventTimestamp, new ActivityTagsCollection { { "key", "value" }, }), - new ActivityEvent( + new( "Event2", eventTimestamp, new ActivityTagsCollection @@ -226,7 +219,7 @@ internal static Activity CreateTestActivity( var activitySource = new ActivitySource(nameof(CreateTestActivity)); var tags = setAttributes ? - attributes.Select(kvp => new KeyValuePair(kvp.Key, kvp.Value?.ToString())) + attributes.Select(kvp => new KeyValuePair(kvp.Key, kvp.Value?.ToString())) : null; var links = addLinks ? new[] @@ -244,7 +237,7 @@ internal static Activity CreateTestActivity( parentContext: new ActivityContext(traceId, parentSpanId, ActivityTraceFlags.Recorded), tags, links, - startTime: startTimestamp); + startTime: startTimestamp)!; if (addEvents) { diff --git a/test/OpenTelemetry.Exporter.Stackdriver.Tests/TestActivityProcessor.cs b/test/OpenTelemetry.Exporter.Stackdriver.Tests/TestActivityProcessor.cs index c4a55c3755..477140520c 100644 --- a/test/OpenTelemetry.Exporter.Stackdriver.Tests/TestActivityProcessor.cs +++ b/test/OpenTelemetry.Exporter.Stackdriver.Tests/TestActivityProcessor.cs @@ -21,8 +21,8 @@ namespace OpenTelemetry.Exporter.Stackdriver.Tests; public class TestActivityProcessor : BaseProcessor, IDisposable { - public Action StartAction; - public Action EndAction; + public Action? StartAction; + public Action? EndAction; public TestActivityProcessor() {