Skip to content

Commit

Permalink
Merge branch 'main' into net9prep-elastic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Nov 4, 2024
2 parents 4299604 + a1edda6 commit 2640277
Show file tree
Hide file tree
Showing 63 changed files with 76 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static void BeginRequest(IOwinContext owinContext)
var textMapPropagator = Propagators.DefaultTextMapPropagator;
var ctx = textMapPropagator.Extract(default, owinContext.Request, OwinRequestHeaderValuesGetter);

Activity? activity = OwinInstrumentationActivitySource.ActivitySource.StartActivity(
var activity = OwinInstrumentationActivitySource.ActivitySource.StartActivity(
OwinInstrumentationActivitySource.IncomingRequestActivityName,
ActivityKind.Server,
ctx.ActivityContext);
Expand All @@ -103,7 +103,7 @@ private static void BeginRequest(IOwinContext owinContext)
activity.SetTag(SemanticConventions.AttributeUrlQuery, request.Query);
activity.SetTag(SemanticConventions.AttributeUrlScheme, owinContext.Request.Scheme);

if (request.Headers.TryGetValue("User-Agent", out string[] userAgent) && userAgent.Length > 0)
if (request.Headers.TryGetValue("User-Agent", out var userAgent) && userAgent.Length > 0)
{
activity.SetTag(SemanticConventions.AttributeUserAgentOriginal, userAgent[0]);
}
Expand All @@ -124,7 +124,7 @@ private static void BeginRequest(IOwinContext owinContext)
}
}

if (!(textMapPropagator is TraceContextPropagator))
if (textMapPropagator is not TraceContextPropagator)
{
Baggage.Current = ctx.Baggage;
}
Expand All @@ -136,7 +136,7 @@ private static void BeginRequest(IOwinContext owinContext)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void RequestEnd(IOwinContext owinContext, Exception? exception, long startTimestamp)
{
if (owinContext.Environment.TryGetValue(ContextKey, out object context)
if (owinContext.Environment.TryGetValue(ContextKey, out var context)
&& context is Activity activity)
{
if (Activity.Current != activity)
Expand Down Expand Up @@ -191,7 +191,7 @@ private static void RequestEnd(IOwinContext owinContext, Exception? exception, l
new(SemanticConventions.AttributeHttpResponseStatusCode, owinContext.Response.StatusCode));
}

if (!(Propagators.DefaultTextMapPropagator is TraceContextPropagator))
if (Propagators.DefaultTextMapPropagator is not TraceContextPropagator)
{
Baggage.Current = default;
}
Expand All @@ -209,21 +209,4 @@ private static void RequestEnd(IOwinContext owinContext, Exception? exception, l
new(SemanticConventions.AttributeHttpResponseStatusCode, owinContext.Response.StatusCode));
}
}

