Exemplo n.º 1
0
        public async Task <bool> ReportMetricAsync <T>(
            string name,
            T value,
            string source,
            CancellationToken cancellationToken)
        {
            var(clusterId, _, _) =
                await ClusterIdentificationUtility.TupleGetClusterIdAndTypeAsync(
                    this.fabricClient,
                    this.token).ConfigureAwait(true);

            string jsonPayload = JsonConvert.SerializeObject(
                new
            {
                id        = $"FO_{Guid.NewGuid()}",
                datetime  = DateTime.UtcNow,
                clusterId = clusterId ?? string.Empty,
                source,
                property = name,
                value,
            });

            await this.SendTelemetryAsync(jsonPayload).ConfigureAwait(false);

            return(await Task.FromResult(true).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public async Task ReportHealthAsync(
            HealthScope scope,
            string propertyName,
            HealthState state,
            string unhealthyEvaluations,
            string source,
            CancellationToken cancellationToken,
            string serviceName  = null,
            string instanceName = null)
        {
            var(clusterId, tenantId, clusterType) =
                await ClusterIdentificationUtility.TupleGetClusterIdAndTypeAsync(this.fabricClient, this.token).ConfigureAwait(true);

            string jsonPayload = JsonConvert.SerializeObject(
                new
            {
                id               = $"FO_{Guid.NewGuid().ToString()}",
                datetime         = DateTime.UtcNow,
                clusterId        = clusterId ?? string.Empty,
                clusterType      = clusterType ?? string.Empty,
                source           = ObserverConstants.FabricObserverName,
                property         = propertyName,
                healthScope      = scope.ToString(),
                healthState      = state.ToString(),
                healthEvaluation = unhealthyEvaluations,
                serviceName      = serviceName ?? string.Empty,
                instanceName     = instanceName ?? string.Empty,
            });

            await this.SendTelemetryAsync(jsonPayload).ConfigureAwait(false);
        }
        // This is the only function impl that really makes sense for ClusterObserver
        // with respect to ITelemetryProvider as CO does not monitor resources and generate data.
        // It just reports AggregatedClusterHealth and related details surfaced by other Fabric services
        // running in the cluster.
        public async Task ReportHealthAsync(
            HealthScope scope,
            string propertyName,
            HealthState state,
            string unhealthyEvaluations,
            string source,
            CancellationToken cancellationToken,
            string serviceName  = null,
            string instanceName = null)
        {
            var(clusterId, _) =
                await ClusterIdentificationUtility.TupleGetClusterIdAndTypeAsync(fabricClient, token).ConfigureAwait(true);

            string jsonPayload = JsonConvert.SerializeObject(
                new
            {
                id               = $"CO_{Guid.NewGuid()}",
                datetime         = DateTime.UtcNow,
                clusterId        = clusterId ?? string.Empty,
                source           = ObserverConstants.ClusterObserverName,
                property         = propertyName,
                healthScope      = scope.ToString(),
                healthState      = state.ToString(),
                healthEvaluation = unhealthyEvaluations,
                serviceName      = serviceName ?? string.Empty,
                instanceName     = instanceName ?? string.Empty,
                osPlatform       = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows" : "Linux",
            });

            await SendTelemetryAsync(jsonPayload, cancellationToken).ConfigureAwait(false);
        }
Exemplo n.º 4
0
        public TelemetryData(
            FabricClient fabricClient,
            CancellationToken cancellationToken)
        {
            var(clusterId, _, _) =
                ClusterIdentificationUtility.TupleGetClusterIdAndTypeAsync(fabricClient, cancellationToken).Result;

            this.ClusterId = clusterId;
        }