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

Add federation tracing extension method #894

Merged
merged 5 commits into from
Aug 16, 2022
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
@@ -0,0 +1,25 @@
namespace GraphQL.Utilities.Federation;

/// <summary>
/// <see cref="HttpRequest" /> extension methods for checking headers.
/// </summary>
public static class GraphQLHttpRequestExtensions
{
private const string HEADER_NAME = "apollo-federation-include-trace";
private const string HEADER_VALUE = "ftv1";

/// <summary>
/// Determines if federated tracing is enabled through HTTP headers.
/// </summary>
/// <returns><see langword="true"/> if the 'apollo-federation-include-trace' HTTP header has a value of 'ftv1'</returns>
public static bool IsApolloFederatedTracingEnabled(this HttpRequest request)
{
var headers = request?.Headers;
if (headers != null && headers.TryGetValue(HEADER_NAME, out var values))
{
var value = values.FirstOrDefault();
return HEADER_VALUE.Equals(value, StringComparison.OrdinalIgnoreCase);
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ namespace GraphQL
where TWebSocketAuthenticationService : class, GraphQL.Server.Transports.AspNetCore.WebSockets.IWebSocketAuthenticationService { }
}
}
namespace GraphQL.Utilities.Federation
{
public static class GraphQLHttpRequestExtensions
{
public static bool IsApolloFederatedTracingEnabled(this Microsoft.AspNetCore.Http.HttpRequest request) { }
}
}
namespace Microsoft.AspNetCore.Builder
{
public class GraphQLEndpointConventionBuilder : Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ namespace GraphQL
where TWebSocketAuthenticationService : class, GraphQL.Server.Transports.AspNetCore.WebSockets.IWebSocketAuthenticationService { }
}
}
namespace GraphQL.Utilities.Federation
{
public static class GraphQLHttpRequestExtensions
{
public static bool IsApolloFederatedTracingEnabled(this Microsoft.AspNetCore.Http.HttpRequest request) { }
}
}
namespace Microsoft.AspNetCore.Builder
{
public static class GraphQLHttpApplicationBuilderExtensions
Expand Down