Tracing RavenDB requests #13334
-
Hi everybody, I am trying to add tracing to all requests that are going to RavenDB. I found the following idea However, for tracing the tracing library APIs don't really go well along with this concept, as generally a disposable object is used in a block scope fashion for instrumentation. static async Task StepOne()
{
using (Activity activity = source.StartActivity("StepOne"))
{
await Task.Delay(500);
}
} same applies to GCP tracing lib I think a possible way around it would be using the IHttpClientFactory, but it seems RavenDB is creating the client directly using ravendb/src/Raven.Client/Http/RequestExecutor.cs Line 1903 in f773b7d If the factory would be used, like recommended here public static IHostBuilder CreateHostBuilder() =>
new HostBuilder()
.ConfigureServices(services =>
{
// Replace ProjectId with your Google Cloud Project ID.
services.AddGoogleTrace(new TraceServiceOptions { ProjectId = ProjectId });
// Register an HttpClient for outgoing requests.
services.AddHttpClient("tracesOutgoing")
// The next call guarantees that trace information is propagated for outgoing
// requests that are already being traced.
.AddOutgoingGoogleTraceHandler();
// Register other services here if you need them.
});
----
IHttpClientFactory clientFactory = host.Services.GetRequiredService<IHttpClientFactory>();
var httpClient = clientFactory.CreateClient("tracesOutgoing");
// Any code that makes outgoing requests.
var response = await httpClient.GetAsync("http://weather.com/"); Would be great if anybody has some recommendations on how to hook up those two concepts! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Here is our integration of RavenDB request tracing with HttpDiagnosticSourceSubscriber to MiniProfiler https://gist.github.com/vlko/708c046c547c6684c547154ebaa74f1f |
Beta Was this translation helpful? Give feedback.
-
You can handle this like so, no?
|
Beta Was this translation helpful? Give feedback.
You can handle this like so, no?