Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code from Http instrumentation #5159

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ namespace OpenTelemetry.Instrumentation.Http;

internal static class HttpRequestMessageContextPropagation
{
internal static Func<HttpRequestMessage, string, IEnumerable<string>> HeaderValuesGetter => (request, name) =>
{
if (request.Headers.TryGetValues(name, out var values))
{
return values;
}

return null;
};

internal static Action<HttpRequestMessage, string, string> HeaderValueSetter => (request, name, value) =>
{
request.Headers.Remove(name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Collections.Concurrent;
#if NETFRAMEWORK
using System.Net.Http;
#endif

namespace OpenTelemetry.Instrumentation.Http.Implementation;

/// <summary>
/// A collection of helper methods to be used when building Http activities.
/// </summary>
internal static class HttpTagHelper
{
private static readonly ConcurrentDictionary<string, string> MethodOperationNameCache = new();
private static readonly ConcurrentDictionary<HttpMethod, string> HttpMethodOperationNameCache = new();
private static readonly ConcurrentDictionary<HttpMethod, string> HttpMethodNameCache = new();

private static readonly Func<string, string> ConvertMethodToOperationNameRef = ConvertMethodToOperationName;
private static readonly Func<HttpMethod, string> ConvertHttpMethodToOperationNameRef = ConvertHttpMethodToOperationName;
private static readonly Func<HttpMethod, string> ConvertHttpMethodToNameRef = ConvertHttpMethodToName;

/// <summary>
/// Gets the OpenTelemetry standard name for an activity based on its Http method.
/// </summary>
/// <param name="method">Http method.</param>
/// <returns>Activity name.</returns>
public static string GetOperationNameForHttpMethod(string method) => MethodOperationNameCache.GetOrAdd(method, ConvertMethodToOperationNameRef);

/// <summary>
/// Gets the OpenTelemetry standard operation name for a span based on its <see cref="HttpMethod"/>.
/// </summary>
/// <param name="method"><see cref="HttpMethod"/>.</param>
/// <returns>Span operation name.</returns>
public static string GetOperationNameForHttpMethod(HttpMethod method) => HttpMethodOperationNameCache.GetOrAdd(method, ConvertHttpMethodToOperationNameRef);

/// <summary>
/// Gets the OpenTelemetry standard method name for a span based on its <see cref="HttpMethod"/>.
/// </summary>
/// <param name="method"><see cref="HttpMethod"/>.</param>
/// <returns>Span method name.</returns>
public static string GetNameForHttpMethod(HttpMethod method) => HttpMethodNameCache.GetOrAdd(method, ConvertHttpMethodToNameRef);

/// <summary>
/// Gets the OpenTelemetry standard uri tag value for a span based on its request <see cref="Uri"/>.
/// </summary>
Expand All @@ -65,10 +31,4 @@ public static string GetUriTagValueFromRequestUri(Uri uri)
(3, 0) => "3",
_ => httpVersion.ToString(),
};

private static string ConvertMethodToOperationName(string method) => $"HTTP {method}";

private static string ConvertHttpMethodToOperationName(HttpMethod method) => $"HTTP {method}";

private static string ConvertHttpMethodToName(HttpMethod method) => method.ToString();
}