/// <summary>
        /// Starts the exporter.
        /// </summary>
        public void Start()
        {
            lock (this.locker)
            {
                if (this.isInitialized)
                {
                    return;
                }

                // Register stats(metrics) exporter
                if (this.viewManager != null)
                {
                    var credential = this.GetGoogleCredential();

                    var statsConfig = StackdriverStatsConfiguration.Default;
                    statsConfig.GoogleCredential = credential;
                    if (statsConfig.ProjectId != this.projectId)
                    {
                        statsConfig.ProjectId         = this.projectId;
                        statsConfig.MonitoredResource = GoogleCloudResourceUtils.GetDefaultResource(this.projectId);
                    }

                    this.statsExporter = new StackdriverStatsExporter(this.viewManager, statsConfig);
                    this.statsExporter.Start();
                }

                this.isInitialized = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the exporter
        /// </summary>
        public void Start()
        {
            lock (locker)
            {
                if (isInitialized)
                {
                    return;
                }

                // Register trace exporter
                if (exportComponent != null)
                {
                    var traceExporter = new StackdriverTraceExporter(projectId);
                    exportComponent.SpanExporter.RegisterHandler(ExporterName, traceExporter);
                }

                // Register stats(metrics) exporter
                if (viewManager != null)
                {
                    var credential = GetGoogleCredential();

                    var statsConfig = StackdriverStatsConfiguration.Default;
                    statsConfig.GoogleCredential = credential;
                    if (statsConfig.ProjectId != projectId)
                    {
                        statsConfig.ProjectId         = projectId;
                        statsConfig.MonitoredResource = GoogleCloudResourceUtils.GetDefaultResource(projectId);
                    }

                    statsExporter = new StackdriverStatsExporter(viewManager, statsConfig);
                    statsExporter.Start();
                }

                isInitialized = true;
            }
        }