-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support ActivitySource in ClientHelper
This wires everything up, but doesn't actually start any activities. The implementation will all be in ApiCallTracingExtensions, in another commit.
- Loading branch information
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2024 Google LLC All Rights Reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file or at | ||
* https://developers.google.com/open-source/licenses/bsd | ||
*/ | ||
|
||
using Grpc.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Google.Api.Gax.Grpc; | ||
|
||
/// <summary> | ||
/// Extension methods to provide tracing via <see cref="ActivitySource"/>. | ||
/// </summary> | ||
internal static class ApiCallTracingExtensions | ||
{ | ||
// Unary async | ||
internal static Func<TRequest, CallSettings, Task<TResponse>> WithTracing<TRequest, TResponse>( | ||
this Func<TRequest, CallSettings, Task<TResponse>> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
|
||
// Unary sync | ||
internal static Func<TRequest, CallSettings, TResponse> WithTracing<TRequest, TResponse>( | ||
this Func<TRequest, CallSettings, TResponse> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
|
||
// Server-streaming async | ||
internal static Func<TRequest, CallSettings, Task<AsyncServerStreamingCall<TResponse>>> WithTracing<TRequest, TResponse>( | ||
this Func<TRequest, CallSettings, Task<AsyncServerStreamingCall<TResponse>>> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
|
||
// Server-streaming sync | ||
internal static Func<TRequest, CallSettings, AsyncServerStreamingCall<TResponse>> WithTracing<TRequest, TResponse>( | ||
this Func<TRequest, CallSettings, AsyncServerStreamingCall<TResponse>> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
|
||
// Client-streaming | ||
internal static Func<CallSettings, AsyncClientStreamingCall<TRequest, TResponse>> WithTracing<TRequest, TResponse>( | ||
this Func<CallSettings, AsyncClientStreamingCall<TRequest, TResponse>> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
|
||
// Bidi-streaming | ||
internal static Func<CallSettings, AsyncDuplexStreamingCall<TRequest, TResponse>> WithTracing<TRequest, TResponse>( | ||
this Func<CallSettings, AsyncDuplexStreamingCall<TRequest, TResponse>> fn, ActivitySource activitySource, string methodName) => | ||
fn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters