internal static TracerProviderBuilder AddElasticProcessorsCore()

in src/Elastic.OpenTelemetry.Core/Extensions/TracerProviderBuilderExtensions.cs [78:107]


	internal static TracerProviderBuilder AddElasticProcessorsCore(
		TracerProviderBuilder builder,
		BuilderState? builderState,
		ElasticOpenTelemetryComponents? components,
		IServiceCollection? services)
	{
		components ??= builderState?.Components;

		var callCount = Interlocked.Increment(ref AddElasticProcessorsCallCount);

		var logger = SignalBuilder.GetLogger(builder, components, null, builderState);

		if (callCount > 1)
			logger.LogMultipleAddElasticProcessorsCallsWarning(callCount);

		if (builderState is not null)
		{
			// When we have existing builderState, this method is being invoked from the main WithElasticDefaults method.
			// In that scenario, we skip configuring the resource, as it will have already been configured by the caller.
			return builder;
		}

		return SignalBuilder.WithElasticDefaults(builder, Signals.Traces, components?.Options, components, null, ConfigureBuilder);

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		static void ConfigureBuilder(TracerProviderBuilder builder, BuilderState builderState, IServiceCollection? services)
		{
			builder.ConfigureResource(r => r.WithElasticDefaultsCore(builderState, services, null));
		}
	}