/// <summary> /// Adds InMemory exporter to the TracerProvider. /// </summary> /// <param name="builder"><see cref="MeterProviderBuilder"/> builder to use.</param> /// <param name="exportedItems">Collection which will be populated with the exported MetricItem.</param> /// <returns>The instance of <see cref="MeterProviderBuilder"/> to chain the calls.</returns> public static MeterProviderBuilder AddInMemoryExporter(this MeterProviderBuilder builder, ICollection <Metric> exportedItems) { Guard.ThrowIfNull(builder, nameof(builder)); Guard.ThrowIfNull(exportedItems, nameof(exportedItems)); return(builder.AddReader(new BaseExportingMetricReader(new InMemoryExporter <Metric>(exportedItems)))); }
private static MeterProviderBuilder AddPrometheusExporter(MeterProviderBuilder builder, PrometheusExporterOptions options, Action <PrometheusExporterOptions> configure = null) { configure?.Invoke(options); var exporter = new PrometheusExporter(options); var reader = new BaseExportingMetricReader(exporter); return(builder.AddReader(reader)); }
private static MeterProviderBuilder AddOtlpExporter(MeterProviderBuilder builder, OtlpExporterOptions options, Action <OtlpExporterOptions> configure = null) { configure?.Invoke(options); var metricExporter = new OtlpMetricExporter(options); var metricReader = new PeriodicExportingMetricReader(metricExporter, options.MetricExportIntervalMilliseconds); metricReader.PreferredAggregationTemporality = options.AggregationTemporality; return(builder.AddReader(metricReader)); }
private static MeterProviderBuilder AddOtlpExporter(MeterProviderBuilder builder, OtlpExporterOptions options, Action <OtlpExporterOptions> configure = null) { var initialEndpoint = options.Endpoint; configure?.Invoke(options); options.AppendExportPath(initialEndpoint, OtlpExporterOptions.MetricsExportPath); var metricExporter = new OtlpMetricExporter(options); var metricReader = options.MetricReaderType == MetricReaderType.Manual ? new BaseExportingMetricReader(metricExporter) : new PeriodicExportingMetricReader(metricExporter, options.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds); metricReader.Temporality = options.AggregationTemporality; return(builder.AddReader(metricReader)); }
public static MeterProviderBuilder AddConsoleExporter(this MeterProviderBuilder builder, Action <ConsoleExporterOptions> configure = null) { Guard.Null(builder, nameof(builder)); var options = new ConsoleExporterOptions(); configure?.Invoke(options); var exporter = new ConsoleMetricExporter(options); var reader = options.MetricExportIntervalMilliseconds == Timeout.Infinite ? new BaseExportingMetricReader(exporter) : new PeriodicExportingMetricReader(exporter, options.MetricExportIntervalMilliseconds); reader.PreferredAggregationTemporality = options.AggregationTemporality; return(builder.AddReader(reader)); }
private static MeterProviderBuilder AddInMemoryExporter( MeterProviderBuilder builder, ICollection <Metric> exportedItems, MetricReaderOptions metricReaderOptions, Action <MetricReaderOptions> configureMetricReader) { configureMetricReader?.Invoke(metricReaderOptions); var metricExporter = new InMemoryExporter <Metric>(exportedItems); var metricReader = PeriodicExportingMetricReaderHelper.CreatePeriodicExportingMetricReader( metricExporter, metricReaderOptions, DefaultExportIntervalMilliseconds, DefaultExportTimeoutMilliseconds); return(builder.AddReader(metricReader)); }