Exemplo n.º 1
0
        public TelemetryEvents(
            FabricClient fabricClient,
            ServiceContext context,
            ITelemetryEventSource eventSource)
        {
            this.eventSource    = eventSource;
            this.serviceContext = context;
            var appInsightsTelemetryConf = TelemetryConfiguration.CreateDefault();

            appInsightsTelemetryConf.InstrumentationKey = TelemetryConstants.AppInsightsInstrumentationKey;
            appInsightsTelemetryConf.TelemetryChannel.EndpointAddress = TelemetryConstants.TelemetryEndpoint;
            this.telemetryClient = new TelemetryClient(appInsightsTelemetryConf);
            ClusterIdentificationUtility clusterIdentificationUtility = null;

            try
            {
                clusterIdentificationUtility = new ClusterIdentificationUtility(fabricClient);
                clusterIdentificationUtility.GetClusterIdAndType(
                    out this.clusterId,
                    out this.tenantId,
                    out this.clusterType);
            }
            finally
            {
                clusterIdentificationUtility?.Dispose();
            }
        }
        public TelemetryEvents(
            FabricClient fabricClient,
            ServiceContext context,
            ITelemetryEventSource eventSource,
            CancellationToken token)
        {
            this.eventSource    = eventSource;
            this.serviceContext = context;
            var appInsightsTelemetryConf = TelemetryConfiguration.CreateDefault();

            appInsightsTelemetryConf.InstrumentationKey = TelemetryConstants.AppInsightsInstrumentationKey;
            appInsightsTelemetryConf.TelemetryChannel.EndpointAddress = TelemetryConstants.TelemetryEndpoint;
            this.telemetryClient = new TelemetryClient(appInsightsTelemetryConf);

            var clusterInfoTuple = ClusterIdentificationUtility.TupleGetClusterIdAndTypeAsync(fabricClient, token).GetAwaiter().GetResult();

            this.clusterId   = clusterInfoTuple.Item1;
            this.tenantId    = clusterInfoTuple.Item2;
            this.clusterType = clusterInfoTuple.Item3;
        }