Doxense / foundationdb-dotnet-client

C#/.NET Binding for FoundationDB Client API
BSD 3-Clause "New" or "Revised" License
149 stars 33 forks source link

Not seeing telemetry in Aspire dashboard #141

Closed tskimmett closed 1 week ago

tskimmett commented 1 week ago

So far this project looks great and the actual FDB interaction is working perfectly. My only question is about how to get open telemetry working. As far as I can tell, tracing and metrics are enabled on the db client by default, but I'm not seeing anything in the aspire dashboard. I also noticed that individual transactions had null Log properties. I'm guessing I've just misconfigured something.

KrzysFR commented 1 week ago

Are you talking about spans and metrics?

I am declaring the fdb resources in the AppHost like this, and I can control the tracing options for all processes that will reference this resource.

var fdb = builder
    .AddFoundationDb("fdb", apiVersion: 720, root: "/Sandbox/HelloWorld", clusterVersion: "7.3.54", rollForward: FdbVersionPolicy.Exact)
    .WithDefaults(timeout: TimeSpan.FromSeconds(15), retryLimit: 10, tracing: FdbTracingOptions.All)
    .WithLifetime(ContainerLifetime.Persistent)
    ;

The call to WithDefaults(...., tracing: FdbTracingOptions.All) changes the default tracing options to include more detailed spans and metrics, but with Default you should already see some entries. With this, I can see spans in the dashboard:

image

image

As well as metrics: image

For both Metrics and Activities, the source name is FoundationDB.Client and you may have to change the log level in you appsettings.json file, depending on the logging library that you are using (Serilog? default .NET implementation?)

I looked in the ServiceDefaults and appsettings.json I am using, and did not see any other particular settings.

tskimmett commented 1 week ago

Yeah, spans and metrics. The main difference I see on my end is that I specified api version 730 and I'm using an ARM-based fdb docker image. I'll play around with that. Thanks for the quick response!

KrzysFR commented 1 week ago

the API level could be anything else, like 710 or 720. Are you on macOS on M3/M4 ? The current version published in NuGet does not correctly load libfdb_c on macOS (it looks for libfbd_c.so instead of libfdb_c.dylib which is fixed in the main branch).

Also, please note that the official docker images published on dockerhub by Apple usually come in pairs, with odd and even numbered version, which are built with and without AVX (I'm not sure why they do it that way??). The odd versions with AVX will not run on Docker Desktop on macOS, you have to select an even numbered version (like 7.3.54 instead of 7.3.55).

If everything starts correctly, you should see in the Aspire Dashboard that the fdb cluster resource is running. Then of course, you have to execute some fdb queries from your other process to see the logs/spans.

I have not yet done the work to send the telemetry from the fdb cluster itself via OpenTelemetry. I known this is supported by fdbserver via some environment variable, but I was not able to make it run previously.

For spans and metrics from the fdb .NET Client, they should be sent, unless you have some settings that set the log level to Warning/Error by default? The namespace of the client code is "FoundationDB.Client", (I'm not sure if this is case sensitive by the way!).

tskimmett commented 1 week ago

Yeah, the fdb container is running fine and I have a simple console application to do some basic benchmarking of reads/writes.

KrzysFR commented 1 week ago

Could share the code of your AppHost and the relevant parts of the console app?

tskimmett commented 1 week ago

Turns out it was just because I wasn't calling app.StartAsync() with my console app setup. Thanks for all the info. I'll go ahead and close this issue.