public static void InitSingleton(SimpleTracingSetupConfig setupConfig) { if (Instance != null) { return; } Instance = new SimpleTracingSetup(setupConfig); }
/// <summary> /// Should be instantiated before any Http request takes place /// </summary> /// <param name="setupConfig"></param> private SimpleTracingSetup(SimpleTracingSetupConfig setupConfig) { setupConfig.CheckValidity(); this._setupConfig = setupConfig; var probabilisticSampler = new ProbabilisticSampler(this._setupConfig.TracingComponentsConfigProvider); var debugModeSampler = new DebugModeSampler(probabilisticSampler, this._setupConfig.DebugModeConfig); var sampler = new TracesThrottlerSampler( new ParentBasedSampler(debugModeSampler), this._setupConfig.TracingComponentsConfigProvider); this._setupConfig.InstrumentationConfig.WithSampler(sampler); var httpClientHeadersTracker = new ClientHeadersTracker(this._setupConfig.TracingComponentsConfigProvider); this._setupConfig.InstrumentationConfig.HttpInstrumentationEnrichHooks.Add(httpClientHeadersTracker); TracingSetup.PreConfigure(this._setupConfig.InstrumentationConfig); this._startTraceHandler = new StartTraceHandler( ActivityTracer.Singleton, () => sampler.DecrementOngoingTraces(), this._setupConfig.RouteTemplateProvider, this._setupConfig.DebugModeConfig, this._setupConfig.TracingComponentsConfigProvider ); this._periodicUpdater = new PeriodicUpdater( this._setupConfig.ComponentsUpdateInterval, this._setupConfig.ComponentsUpdateTimeout, this._setupConfig.TracingComponentsConfigProvider, new List <IConfigUpdatableComponent> { probabilisticSampler, sampler, httpClientHeadersTracker, this._startTraceHandler }, this._setupConfig.Logger, this._setupConfig.MetricsTracker); this._periodicMetricsReporter = new PeriodicMetricsReporter( this._setupConfig.ComponentsMetricsReportInterval, new List <IMeasurableComponent> { probabilisticSampler, debugModeSampler, sampler, this._startTraceHandler }, this._setupConfig.Logger, this._setupConfig.MetricsTracker); }