Beispiel #1
0
        internal static MeterProviderBuilder AddOtlpExporter(
            MeterProviderBuilder builder,
            OtlpExporterOptions exporterOptions,
            MetricReaderOptions metricReaderOptions,
            Action <OtlpExporterOptions> configureExporter,
            Action <OtlpExporterOptions, MetricReaderOptions> configureExporterAndMetricReader,
            IServiceProvider serviceProvider,
            Func <BaseExporter <Metric>, BaseExporter <Metric> > configureExporterInstance = null)
        {
            if (configureExporterAndMetricReader != null)
            {
                configureExporterAndMetricReader.Invoke(exporterOptions, metricReaderOptions);
            }
            else
            {
                configureExporter?.Invoke(exporterOptions);
            }

            exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter");

            BaseExporter <Metric> metricExporter = new OtlpMetricExporter(exporterOptions);

            if (configureExporterInstance != null)
            {
                metricExporter = configureExporterInstance(metricExporter);
            }

            var metricReader = PeriodicExportingMetricReaderHelper.CreatePeriodicExportingMetricReader(
                metricExporter,
                metricReaderOptions,
                DefaultExportIntervalMilliseconds,
                DefaultExportTimeoutMilliseconds);

            return(builder.AddReader(metricReader));
        }
        private static TracerProviderBuilder AddOtlpExporter(
            TracerProviderBuilder builder,
            OtlpExporterOptions exporterOptions,
            Action <OtlpExporterOptions> configure,
            IServiceProvider serviceProvider)
        {
            var originalEndpoint = exporterOptions.Endpoint;

            configure?.Invoke(exporterOptions);

            exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpTraceExporter");

            exporterOptions.AppendExportPath(originalEndpoint, OtlpExporterOptions.TracesExportPath);

            var otlpExporter = new OtlpTraceExporter(exporterOptions);

            if (exporterOptions.ExportProcessorType == ExportProcessorType.Simple)
            {
                return(builder.AddProcessor(new SimpleActivityExportProcessor(otlpExporter)));
            }
            else
            {
                return(builder.AddProcessor(new BatchActivityExportProcessor(
                                                otlpExporter,
                                                exporterOptions.BatchExportProcessorOptions.MaxQueueSize,
                                                exporterOptions.BatchExportProcessorOptions.ScheduledDelayMilliseconds,
                                                exporterOptions.BatchExportProcessorOptions.ExporterTimeoutMilliseconds,
                                                exporterOptions.BatchExportProcessorOptions.MaxExportBatchSize)));
            }
        }
        internal static TracerProviderBuilder AddOtlpExporter(
            TracerProviderBuilder builder,
            OtlpExporterOptions exporterOptions,
            Action <OtlpExporterOptions> configure,
            IServiceProvider serviceProvider,
            Func <BaseExporter <Activity>, BaseExporter <Activity> > configureExporterInstance = null)
        {
            configure?.Invoke(exporterOptions);

            exporterOptions.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpTraceExporter");

            BaseExporter <Activity> otlpExporter = new OtlpTraceExporter(exporterOptions);

            if (configureExporterInstance != null)
            {
                otlpExporter = configureExporterInstance(otlpExporter);
            }

            if (exporterOptions.ExportProcessorType == ExportProcessorType.Simple)
            {
                return(builder.AddProcessor(new SimpleActivityExportProcessor(otlpExporter)));
            }
            else
            {
                var batchOptions = exporterOptions.BatchExportProcessorOptions ?? new();

                return(builder.AddProcessor(new BatchActivityExportProcessor(
                                                otlpExporter,
                                                batchOptions.MaxQueueSize,
                                                batchOptions.ScheduledDelayMilliseconds,
                                                batchOptions.ExporterTimeoutMilliseconds,
                                                batchOptions.MaxExportBatchSize)));
            }
        }
        private static MeterProviderBuilder AddOtlpExporter(
            MeterProviderBuilder builder,
            OtlpExporterOptions options,
            Action <OtlpExporterOptions> configure,
            IServiceProvider serviceProvider)
        {
            var initialEndpoint = options.Endpoint;

            configure?.Invoke(options);

            options.TryEnableIHttpClientFactoryIntegration(serviceProvider, "OtlpMetricExporter");

            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));
        }