I am collecting metrics from one .net app in another using DiagnosticsClient
:
var providers = new List<EventPipeProvider>()
{
new EventPipeProvider("System.Diagnostics.Metrics", EventLevel.Verbose, keywords: -1, arguments: new Dictionary<string, string>
{
["Metrics"] = "SomeApi",
["Metrics"] = "MyApp",
}),
};
client = new DiagnosticsClient(pid);
session = client.StartEventPipeSession(providers, requestRundown: false);
source = new EventPipeEventSource(session.EventStream);
source.Dynamic.All += (TraceEvent obj) =>
{
if (obj.PayloadNames.Length < 7) return;
var n = obj.PayloadValue(3) as string;
var v = obj.PayloadValue(6) as string;
//[0]: "sessionId"
//[1]: "meterName"
//[2]: "meterVersion"
//[3]: "instrumentName"
//[4]: "unit"
//[5]: "tags"
//[6]: "lastValue"
};
So I figured that payload index 6 is value for a “plane” metric like a counter. But if it is a histogram or observable gauge then there is no value.
I want to print values same as dotnet-counters does: