fun build()

in agent-sdk/src/main/java/co/elastic/otel/android/ElasticApmAgent.kt [293:345]


        fun build(): ElasticApmAgent {
            val finalExportUrl =
                exportUrl ?: throw NullPointerException("The export URL must be set.")

            val serviceManager = ServiceManager.create(application)

            Elog.init(
                AndroidLoggerFactory(loggingPolicy ?: LoggingPolicy.getDefault(serviceManager))
            )

            val systemTimeProvider = SystemTimeProvider()
            val connectivityConfiguration = ExportEndpointConfiguration(
                finalExportUrl,
                exportAuthentication,
                exportProtocol
            )
            val exportConnectivityManager = ExportConnectivityManager.create(
                connectivityConfiguration,
                exportHeadersInterceptor
            )
            val exporterProvider = DefaultExporterProvider.create(exportConnectivityManager)

            val managedFeatures =
                createManagedConfiguration(serviceManager, systemTimeProvider)

            val centralConfigurationManager = configureCentralConfigurationManager(
                serviceManager,
                systemTimeProvider,
                managedFeatures
            )
            val sampleRateManager = configureSampleRateManager(
                serviceManager,
                centralConfigurationManager,
                managedFeatures
            )

            managedAgentBuilder.setExporterProvider(
                internalExporterProviderInterceptor.intercept(
                    exporterProvider
                )
            )

            httpSpanInterceptor?.let {
                managedAgentBuilder.addSpanExporterInterceptor(HttpSpanExporterInterceptor(it))
            }

            return ElasticApmAgent(
                managedAgentBuilder.build(serviceManager, managedFeatures),
                exportConnectivityManager,
                centralConfigurationManager,
                sampleRateManager
            )
        }