static async Task Main(string[] args) { // TODO output different path depending on runtime version var sources = new [] { SourceAndConfig.CreateFrom(b => b.WithThreadPoolStats(CaptureLevel.Counters, new ThreadPoolMetricsProducer.Options())), SourceAndConfig.CreateFrom(b => b.WithThreadPoolStats(CaptureLevel.Informational, new ThreadPoolMetricsProducer.Options())), SourceAndConfig.CreateFrom(b => b.WithGcStats(CaptureLevel.Counters, new double[0])), SourceAndConfig.CreateFrom(b => b.WithGcStats(CaptureLevel.Informational, new double[0])), SourceAndConfig.CreateFrom(b => b.WithGcStats(CaptureLevel.Verbose, new double[0])), SourceAndConfig.CreateFrom(b => b.WithContentionStats(CaptureLevel.Counters, SampleEvery.OneEvent)), SourceAndConfig.CreateFrom(b => b.WithContentionStats(CaptureLevel.Informational, SampleEvery.OneEvent)), SourceAndConfig.CreateFrom(b => b.WithExceptionStats(CaptureLevel.Counters)), SourceAndConfig.CreateFrom(b => b.WithExceptionStats(CaptureLevel.Errors)), SourceAndConfig.CreateFrom(b => b.WithJitStats(CaptureLevel.Counters, SampleEvery.OneEvent)), SourceAndConfig.CreateFrom(b => b.WithJitStats(CaptureLevel.Verbose, SampleEvery.OneEvent)), SourceAndConfig.CreateFrom(b => b.WithExceptionStats(CaptureLevel.Errors)) }; var assemblyDocs = typeof(DotNetRuntimeStatsBuilder).Assembly.LoadXmlDocumentation(); var allMetrics = GetAllMetrics(sources); MdSpan[] GetCells(Collector m) { return(new MdSpan[] { new MdRawMarkdownSpan($"`{m.Name}`"), new MdRawMarkdownSpan($"`{m.GetType().Name}`"), m.Help, new MdRawMarkdownSpan(string.Join(", ", m.LabelNames.Select(x => $"`{x}`"))), }); } var document = new MdDocument(); var root = document.Root; root.Add(new MdHeading(new MdRawMarkdownSpan($"`.net {EventParserTypes.CurrentRuntimeVerison.Value}` metrics"), 1)); root.Add(new MdParagraph(new MdRawMarkdownSpan($"Each subheading details the metrics produced by calling builder methods with the specified `{nameof(CaptureLevel)}`."))); root.Add(new MdHeading("Default metrics", 2)); root.Add(new MdParagraph("Metrics that are included by default, regardless of what stats collectors are enabled.")); root.Add(new MdTable(headerRow: new MdTableRow("Name", "Type", "Description", "Labels"), allMetrics.CommonMetrics.Select(x => new MdTableRow(GetCells(x))).ToArray())); foreach (var methodAndSources in allMetrics.MethodsToSources) { root.Add(new MdHeading(new MdCodeSpan($".{methodAndSources.method.Name}()"), 2)); root.Add(new MdParagraph(assemblyDocs.GetDocumentation(methodAndSources.method).Summary)); for (var i = 0; i < methodAndSources.sources.Length; i++) { var s = methodAndSources.sources[i]; if (allMetrics.SourceToMetrics[s].Count == 0) { continue; } root.Add(new MdHeading(new MdCodeSpan($"{nameof(CaptureLevel)}." + s.Level), 3)); var previousLevels = methodAndSources.sources.Take(i).ToArray(); if (previousLevels.Length > 0) { root.Add(new MdParagraph( new MdRawMarkdownSpan($"Includes metrics generated by {string.Join(", ", previousLevels.Select(c => $"`{nameof(CaptureLevel)}.{c.Level}`"))} plus:") )); } root.Add(new MdTable(headerRow: new MdTableRow("Name", "Type", "Description", "Labels"), allMetrics.SourceToMetrics[s].Select(x => new MdTableRow(GetCells(x.Collector))).ToArray())); } } document.Save($"../../../../../docs/metrics-exposed-{EventParserTypes.CurrentRuntimeVerison.Value}.md"); }