diff --git a/.editorconfig b/.editorconfig index 5bc89604c76..45d0806a20b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -41,7 +41,7 @@ csharp_indent_labels = flush_left # Modifier preferences csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion -dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion # this. preferences dotnet_style_qualification_for_field = true:suggestion @@ -53,8 +53,8 @@ dotnet_style_qualification_for_event = true:suggestion csharp_style_var_for_built_in_types = true:silent csharp_style_var_when_type_is_apparent = true:silent csharp_style_var_elsewhere = true:silent -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion # name all constant fields using PascalCase dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion @@ -75,6 +75,7 @@ dotnet_style_readonly_field = true:suggestion csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion dotnet_style_object_initializer = true:suggestion +csharp_style_prefer_primary_constructors = false:none # Expression-level preferences dotnet_style_object_initializer = true:suggestion @@ -82,21 +83,23 @@ dotnet_style_collection_initializer = true:suggestion dotnet_style_explicit_tuple_names = true:suggestion dotnet_style_coalesce_expression = true:suggestion dotnet_style_null_propagation = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion dotnet_style_prefer_inferred_tuple_names = true:suggestion dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_auto_properties = true:silent -dotnet_style_prefer_conditional_expression_over_assignment = true:silent -dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_auto_properties = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:suggestion csharp_prefer_simple_default_expression = true:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:none # Expression-bodied members -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_methods = true:suggestion +dotnet_diagnostic.IDE0022.severity = suggestion # dotnet format doesn't respect the suggestion in the line above +csharp_style_expression_bodied_constructors = false:warning +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion @@ -113,6 +116,7 @@ csharp_style_prefer_range_operator = false:none csharp_style_pattern_local_over_anonymous_function = true:suggestion csharp_style_deconstructed_variable_declaration = true:suggestion csharp_style_namespace_declarations = file_scoped:warning +dotnet_style_namespace_match_folder = false:none # Space preferences csharp_space_after_cast = false @@ -128,10 +132,10 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false # Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion # Code analyzers # CA1031: Do not catch general exception types diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index baef921968e..d503e982d1f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -48,7 +48,7 @@ body: - type: input attributes: label: Runtime Version - description: What .NET runtime version did you use? (e.g. `net462`, `net48`, `netcoreapp3.1`, `net6.0` etc. You can find this information from the `*.csproj` file) + description: What .NET runtime version did you use? (e.g. `net462`, `net48`, `net8.0`, etc. You can find this information from the `*.csproj` file) validations: required: true diff --git a/.github/workflows/Component.BuildTest.yml b/.github/workflows/Component.BuildTest.yml index e25352b0854..de7ebb3fc4f 100644 --- a/.github/workflows/Component.BuildTest.yml +++ b/.github/workflows/Component.BuildTest.yml @@ -24,7 +24,7 @@ on: required: false type: string tfm-list: - default: '[ "net462", "net6.0", "net8.0" ]' + default: '[ "net462", "net8.0", "net9.0" ]' required: false type: string @@ -42,7 +42,7 @@ jobs: - os: otel-linux-arm64 version: net462 - os: otel-linux-arm64 - version: net6.0 + version: net8.0 runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58eef737fca..73ecbd165ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ net6.0, net8.0 ] + version: [ net8.0, net9.0 ] steps: - uses: actions/checkout@v4 - name: Run OTLP Exporter docker compose @@ -129,7 +129,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ net6.0, net8.0 ] + version: [ net8.0, net9.0 ] steps: - uses: actions/checkout@v4 - name: Run W3C Trace Context docker compose diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml index 4c2031c9303..76ab4f2e1ec 100644 --- a/.github/workflows/docfx.yml +++ b/.github/workflows/docfx.yml @@ -13,6 +13,9 @@ jobs: - name: check out code uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + - name: install docfx run: dotnet tool install -g docfx diff --git a/.github/workflows/verifyaotcompat.yml b/.github/workflows/verifyaotcompat.yml index 24991b9fe3c..3bdc42e3e7f 100644 --- a/.github/workflows/verifyaotcompat.yml +++ b/.github/workflows/verifyaotcompat.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: os: [ ubuntu-latest, windows-latest ] - version: [ net8.0 ] + version: [ net8.0, net9.0 ] runs-on: ${{ matrix.os }} steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fda1c81c336..c6b0e6c4fe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ You can contribute to this project from a Windows, macOS or Linux machine. On all platforms, the minimum requirements are: * Git client and command line tools. -* .NET 8.0 +* .NET 9.0 ### Linux or MacOS diff --git a/Directory.Packages.props b/Directory.Packages.props index abe3785ad8d..fe1f04c7fbe 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,14 +26,14 @@ these packages even during major version bumps, so compatibility is not a concern here. --> - - - - - - - - + + + + + + + + @@ -52,7 +52,7 @@ 3) The .NET runtime team provides extra backward compatibility guarantee to System.Diagnostics.DiagnosticSource even during major version bumps, so compatibility is not a concern here. --> - + @@ -68,7 +68,7 @@ This section covers packages that are **not** directly referenced by the NuGet packages published from this repository. For example, these packages are used in the tests, examples or referenced as "PrivateAssets", but not in the NuGet packages themselves. --> - + @@ -77,11 +77,11 @@ - - - - - + + + + + @@ -97,10 +97,10 @@ - - - + + + diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 2cfcf9b1f22..5ca42dd0962 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -31,8 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E build\debug.snk = build\debug.snk Directory.Packages.props = Directory.Packages.props build\docfx.cmd = build\docfx.cmd - build\docker-compose.net6.0.yml = build\docker-compose.net6.0.yml build\docker-compose.net8.0.yml = build\docker-compose.net8.0.yml + build\docker-compose.net9.0.yml = build\docker-compose.net9.0.yml build\GlobalAttrExclusions.txt = build\GlobalAttrExclusions.txt build\opentelemetry-icon-color.png = build\opentelemetry-icon-color.png build\OpenTelemetry.prod.loose.ruleset = build\OpenTelemetry.prod.loose.ruleset diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index 6de6e014c88..ce99895ccba 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -8,7 +8,7 @@ - net8.0 + net9.0 diff --git a/build/Common.prod.props b/build/Common.prod.props index 9f2c78486c3..1b58605b4d1 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -33,6 +33,13 @@ true + + + + + diff --git a/build/Common.props b/build/Common.props index 7c1f02bdebf..54ecbacfe9b 100644 --- a/build/Common.props +++ b/build/Common.props @@ -28,18 +28,18 @@ net481;net48;net472;net471;net47;net462 - net8.0;net6.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net8.0;net6.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) - net8.0;net6.0 + net9.0;net8.0;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net9.0;net8.0;netstandard2.1;netstandard2.0;$(NetFrameworkMinimumSupportedVersion) + net9.0;net8.0 - net8.0;net6.0 - net8.0 - net8.0;net6.0 + net9.0;net8.0 + net9.0;net8.0 + net9.0;net8.0 $(TargetFrameworksForDocs);$(NetFrameworkSupportedVersions) - net8.0;net6.0 + net9.0;net8.0 $(TargetFrameworksForTests);$(NetFrameworkMinimumSupportedVersion) diff --git a/build/docker-compose.net6.0.yml b/build/docker-compose.net6.0.yml deleted file mode 100644 index 099f1007277..00000000000 --- a/build/docker-compose.net6.0.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: '3.7' - -services: - tests: - build: - args: - PUBLISH_FRAMEWORK: net6.0 - TEST_SDK_VERSION: "6.0" - BUILD_SDK_VERSION: "8.0" diff --git a/build/docker-compose.net8.0.yml b/build/docker-compose.net8.0.yml index a5ac999e43e..22787bff66e 100644 --- a/build/docker-compose.net8.0.yml +++ b/build/docker-compose.net8.0.yml @@ -6,4 +6,4 @@ services: args: PUBLISH_FRAMEWORK: net8.0 TEST_SDK_VERSION: "8.0" - BUILD_SDK_VERSION: "8.0" + BUILD_SDK_VERSION: "9.0" diff --git a/build/docker-compose.net9.0.yml b/build/docker-compose.net9.0.yml new file mode 100644 index 00000000000..29663b3246c --- /dev/null +++ b/build/docker-compose.net9.0.yml @@ -0,0 +1,9 @@ +version: '3.7' + +services: + tests: + build: + args: + PUBLISH_FRAMEWORK: net9.0 + TEST_SDK_VERSION: "9.0" + BUILD_SDK_VERSION: "9.0" diff --git a/docs/metrics/customizing-the-sdk/README.md b/docs/metrics/customizing-the-sdk/README.md index 830ad66957c..ed4d9aa9d67 100644 --- a/docs/metrics/customizing-the-sdk/README.md +++ b/docs/metrics/customizing-the-sdk/README.md @@ -203,7 +203,7 @@ used. By default, the boundaries used for a Histogram are [`{ 0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}`](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.14.0/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation). Views can be used to provide custom boundaries for a Histogram. The measurements -are then aggregated using the custom boundaries provided instead of the the +are then aggregated using the custom boundaries provided instead of the default boundaries. This requires the use of `ExplicitBucketHistogramConfiguration`. diff --git a/examples/Directory.Packages.props b/examples/Directory.Packages.props index 549e1ed325b..02296b44608 100644 --- a/examples/Directory.Packages.props +++ b/examples/Directory.Packages.props @@ -1,6 +1,6 @@ - + diff --git a/global.json b/global.json index 0aca8b12938..f459bbb82e4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestFeature", - "version": "8.0.100" + "version": "9.0.100-rc.1.24452.12" } } diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md index 6609f3d51c4..7af158935fc 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md @@ -7,6 +7,10 @@ Notes](../../RELEASENOTES.md). ## Unreleased +* Updated `Microsoft.Extensions.DependencyInjection.Abstractions` package + version to `9.0.0-rc.1.24431.7`. + ([#5853](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5853)) + ## 1.9.0 Released 2024-Jun-14 diff --git a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt index 46b63e18fee..cd5c445997e 100644 --- a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Shipped.txt @@ -1,11 +1,4 @@ #nullable enable -~OpenTelemetry.Baggage.GetBaggage() -> System.Collections.Generic.IReadOnlyDictionary -~OpenTelemetry.Baggage.GetBaggage(string name) -> string -~OpenTelemetry.Baggage.GetEnumerator() -> System.Collections.Generic.Dictionary.Enumerator -~OpenTelemetry.Baggage.RemoveBaggage(string name) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[] baggageItems) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(string name, string value) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems) -> OpenTelemetry.Baggage ~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.AsyncLocalRuntimeContextSlot(string name) -> void ~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.get -> object ~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.set -> void @@ -16,14 +9,6 @@ ~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.ThreadLocalRuntimeContextSlot(string name) -> void ~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.get -> object ~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.set -> void -~override OpenTelemetry.Baggage.Equals(object obj) -> bool -~static OpenTelemetry.Baggage.Create(System.Collections.Generic.Dictionary baggageItems = null) -> OpenTelemetry.Baggage -~static OpenTelemetry.Baggage.GetBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.IReadOnlyDictionary -~static OpenTelemetry.Baggage.GetBaggage(string name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> string -~static OpenTelemetry.Baggage.GetEnumerator(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.Dictionary.Enumerator -~static OpenTelemetry.Baggage.RemoveBaggage(string name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage -~static OpenTelemetry.Baggage.SetBaggage(string name, string value, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage -~static OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage ~static OpenTelemetry.Context.RuntimeContext.ContextSlotType.get -> System.Type ~static OpenTelemetry.Context.RuntimeContext.ContextSlotType.set -> void ~static OpenTelemetry.Context.RuntimeContext.GetSlot(string slotName) -> OpenTelemetry.Context.RuntimeContextSlot @@ -49,6 +34,13 @@ OpenTelemetry.Baggage.Baggage() -> void OpenTelemetry.Baggage.ClearBaggage() -> OpenTelemetry.Baggage OpenTelemetry.Baggage.Count.get -> int OpenTelemetry.Baggage.Equals(OpenTelemetry.Baggage other) -> bool +OpenTelemetry.Baggage.GetBaggage() -> System.Collections.Generic.IReadOnlyDictionary! +OpenTelemetry.Baggage.GetBaggage(string! name) -> string? +OpenTelemetry.Baggage.GetEnumerator() -> System.Collections.Generic.Dictionary.Enumerator +OpenTelemetry.Baggage.RemoveBaggage(string! name) -> OpenTelemetry.Baggage +OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[]! baggageItems) -> OpenTelemetry.Baggage +OpenTelemetry.Baggage.SetBaggage(string! name, string? value) -> OpenTelemetry.Baggage +OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable>! baggageItems) -> OpenTelemetry.Baggage OpenTelemetry.BaseProvider OpenTelemetry.BaseProvider.~BaseProvider() -> void OpenTelemetry.BaseProvider.BaseProvider() -> void @@ -171,6 +163,7 @@ OpenTelemetry.Trace.TracerProvider.GetTracer(string! name, string? version = nul OpenTelemetry.Trace.TracerProvider.TracerProvider() -> void OpenTelemetry.Trace.TracerProviderBuilder OpenTelemetry.Trace.TracerProviderBuilder.TracerProviderBuilder() -> void +override OpenTelemetry.Baggage.Equals(object? obj) -> bool override OpenTelemetry.Baggage.GetHashCode() -> int override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Get() -> T override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Set(T value) -> void @@ -201,10 +194,17 @@ override OpenTelemetry.Trace.Status.ToString() -> string! override OpenTelemetry.Trace.TracerProvider.Dispose(bool disposing) -> void static OpenTelemetry.ActivityContextExtensions.IsValid(this System.Diagnostics.ActivityContext ctx) -> bool static OpenTelemetry.Baggage.ClearBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage +static OpenTelemetry.Baggage.Create(System.Collections.Generic.Dictionary? baggageItems = null) -> OpenTelemetry.Baggage static OpenTelemetry.Baggage.Current.get -> OpenTelemetry.Baggage static OpenTelemetry.Baggage.Current.set -> void +static OpenTelemetry.Baggage.GetBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.IReadOnlyDictionary! +static OpenTelemetry.Baggage.GetBaggage(string! name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> string? +static OpenTelemetry.Baggage.GetEnumerator(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.Dictionary.Enumerator static OpenTelemetry.Baggage.operator !=(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool static OpenTelemetry.Baggage.operator ==(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool +static OpenTelemetry.Baggage.RemoveBaggage(string! name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage +static OpenTelemetry.Baggage.SetBaggage(string! name, string? value, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage +static OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable>! baggageItems, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage static OpenTelemetry.Context.Propagation.PropagationContext.operator !=(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool static OpenTelemetry.Context.Propagation.PropagationContext.operator ==(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool static OpenTelemetry.Context.Propagation.Propagators.DefaultTextMapPropagator.get -> OpenTelemetry.Context.Propagation.TextMapPropagator! diff --git a/src/OpenTelemetry.Api/Baggage.cs b/src/OpenTelemetry.Api/Baggage.cs index 46cdedbd7d1..835cb3a23f6 100644 --- a/src/OpenTelemetry.Api/Baggage.cs +++ b/src/OpenTelemetry.Api/Baggage.cs @@ -1,6 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#nullable enable + using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Context; using OpenTelemetry.Internal; @@ -87,7 +89,7 @@ public static Baggage Current /// /// Baggage key/value pairs. /// . - public static Baggage Create(Dictionary baggageItems = null) + public static Baggage Create(Dictionary? baggageItems = null) { if (baggageItems == null) { @@ -133,7 +135,7 @@ public static Dictionary.Enumerator GetEnumerator(Baggage baggag /// Optional . is used if not specified. /// Baggage item or if nothing was found. [SuppressMessage("roslyn", "RS0026", Justification = "TODO: fix APIs that violate the backcompt requirement - multiple overloads with optional parameters: https://github.com/dotnet/roslyn/blob/main/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md.")] - public static string GetBaggage(string name, Baggage baggage = default) + public static string? GetBaggage(string name, Baggage baggage = default) => baggage == default ? Current.GetBaggage(name) : baggage.GetBaggage(name); /// @@ -145,7 +147,7 @@ public static string GetBaggage(string name, Baggage baggage = default) /// New containing the key/value pair. /// Note: The returned will be set as the new instance. [SuppressMessage("roslyn", "RS0026", Justification = "TODO: fix APIs that violate the backcompt requirement - multiple overloads with optional parameters: https://github.com/dotnet/roslyn/blob/main/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md.")] - public static Baggage SetBaggage(string name, string value, Baggage baggage = default) + public static Baggage SetBaggage(string name, string? value, Baggage baggage = default) { var baggageHolder = EnsureBaggageHolder(); lock (baggageHolder) @@ -164,7 +166,7 @@ public static Baggage SetBaggage(string name, string value, Baggage baggage = de /// New containing the new key/value pairs. /// Note: The returned will be set as the new instance. [SuppressMessage("roslyn", "RS0026", Justification = "TODO: fix APIs that violate the backcompt requirement - multiple overloads with optional parameters: https://github.com/dotnet/roslyn/blob/main/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md.")] - public static Baggage SetBaggage(IEnumerable> baggageItems, Baggage baggage = default) + public static Baggage SetBaggage(IEnumerable> baggageItems, Baggage baggage = default) { var baggageHolder = EnsureBaggageHolder(); lock (baggageHolder) @@ -222,11 +224,11 @@ public IReadOnlyDictionary GetBaggage() /// /// Baggage item name. /// Baggage item or if nothing was found. - public string GetBaggage(string name) + public string? GetBaggage(string name) { Guard.ThrowIfNullOrEmpty(name); - return this.baggage != null && this.baggage.TryGetValue(name, out string value) + return this.baggage != null && this.baggage.TryGetValue(name, out string? value) ? value : null; } @@ -237,7 +239,7 @@ public string GetBaggage(string name) /// Baggage item name. /// Baggage item value. /// New containing the key/value pair. - public Baggage SetBaggage(string name, string value) + public Baggage SetBaggage(string name, string? value) { if (string.IsNullOrEmpty(value)) { @@ -247,7 +249,7 @@ public Baggage SetBaggage(string name, string value) return new Baggage( new Dictionary(this.baggage ?? EmptyBaggage, StringComparer.OrdinalIgnoreCase) { - [name] = value, + [name] = value!, }); } @@ -256,15 +258,15 @@ public Baggage SetBaggage(string name, string value) /// /// Baggage key/value pairs. /// New containing the key/value pairs. - public Baggage SetBaggage(params KeyValuePair[] baggageItems) - => this.SetBaggage((IEnumerable>)baggageItems); + public Baggage SetBaggage(params KeyValuePair[] baggageItems) + => this.SetBaggage((IEnumerable>)baggageItems); /// /// Returns a new which contains the new key/value pairs. /// /// Baggage key/value pairs. /// New containing the key/value pairs. - public Baggage SetBaggage(IEnumerable> baggageItems) + public Baggage SetBaggage(IEnumerable> baggageItems) { if (baggageItems?.Any() != true) { @@ -281,7 +283,7 @@ public Baggage SetBaggage(IEnumerable> baggageItems } else { - newBaggage[item.Key] = item.Value; + newBaggage[item.Key] = item.Value!; } } @@ -325,11 +327,11 @@ public bool Equals(Baggage other) return false; } - return baggageIsNullOrEmpty || this.baggage.SequenceEqual(other.baggage); + return baggageIsNullOrEmpty || this.baggage!.SequenceEqual(other.baggage!); } /// - public override bool Equals(object obj) + public override bool Equals(object? obj) => (obj is Baggage baggage) && this.Equals(baggage); /// diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 496061383af..07d8dcc123c 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -31,6 +31,10 @@ Notes](../../RELEASENOTES.md). APIs for reading the status of an `Activity` instance. ([#5781](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5781)) +* Updated `System.Diagnostics.DiagnosticSource` package version to + `9.0.0-rc.1.24431.7`. + ([#5853](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5853)) + ## 1.9.0 Released 2024-Jun-14 diff --git a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs index 17bbf13110b..e3ca4fd96c9 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs @@ -56,7 +56,7 @@ public override PropagationContext Extract(PropagationContext context, T carr { if (TryExtractBaggage(baggageCollection.ToArray(), out var baggage)) { - return new PropagationContext(context.ActivityContext, new Baggage(baggage)); + return new PropagationContext(context.ActivityContext, new Baggage(baggage!)); } } diff --git a/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs b/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs index e4367d41c6e..bea5f953882 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordAttributeList.cs @@ -6,7 +6,7 @@ using System.Collections; using System.ComponentModel; using System.Diagnostics; -#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES +#if NET && EXPOSE_EXPERIMENTAL_FEATURES using System.Diagnostics.CodeAnalysis; #endif using OpenTelemetry.Internal; @@ -19,7 +19,7 @@ namespace OpenTelemetry.Logs; /// Stores attributes to be added to a log message. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry.Api/Logs/LogRecordData.cs b/src/OpenTelemetry.Api/Logs/LogRecordData.cs index cb3c49292af..92bb2765a23 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordData.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordData.cs @@ -4,7 +4,7 @@ #nullable enable using System.Diagnostics; -#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES +#if NET && EXPOSE_EXPERIMENTAL_FEATURES using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -16,7 +16,7 @@ namespace OpenTelemetry.Logs; /// Stores details about a log message. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs b/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs index 9f48e71e854..b849abdcffa 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs @@ -3,7 +3,7 @@ #nullable enable -#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES +#if NET && EXPOSE_EXPERIMENTAL_FEATURES using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs; /// Describes the severity level of a log record. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs index f171edbc9ca..e5cb23d7fa0 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs @@ -3,7 +3,7 @@ #nullable enable -#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES +#if NET && EXPOSE_EXPERIMENTAL_FEATURES using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs; /// Contains extension methods for the enum. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry.Api/Logs/Logger.cs b/src/OpenTelemetry.Api/Logs/Logger.cs index 71baf7d611e..8318ed92c85 100644 --- a/src/OpenTelemetry.Api/Logs/Logger.cs +++ b/src/OpenTelemetry.Api/Logs/Logger.cs @@ -3,7 +3,7 @@ #nullable enable -#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES +#if NET && EXPOSE_EXPERIMENTAL_FEATURES using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -15,7 +15,7 @@ namespace OpenTelemetry.Logs; /// Logger is the class responsible for creating log records. /// /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry.Api/Logs/LoggerProvider.cs b/src/OpenTelemetry.Api/Logs/LoggerProvider.cs index f87eddc6571..018658446cd 100644 --- a/src/OpenTelemetry.Api/Logs/LoggerProvider.cs +++ b/src/OpenTelemetry.Api/Logs/LoggerProvider.cs @@ -6,7 +6,7 @@ #if NETSTANDARD2_1_OR_GREATER || NET using System.Diagnostics.CodeAnalysis; #endif -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using OpenTelemetry.Internal; #endif @@ -32,7 +32,7 @@ protected LoggerProvider() /// /// /// instance. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -49,7 +49,7 @@ Logger GetLogger() /// /// Optional name identifying the instrumentation library. /// instance. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -67,7 +67,7 @@ Logger GetLogger(string? name) /// Optional name identifying the instrumentation library. /// Optional version of the instrumentation library. /// instance. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -94,7 +94,7 @@ Logger GetLogger(string? name, string? version) /// Optional name identifying the instrumentation library. /// . /// if the logger was created. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif protected diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index ffb47ff3a33..e90109e737b 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -22,6 +22,10 @@ Notes](../../RELEASENOTES.md). on mobile platforms which caused telemetry to be dropped silently. ([#5821](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/5821)) +* Updated `Microsoft.Extensions.Hosting.Abstractions` package + version to `9.0.0-rc.1.24431.7`. + ([#5853](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5853)) + ## 1.9.0 Released 2024-Jun-14 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/IOtlpExporterOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/IOtlpExporterOptions.cs index 46855f8882d..d6402bc85a8 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/IOtlpExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/IOtlpExporterOptions.cs @@ -14,7 +14,7 @@ namespace OpenTelemetry.Exporter; internal interface IOtlpExporterOptions { /// - /// Gets or sets the the OTLP transport protocol. + /// Gets or sets the OTLP transport protocol. /// OtlpExportProtocol Protocol { get; set; } diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs index c2bd1cc2572..f91a93f66bb 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/PrometheusExporterMiddleware.cs @@ -65,7 +65,7 @@ public async Task InvokeAsync(HttpContext httpContext) if (dataView.Count > 0) { response.StatusCode = 200; -#if NET8_0_OR_GREATER +#if NET response.Headers.Append("Last-Modified", collectionResponse.GeneratedAtUtc.ToString("R")); #else response.Headers.Add("Last-Modified", collectionResponse.GeneratedAtUtc.ToString("R")); diff --git a/src/OpenTelemetry.Exporter.Zipkin/README.md b/src/OpenTelemetry.Exporter.Zipkin/README.md index aa277b7fdc2..ededcf9b07d 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/README.md +++ b/src/OpenTelemetry.Exporter.Zipkin/README.md @@ -15,7 +15,7 @@ dotnet add package OpenTelemetry.Exporter.Zipkin ## Enable/Add Zipkin as a tracing exporter -You can enable the the `ZipkinExporter` with the `AddZipkinExporter()` extension +You can enable the `ZipkinExporter` with the `AddZipkinExporter()` extension method on `TracerProviderBuilder`. ## Configuration diff --git a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md index ac95bbe985e..935f07ffc55 100644 --- a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md @@ -6,6 +6,10 @@ Notes](../../RELEASENOTES.md). ## Unreleased +* Updated `Microsoft.Extensions.Hosting.Abstractions` package + version to `9.0.0-rc.1.24431.7`. + ([#5853](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5853)) + ## 1.9.0 Released 2024-Jun-14 diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 844b237e1d2..1e802f55fd1 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -12,6 +12,11 @@ Notes](../../RELEASENOTES.md). `IOpenTelemetryBuilder`. ([#5325](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5325)) +* Updated the `Microsoft.Extensions.Logging.Configuration` and + `Microsoft.Extensions.Diagnostics.Abstractions` packages version to + `9.0.0-rc.1.24431.7`. + ([#5853](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5853)) + ## 1.9.0 Released 2024-Jun-14 diff --git a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs index 3216c050f7c..751154f8849 100644 --- a/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs +++ b/src/OpenTelemetry/Internal/SelfDiagnosticsConfigParser.cs @@ -66,7 +66,9 @@ public bool TryGetConfiguration( this.configBuffer = buffer; } - file.Read(buffer, 0, buffer.Length); + // TODO: Fix CA2022 - Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)' + // Added _ = as a workaround to suppress the warning + _ = file.Read(buffer, 0, buffer.Length); string configJson = Encoding.UTF8.GetString(buffer); if (!TryParseLogDirectory(configJson, out logDirectory)) diff --git a/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs index 973096cf7bc..e1a68730f2b 100644 --- a/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs +++ b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs @@ -71,7 +71,7 @@ public static ILoggingBuilder AddOpenTelemetry( /// /// The to use. /// The supplied for call chaining. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -90,7 +90,7 @@ static ILoggingBuilder UseOpenTelemetry( /// The to use. /// configuration action. /// The supplied for call chaining. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -115,7 +115,7 @@ static ILoggingBuilder UseOpenTelemetry( /// Optional configuration action. /// Optional configuration action. /// The supplied for call chaining. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry/Logs/LogRecord.cs b/src/OpenTelemetry/Logs/LogRecord.cs index 58d97c38edf..8009687d551 100644 --- a/src/OpenTelemetry/Logs/LogRecord.cs +++ b/src/OpenTelemetry/Logs/LogRecord.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 using System.Diagnostics; -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; #endif using System.Runtime.CompilerServices; @@ -355,7 +355,7 @@ public Exception? Exception /// known at the source. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -377,7 +377,7 @@ public Exception? Exception /// Gets or sets the log . /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -405,7 +405,7 @@ public Exception? Exception /// typically the which emitted the however the value may be different if is modified. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public Logger Logger { get; internal set; } = InstrumentationScopeLogger.Default; diff --git a/src/OpenTelemetry/Metrics/AggregatorStore.cs b/src/OpenTelemetry/Metrics/AggregatorStore.cs index 34a4bb5f2ce..5dc4f92dee9 100644 --- a/src/OpenTelemetry/Metrics/AggregatorStore.cs +++ b/src/OpenTelemetry/Metrics/AggregatorStore.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 using System.Collections.Concurrent; -#if NET8_0_OR_GREATER +#if NET using System.Collections.Frozen; #endif using System.Diagnostics; @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics; internal sealed class AggregatorStore { -#if NET8_0_OR_GREATER +#if NET internal readonly FrozenSet? TagKeysInteresting; #else internal readonly HashSet? TagKeysInteresting; @@ -96,7 +96,7 @@ internal AggregatorStore( { this.updateLongCallback = this.UpdateLongCustomTags; this.updateDoubleCallback = this.UpdateDoubleCustomTags; -#if NET8_0_OR_GREATER +#if NET var hs = FrozenSet.ToFrozenSet(metricStreamIdentity.TagKeys, StringComparer.Ordinal); #else var hs = new HashSet(metricStreamIdentity.TagKeys, StringComparer.Ordinal); diff --git a/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs b/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs index c53a7abf8b4..d1801afdd39 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if NET8_0_OR_GREATER +#if NET using System.Collections.Frozen; #endif using System.Diagnostics; @@ -17,7 +17,7 @@ namespace OpenTelemetry.Metrics; /// public struct Exemplar { -#if NET8_0_OR_GREATER +#if NET internal FrozenSet? ViewDefinedTagKeys; #else internal HashSet? ViewDefinedTagKeys; diff --git a/src/OpenTelemetry/Metrics/Exemplar/ExemplarMeasurement.cs b/src/OpenTelemetry/Metrics/Exemplar/ExemplarMeasurement.cs index eb3882e6e08..70d6ff3e762 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/ExemplarMeasurement.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/ExemplarMeasurement.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics; /// /// /// Measurement type. -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry/Metrics/Exemplar/ExemplarReservoir.cs b/src/OpenTelemetry/Metrics/Exemplar/ExemplarReservoir.cs index 4eb800921f1..0070074bed6 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/ExemplarReservoir.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/ExemplarReservoir.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; using OpenTelemetry.Internal; #endif @@ -17,7 +17,7 @@ namespace OpenTelemetry.Metrics; /// Specification: . /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry/Metrics/Exemplar/FixedSizeExemplarReservoir.cs b/src/OpenTelemetry/Metrics/Exemplar/FixedSizeExemplarReservoir.cs index dc929e725ed..bca577db0b6 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/FixedSizeExemplarReservoir.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/FixedSizeExemplarReservoir.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; #endif using OpenTelemetry.Internal; @@ -14,7 +14,7 @@ namespace OpenTelemetry.Metrics; /// number of s. /// /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry/Metrics/ThreadStaticStorage.cs b/src/OpenTelemetry/Metrics/ThreadStaticStorage.cs index 35f9be5b5da..a66460bfb79 100644 --- a/src/OpenTelemetry/Metrics/ThreadStaticStorage.cs +++ b/src/OpenTelemetry/Metrics/ThreadStaticStorage.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if NET8_0_OR_GREATER +#if NET using System.Collections.Frozen; #endif using System.Diagnostics; @@ -57,7 +57,7 @@ internal void SplitToKeysAndValues( internal void SplitToKeysAndValues( ReadOnlySpan> tags, int tagLength, -#if NET8_0_OR_GREATER +#if NET FrozenSet tagKeysInteresting, #else HashSet tagKeysInteresting, diff --git a/src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs b/src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs index 578049f329f..cc36941ce68 100644 --- a/src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs +++ b/src/OpenTelemetry/Metrics/View/MetricStreamConfiguration.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; #endif using OpenTelemetry.Internal; @@ -116,7 +116,7 @@ public string[]? TagKeys /// If not set the default /// MeterProvider cardinality limit of 2000 will apply. /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.CardinalityLimitExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public @@ -151,7 +151,7 @@ public string[]? TagKeys /// Specification: . /// -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.ExemplarReservoirExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public Func? ExemplarReservoirFactory { get; set; } diff --git a/src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs b/src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs index 8b8d7d12b3d..6369018ca0b 100644 --- a/src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs +++ b/src/OpenTelemetry/ReadOnlyFilteredTagCollection.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#if NET8_0_OR_GREATER +#if NET using System.Collections.Frozen; #endif using System.Diagnostics; @@ -16,7 +16,7 @@ namespace OpenTelemetry; // prevent accidental boxing. public readonly struct ReadOnlyFilteredTagCollection { -#if NET8_0_OR_GREATER +#if NET private readonly FrozenSet? excludedKeys; #else private readonly HashSet? excludedKeys; @@ -25,7 +25,7 @@ public readonly struct ReadOnlyFilteredTagCollection private readonly int count; internal ReadOnlyFilteredTagCollection( -#if NET8_0_OR_GREATER +#if NET FrozenSet? excludedKeys, #else HashSet? excludedKeys, diff --git a/src/OpenTelemetry/Sdk.cs b/src/OpenTelemetry/Sdk.cs index 3a95120e3ef..2cb4e0b6c9f 100644 --- a/src/OpenTelemetry/Sdk.cs +++ b/src/OpenTelemetry/Sdk.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 using System.Diagnostics; -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if EXPOSE_EXPERIMENTAL_FEATURES && NET using System.Diagnostics.CodeAnalysis; #endif using OpenTelemetry.Context.Propagation; @@ -89,7 +89,7 @@ public static TracerProviderBuilder CreateTracerProviderBuilder() /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. /// instance, which is used /// to build a . -#if NET8_0_OR_GREATER +#if NET [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] #endif public diff --git a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderExtensions.cs index c429dad7b01..c76befd9b75 100644 --- a/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry/Trace/Builder/TracerProviderBuilderExtensions.cs @@ -27,7 +27,7 @@ public static class TracerProviderBuilderExtensions /// /// This method is not supported in native AOT or Mono Runtime as of .NET 8. /// -#if NET7_0_OR_GREATER +#if NET [RequiresDynamicCode("The code for detecting exception and setting error status might not be available.")] #endif public static TracerProviderBuilder SetErrorStatusOnException(this TracerProviderBuilder tracerProviderBuilder, bool enabled = true) diff --git a/test/Directory.Packages.props b/test/Directory.Packages.props index d6755d05725..9e456e2826f 100644 --- a/test/Directory.Packages.props +++ b/test/Directory.Packages.props @@ -2,7 +2,7 @@ - + diff --git a/test/OpenTelemetry.Api.Tests/BaggageTests.cs b/test/OpenTelemetry.Api.Tests/BaggageTests.cs index e13aa68a502..32bc6a74f62 100644 --- a/test/OpenTelemetry.Api.Tests/BaggageTests.cs +++ b/test/OpenTelemetry.Api.Tests/BaggageTests.cs @@ -1,6 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +#nullable enable + using Xunit; namespace OpenTelemetry.Tests; @@ -27,8 +29,8 @@ public void SetAndGetTest() { var list = new List>(2) { - new KeyValuePair(K1, V1), - new KeyValuePair(K2, V2), + new(K1, V1), + new(K2, V2), }; Baggage.SetBaggage(K1, V1); @@ -44,7 +46,7 @@ public void SetAndGetTest() Assert.Null(Baggage.GetBaggage("NO_KEY")); Assert.Equal(V2, Baggage.Current.GetBaggage(K2)); - Assert.Throws(() => Baggage.GetBaggage(null)); + Assert.Throws(() => Baggage.GetBaggage(null!)); } [Fact] @@ -52,12 +54,12 @@ public void SetExistingKeyTest() { var list = new List>(2) { - new KeyValuePair(K1, V1), + new(K1, V1), }; - Baggage.Current.SetBaggage(new KeyValuePair(K1, V1)); + Baggage.Current.SetBaggage(new KeyValuePair(K1, V1)); var baggage = Baggage.SetBaggage(K1, V1); - Baggage.SetBaggage(new Dictionary { [K1] = V1 }, baggage); + Baggage.SetBaggage(new Dictionary { [K1] = V1 }, baggage); Assert.Equal(list, Baggage.GetBaggage()); } @@ -78,7 +80,7 @@ public void SetNullValueTest() Assert.Empty(Baggage.SetBaggage(K1, null).GetBaggage()); Baggage.SetBaggage(K1, V1); - Baggage.SetBaggage(new Dictionary + Baggage.SetBaggage(new Dictionary { [K1] = null, [K2] = V2, @@ -94,7 +96,7 @@ public void RemoveTest() var empty2 = Baggage.RemoveBaggage(K1); Assert.True(empty == empty2); - var baggage = Baggage.SetBaggage(new Dictionary + var baggage = Baggage.SetBaggage(new Dictionary { [K1] = V1, [K2] = V2, @@ -112,7 +114,7 @@ public void RemoveTest() [Fact] public void ClearTest() { - var baggage = Baggage.SetBaggage(new Dictionary + var baggage = Baggage.SetBaggage(new Dictionary { [K1] = V1, [K2] = V2, @@ -151,8 +153,8 @@ public void EnumeratorTest() { var list = new List>(2) { - new KeyValuePair(K1, V1), - new KeyValuePair(K2, V2), + new(K1, V1), + new(K2, V2), }; var baggage = Baggage.SetBaggage(K1, V1); @@ -207,7 +209,7 @@ public void CreateBaggageTest() ["key2"] = "value2", ["KEY2"] = "VALUE2", ["KEY3"] = "VALUE3", - ["Key3"] = null, + ["Key3"] = null!, // Note: This causes Key3 to be removed }); Assert.Equal(2, baggage.Count); @@ -232,7 +234,7 @@ public void EqualityTests() baggage = Baggage.SetBaggage(K1, V1); - var baggage2 = Baggage.SetBaggage(null); + var baggage2 = Baggage.SetBaggage(null!); Assert.Equal(baggage, baggage2); diff --git a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile index 7a8dc6f5705..fc50a196ecf 100644 --- a/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile +++ b/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile @@ -2,8 +2,8 @@ # This should be run from the root of the repo: # docker build --file test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/Dockerfile . -ARG BUILD_SDK_VERSION=8.0 -ARG TEST_SDK_VERSION=8.0 +ARG BUILD_SDK_VERSION=9.0 +ARG TEST_SDK_VERSION=9.0 FROM ubuntu AS w3c #Install git @@ -13,7 +13,7 @@ RUN git clone --branch level-1 https://github.com/w3c/trace-context.git FROM mcr.microsoft.com/dotnet/sdk:${BUILD_SDK_VERSION} AS build ARG PUBLISH_CONFIGURATION=Release -ARG PUBLISH_FRAMEWORK=net8.0 +ARG PUBLISH_FRAMEWORK=net9.0 WORKDIR /repo COPY . ./ WORKDIR "/repo/test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests" diff --git a/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs b/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs index 58777971b5d..3ea7ae3bf7a 100644 --- a/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs +++ b/test/OpenTelemetry.Tests/Internal/SelfDiagnosticsEventListenerTest.cs @@ -124,7 +124,9 @@ public void SelfDiagnosticsEventListener_EmitEvent_OmitAsConfigured() using FileStream file = File.Open(LOGFILEPATH, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); var buffer = new byte[256]; - file.Read(buffer, 0, buffer.Length); + + // Suppress CA2022 error: Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)' + _ = file.Read(buffer, 0, buffer.Length); Assert.Equal('\0', (char)buffer[0]); } @@ -256,7 +258,9 @@ private static void AssertFileOutput(string filePath, string eventMessage) { using FileStream file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); var buffer = new byte[256]; - file.Read(buffer, 0, buffer.Length); + + // Suppress CA2022 error: Avoid inexact read with 'System.IO.FileStream.Read(byte[], int, int)' + _ = file.Read(buffer, 0, buffer.Length); string logLine = Encoding.UTF8.GetString(buffer); string logMessage = ParseLogMessage(logLine); Assert.StartsWith(eventMessage, logMessage);