internal MeterProviderSdk(MetricProcessor metricProcessor, Dictionary <MeterRegistryKey, MeterSdk> registry, PushMetricController controller, CancellationTokenSource cts)
 {
     this.MetricProcessor         = metricProcessor;
     this.PushMetricController    = controller;
     this.CancellationTokenSource = cts;
     this.defaultMeter            = new MeterSdk(string.Empty, this.MetricProcessor);
     this.MeterRegistry           = registry;
     this.MeterRegistry.Add(new MeterRegistryKey(string.Empty, null), this.defaultMeter);
 }
        private MeterFactory(MeterBuilder meterBuilder)
        {
            this.metricProcessor = meterBuilder.MetricProcessor ?? new NoOpMetricProcessor();
            this.metricExporter  = meterBuilder.MetricExporter ?? new NoOpMetricExporter();

            // We only have PushMetricController now with only configurable thing being the push interval
            this.PushMetricController = new PushMetricController(
                this.meterRegistry,
                this.metricProcessor,
                this.metricExporter,
                meterBuilder.MetricPushInterval == default(TimeSpan) ? this.defaultPushInterval : meterBuilder.MetricPushInterval,
                new CancellationTokenSource());

            this.defaultMeter = new MeterSdk(string.Empty, this.metricProcessor);
            this.meterRegistry.Add(new MeterRegistryKey(string.Empty, null), this.defaultMeter);
        }
        public override Meter GetMeter(string name, string version = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(this.defaultMeter);
            }

            lock (this.syncObject)
            {
                var key = new MeterRegistryKey(name, version);
                if (!this.MeterRegistry.TryGetValue(key, out var meter))
                {
                    meter = this.defaultMeter = new MeterSdk(name, this.MetricProcessor);

                    this.MeterRegistry.Add(key, meter);
                }

                return(meter);
            }
        }