public override void Collect(ICollectContext ctx) { // Load object from memory var obj = ctx.Load <Dictionary <string, int> >("stored_object"); obj["counter"]++; ctx.Store("stored_object", obj); // Log messages with information from stored object ctx.Log(LogLevel.Info, "Log message from C#", new Dictionary <string, string> { { "language", "c#" }, { "counter", $"{obj["counter"]}" } }); ctx.AddWarning("Warning from C#"); // List requested metrics var reqMts = ctx.RequestedMetrics(); if (reqMts.Count > 0) { Console.WriteLine("Requested metrics: "); foreach (var mt in reqMts) { Console.WriteLine($"- {mt}"); } } // Add metrics ctx.AlwaysApply("/example/group1/*", Modifiers.Tags(new Dictionary <string, string> { { "virtualization", "VirtualBox" } })); ctx.AddMetric("/example/group1/metric1", 12.4, Modifiers.Tags(new Dictionary <string, string> { { "origin", "C# lang" }, { "system", "Windows" } }), Modifiers.Description("new custom description") ); ctx.AddMetric("/example/group1/metric2", 20); ctx.AddMetric("/example/group1/metric3", (uint)30); if (ctx.ShouldProcess("/example/group2/metric4")) { ctx.AddMetric("/example/group2/metric4", true); } ctx.AddMetric("/example/group2/metric5", "string value"); }