diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be3cdf11abe..999985d15a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,7 +129,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ net6.0 ] + version: [ net6.0, net8.0 ] steps: - uses: actions/checkout@v4 - name: Run W3C Trace Context docker compose diff --git a/Directory.Packages.props b/Directory.Packages.props index bfe09403ee5..abe3785ad8d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -81,9 +81,9 @@ - + - + @@ -92,15 +92,15 @@ - - - + + + - + - + diff --git a/build/Common.props b/build/Common.props index e526f543e93..7c1f02bdebf 100644 --- a/build/Common.props +++ b/build/Common.props @@ -10,6 +10,8 @@ enable enable true + all + low $(NoWarn);OTEL1000;OTEL1001;OTEL1002;OTEL1003;OTEL1004 diff --git a/examples/MicroserviceExample/WorkerService/WorkerService.csproj b/examples/MicroserviceExample/WorkerService/WorkerService.csproj index b9b1a680772..f10cebc2d7e 100644 --- a/examples/MicroserviceExample/WorkerService/WorkerService.csproj +++ b/examples/MicroserviceExample/WorkerService/WorkerService.csproj @@ -6,6 +6,8 @@ + + diff --git a/src/OpenTelemetry/Trace/TracerProviderSdk.cs b/src/OpenTelemetry/Trace/TracerProviderSdk.cs index 2da7f0ea4d5..8fd333b1958 100644 --- a/src/OpenTelemetry/Trace/TracerProviderSdk.cs +++ b/src/OpenTelemetry/Trace/TracerProviderSdk.cs @@ -111,7 +111,7 @@ internal TracerProviderSdk( OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent($"Instrumentations added = \"{instrumentationFactoriesAdded}\"."); } - var listener = new ActivityListener(); + var activityListener = new ActivityListener(); if (this.supportLegacyActivity) { @@ -125,7 +125,7 @@ internal TracerProviderSdk( legacyActivityPredicate = activity => state.LegacyActivityOperationNames.Contains(activity.OperationName); } - listener.ActivityStarted = activity => + activityListener.ActivityStarted = activity => { OpenTelemetrySdkEventSource.Log.ActivityStarted(activity); @@ -163,7 +163,7 @@ internal TracerProviderSdk( } }; - listener.ActivityStopped = activity => + activityListener.ActivityStopped = activity => { OpenTelemetrySdkEventSource.Log.ActivityStopped(activity); @@ -194,7 +194,7 @@ internal TracerProviderSdk( } else { - listener.ActivityStarted = activity => + activityListener.ActivityStarted = activity => { OpenTelemetrySdkEventSource.Log.ActivityStarted(activity); @@ -204,7 +204,7 @@ internal TracerProviderSdk( } }; - listener.ActivityStopped = activity => + activityListener.ActivityStopped = activity => { OpenTelemetrySdkEventSource.Log.ActivityStopped(activity); @@ -230,20 +230,20 @@ internal TracerProviderSdk( if (this.sampler is AlwaysOnSampler) { - listener.Sample = (ref ActivityCreationOptions options) => + activityListener.Sample = (ref ActivityCreationOptions options) => !Sdk.SuppressInstrumentation ? ActivitySamplingResult.AllDataAndRecorded : ActivitySamplingResult.None; this.getRequestedDataAction = this.RunGetRequestedDataAlwaysOnSampler; } else if (this.sampler is AlwaysOffSampler) { - listener.Sample = (ref ActivityCreationOptions options) => + activityListener.Sample = (ref ActivityCreationOptions options) => !Sdk.SuppressInstrumentation ? PropagateOrIgnoreData(options.Parent) : ActivitySamplingResult.None; this.getRequestedDataAction = this.RunGetRequestedDataAlwaysOffSampler; } else { // This delegate informs ActivitySource about sampling decision when the parent context is an ActivityContext. - listener.Sample = (ref ActivityCreationOptions options) => + activityListener.Sample = (ref ActivityCreationOptions options) => !Sdk.SuppressInstrumentation ? ComputeActivitySamplingResult(ref options, this.sampler) : ActivitySamplingResult.None; this.getRequestedDataAction = this.RunGetRequestedDataOtherSampler; } @@ -260,7 +260,7 @@ internal TracerProviderSdk( // Function which takes ActivitySource and returns true/false to indicate if it should be subscribed to // or not. - listener.ShouldListenTo = (activitySource) => + activityListener.ShouldListenTo = activitySource => this.supportLegacyActivity ? string.IsNullOrEmpty(activitySource.Name) || regex.IsMatch(activitySource.Name) : regex.IsMatch(activitySource.Name); @@ -276,19 +276,19 @@ internal TracerProviderSdk( // Function which takes ActivitySource and returns true/false to indicate if it should be subscribed to // or not. - listener.ShouldListenTo = (activitySource) => activitySources.Contains(activitySource.Name); + activityListener.ShouldListenTo = activitySource => activitySources.Contains(activitySource.Name); } } else { if (this.supportLegacyActivity) { - listener.ShouldListenTo = (activitySource) => string.IsNullOrEmpty(activitySource.Name); + activityListener.ShouldListenTo = activitySource => string.IsNullOrEmpty(activitySource.Name); } } - ActivitySource.AddActivityListener(listener); - this.listener = listener; + ActivitySource.AddActivityListener(activityListener); + this.listener = activityListener; OpenTelemetrySdkEventSource.Log.TracerProviderSdkEvent("TracerProvider built successfully."); } diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props index b3769fc1459..d6755d05725 100644 --- a/test/Directory.Packages.props +++ b/test/Directory.Packages.props @@ -4,6 +4,6 @@ - + diff --git a/test/OpenTelemetry.Api.Tests/OpenTelemetry.Api.Tests.csproj b/test/OpenTelemetry.Api.Tests/OpenTelemetry.Api.Tests.csproj index fac3c2e2c11..e6a6749107c 100644 --- a/test/OpenTelemetry.Api.Tests/OpenTelemetry.Api.Tests.csproj +++ b/test/OpenTelemetry.Api.Tests/OpenTelemetry.Api.Tests.csproj @@ -24,5 +24,7 @@ runtime; build; native; contentfiles; analyzers + + diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj index 21b320de546..ed31a950360 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.csproj @@ -14,6 +14,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests.csproj b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests.csproj index 97e6f15e108..b361d72e7ee 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests.csproj @@ -15,6 +15,8 @@ runtime; build; native; contentfiles; analyzers + + diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj index f4901706361..295231183c2 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests.csproj @@ -14,6 +14,8 @@ runtime; build; native; contentfiles; analyzers + + diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj b/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj index f5a72a2f25f..31636f33157 100644 --- a/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj +++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/OpenTelemetry.Exporter.Zipkin.Tests.csproj @@ -22,6 +22,8 @@ runtime; build; native; contentfiles; analyzers + + diff --git a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj index 1ea17a421de..7dec47d5464 100644 --- a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj +++ b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetry.Extensions.Hosting.Tests.csproj @@ -41,5 +41,7 @@ runtime; build; native; contentfiles; analyzers + + diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile index 9723867f4f3..7a8dc6f5705 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile @@ -26,7 +26,9 @@ COPY --from=w3c /w3c . RUN apt-get update \ && apt-get install -y python3-pip python3-dev \ && cd /usr/local/bin \ - && ln -s /usr/bin/python3 python \ - && pip3 install --upgrade pip \ - && pip3 install aiohttp + && ln -s /usr/bin/python3 python + +# net6.0 image uses Python 3.9, which doesn't have `--break-system-packages` option. +RUN pip3 install --upgrade pip --break-system-packages || pip3 install --upgrade pip +RUN pip3 install aiohttp --break-system-packages ENTRYPOINT ["dotnet", "vstest", "OpenTelemetry.Instrumentation.W3cTraceContext.Tests.dll", "--logger:console;verbosity=detailed"] diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs index 323b35ecba9..b80a57f1ced 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/W3CTraceContextTests.cs @@ -69,7 +69,7 @@ public void W3CTraceContextTestSuiteAsync(string value) return result; }); - app.RunAsync(); + app.RunAsync("http://localhost:5000/"); string result = RunCommand("python", "trace-context/test/test.py http://localhost:5000/"); diff --git a/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj b/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj index 1aac45f10ca..430bb7057e2 100644 --- a/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj +++ b/test/OpenTelemetry.Shims.OpenTracing.Tests/OpenTelemetry.Shims.OpenTracing.Tests.csproj @@ -12,6 +12,8 @@ + + diff --git a/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs b/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs index cc5a34d7fd1..41726da14d7 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs @@ -236,7 +236,7 @@ public void MetricInstrumentationScopeAttributesAreNotTreatedAsIdentifyingProper Assert.Equal(meterVersion, metric.MeterVersion); Assert.Single(metric.MeterTags.Where(kvp => kvp.Key == meterTags1[0].Key && kvp.Value == meterTags1[0].Value)); - Assert.Empty(metric.MeterTags.Where(kvp => kvp.Key == meterTags2[0].Key && kvp.Value == meterTags2[0].Value)); + Assert.DoesNotContain(metric.MeterTags, kvp => kvp.Key == meterTags2[0].Key && kvp.Value == meterTags2[0].Value); List metricPoints = new List(); foreach (ref readonly var mp in metric.GetMetricPoints()) diff --git a/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj b/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj index 2a2532c07e9..96304bf6c6c 100644 --- a/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj +++ b/test/OpenTelemetry.Tests/OpenTelemetry.Tests.csproj @@ -15,7 +15,6 @@ - @@ -32,5 +31,7 @@ runtime; build; native; contentfiles; analyzers + +