/// <summary>
/// Gets the OpenTelemetry standard uri tag value for a span based on its request <see cref="Uri"/>.
/// </summary>
/// <param name="uri"><see cref="Uri"/>.</param>
/// <returns>Span uri value.</returns>
private static string GetUriTagValueFromRequestUri(Uri uri, bool disableQueryRedaction)
{
if (string.IsNullOrEmpty(uri.UserInfo) && disableQueryRedaction)
{
return uri.OriginalString;
}

var query = disableQueryRedaction ? uri.Query : RedactionHelper.GetRedactedQueryString(uri.Query);

return string.Concat(uri.Scheme, Uri.SchemeDelimiter, uri.Authority, uri.AbsolutePath, query, uri.Fragment);
}
}
2 changes: 0 additions & 2 deletions src/OpenTelemetry.Instrumentation.Process/ProcessMetrics.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics.Metrics;
using System.Reflection;
using OpenTelemetry.Internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public QuartzDiagnosticListener(string sourceName, QuartzInstrumentationOptions

public override void OnEventWritten(string name, object? payload)
{
Activity? activity = Activity.Current;
var activity = Activity.Current;
Guard.ThrowIfNull(activity);
switch (name)
{
Expand All @@ -44,6 +44,8 @@ public override void OnEventWritten(string name, object? payload)
case "Quartz.Job.Veto.Exception":
this.OnException(activity, payload);
break;
default:
break;
}
}

Expand Down Expand Up @@ -127,8 +129,7 @@ private void OnException(Activity activity, object? payload)
{
if (activity.IsAllDataRequested)
{
var exc = payload as Exception;
if (exc == null)
if (payload is not Exception exc)
{
QuartzInstrumentationEventSource.Log.NullPayload(nameof(QuartzDiagnosticListener), nameof(this.OnStopActivity));
return;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/ActivityHelperExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using System.Runtime.CompilerServices;

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/ActivityInstrumentationHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;

namespace OpenTelemetry.Instrumentation;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/AssemblyVersionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using System.Reflection;

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/Configuration/IConfigurationExtensionsLogger.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

namespace Microsoft.Extensions.Configuration;

internal interface IConfigurationExtensionsLogger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
#if NET || NETSTANDARD2_1
using System.Diagnostics.CodeAnalysis;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/DatabaseSemanticConventionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/DiagnosticSourceListener.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using OpenTelemetry.Internal;

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/DiagnosticSourceSubscriber.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using OpenTelemetry.Internal;

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Globalization;

namespace OpenTelemetry.Internal;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/GrpcStatusCanonicalCode.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

namespace OpenTelemetry.Instrumentation;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/GrpcTagHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using System.Text.RegularExpressions;
using OpenTelemetry.Trace;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/Guard.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

// Note: For some targets this file will contain more than one type/namespace.
#pragma warning disable IDE0161 // Convert to file-scoped namespace

Expand Down
2 changes: 0 additions & 2 deletions src/Shared/ListenerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

using System.Diagnostics;

#nullable enable

namespace OpenTelemetry.Instrumentation;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/MultiTypePropertyFetcher.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Collections.Concurrent;
using System.Reflection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
#if NET
using System.Diagnostics.CodeAnalysis;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/Options/SingletonOptionsManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

#if NET
using System.Diagnostics.CodeAnalysis;
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/PropertyFetcher.AOT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Usages of the non-AOT-compatible version can be moved over to this one when they need to support AOT/trimming.
// Copied from https://github.com/open-telemetry/opentelemetry-dotnet/blob/86a6ba0b7f7ed1f5e84e5a6610e640989cd3ae9f/src/Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs#L30

#nullable enable

#if NETSTANDARD2_1_0_OR_GREATER || NET
using System.Diagnostics.CodeAnalysis;
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/RedactionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Text;

namespace OpenTelemetry.Internal;
Expand Down
2 changes: 0 additions & 2 deletions src/Shared/RequestDataHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

#if NET
using System.Collections.Frozen;
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Diagnostics;
using System.Globalization;
using System.Net.Sockets;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using Xunit;

namespace OpenTelemetry.Exporter.Geneva.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Diagnostics;
using System.Diagnostics.Metrics;
using System.Globalization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Diagnostics;
using System.Net.Sockets;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Text;
using OpenTelemetry.Exporter.Geneva.Tld;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Net.Sockets;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Globalization;
using System.Text;
using OpenTelemetry.Exporter.Geneva.MsgPack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net48;net472;net471;net47;net462</TargetFrameworks>
<Description>Unit test project for Geneva Exporters for OpenTelemetry.</Description>
<NoWarn>$(NoWarn);SA1311;SA1312;SA1313;SA1123;SA1202;OTEL1002</NoWarn>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Diagnostics;
using System.Diagnostics.Metrics;
using Google.Protobuf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Text;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable disable

using System.Net.Sockets;
using System.Reflection;
using OpenTelemetry.Exporter.Geneva.Transports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#if !NET

#nullable disable

using System.Net;
using System.Net.Sockets;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#if NET6_0_OR_GREATER

#nullable enable

using System.Diagnostics;
using System.Globalization;
using System.Text.RegularExpressions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#nullable enable

using System.Diagnostics;
using OpenTelemetry.Exporter.Instana.Implementation;
using OpenTelemetry.Exporter.Instana.Implementation.Processors;
Expand Down
Loading

0 comments on commit 2640277

Please sign in to comment.