public async Task SetupTelemetryStreamPump() { var metricsStreamProvider = GrainClient.GetStreamProvider(MetricsStreamProvider); var clusterStream = metricsStreamProvider.GetStream <MetricsSnapshot>(Guid.Empty, "ClusterMetricSnapshots"); var siloStream = metricsStreamProvider.GetStream <MetricsSnapshot>(Guid.Empty, "SiloMetricSnapshots"); var metricsGrain = GrainClient.GrainFactory.GetGrain <IClusterMetricsGrain>(Guid.Empty); //config.StreamingProviderName = "SystemMetricsStream"; await metricsGrain.Configure(new MetricsConfiguration { Enabled = true, // default SamplingInterval = TimeSpan.FromSeconds(1), // default ConfigurationInterval = TimeSpan.FromSeconds(10), // default StaleSiloMetricsDuration = TimeSpan.FromSeconds(30), // default TrackExceptionCounters = true, TrackMethodGrainCalls = true, StreamingProviderName = MetricsStreamProvider, HistoryLength = 30 // default }); _rootDataObject = new VizceralRootObject { renderer = "global", name = "edge", serverUpdateTime = DateTime.UtcNow.Ticks, maxVolume = 100000, nodes = new List <Node> { new Node { renderer = "region", name = "INTERNET", updated = DateTime.UtcNow.Ticks, @class = "normal", nodes = new List <Node>(), }, }, connections = new List <Connection>() }; _metricsHub = GlobalHost.ConnectionManager.GetHubContext <VizceralHub>(); await clusterStream.SubscribeAsync((data, token) => { PushClusterMetricsToConsumers(); return(TaskDone.Done); }); await siloStream.SubscribeAsync((data, token) => { data.Source = System.Uri.EscapeDataString(data.Source); AddReplaceSiloStatsToMetrics(data, _snapshotHistoryCache.ContainsKey(data.Source) ? _snapshotHistoryCache[data.Source] : null); PushSiloMetricsToConsumers(); return(TaskDone.Done); }); }
public void SendLatestSystemTelemetry(VizceralRootObject root) { Clients.All.updateTelemetry(root); }