Eventuous / eventuous

Event Sourcing library for .NET
https://eventuous.dev
Apache License 2.0
458 stars 73 forks source link

Metrics don't work when tracing is not used #173

Closed alexeyzimarev closed 1 year ago

alexeyzimarev commented 1 year ago

If the tracing collection is not set up, but metrics are configured, the diagnostics of durations don't work correctly. Well, they don't work at all.

The reason is that we removed the sampling functions from internal activity listeners as the activity sampling is collected across all the listeners when the activity is created. Therefore, if one listener says: "I want it all", all the listeners will get it, even if they don't want it. As a result, when internal listeners asked for all activities (no sampling), the tracing sampling didn't work, and all the traces were collected without sampling. It caused over-reporting to the APM provider and increased costs (Datadog).

So, we removed the sampling function from the internal listeners, and now there's no sampling defined when you only use metrics. As duration metrics (histograms) are collected by plugging into the activity source OnActivityStopped because activities were not created, the function is not called, and metrics aren't collected.

The only solution I see is not to use activities and listeners for histograms and use the metrics directly.