public TelemetryHelper(MediaServicesAccountConfig account, string channelId, string originId) { if (account.TelemetryStorage != null) { var telemetryStorage = new TelemetryStorage(account.TelemetryStorage); if (channelId != null) { _channelId = channelId; _channelMetrics = telemetryStorage.GetRecentChannelMetrics( new Guid(account.Id), new Guid(channelId), 20); } if (originId != null) { _originId = originId; _originMetrics = telemetryStorage.GetRecentStreamingEndpointMetrics( new Guid(account.Id), new Guid(originId.NimbusIdToRawGuid()), 20); } } }
public AventusHelper(MediaServicesAccountConfig config) { AccountConfig = config; if (config.TelemetryStorage != null) { TelemetryStorage = new TelemetryStorage(config.TelemetryStorage); } if (config.MetaData.Thumbprint != null) { AventusDNSTail = config.MetaData.aventusDNSBase; Certificate = ChannelCreationOperations.GetCertificate(config.MetaData.Thumbprint); TelemetryClient = ChannelCreationOperations.GetWebClient(null, Certificate); } }
/// <summary> /// Get metrics for a Media Services Channel in in asynchronous mode. /// </summary> /// <param name="endpointAddress">The Telemetry endpoint address</param> /// <param name="storageAccountKey">The Storage account key.</param> /// <param name="mediaServicesAccountId">The Media Services account Id.</param> /// <param name="channelId">The Channel ID</param> /// <param name="start">The start time.</param> /// <param name="end">The end time.</param> /// <returns>The Task of the Channel metrics for the given channel within the given time range.</returns> public Task<ICollection<IChannelHeartbeat>> GetChannelMetricsAsync( string endpointAddress, string storageAccountKey, string mediaServicesAccountId, string channelId, DateTime start, DateTime end) { if (endpointAddress == null) { throw new ArgumentNullException("endpointAddress"); } if (storageAccountKey == null) { throw new ArgumentNullException("storageAccountKey"); } if (mediaServicesAccountId == null) { throw new ArgumentNullException("mediaServicesAccountId"); } Guid accountId; if (!Guid.TryParse(mediaServicesAccountId, out accountId)) { throw new ArgumentException(StringTable.InvalidMediaServicesAccountIdInput); } var channelGuid = TelemetryUtilities.ParseChannelId(channelId); if (start.Kind != DateTimeKind.Utc) { throw new ArgumentException(StringTable.NonUtcDateTime, "start"); } if (end.Kind != DateTimeKind.Utc) { throw new ArgumentException(StringTable.NonUtcDateTime, "end"); } if (start >= end) { throw new ArgumentException(StringTable.InvalidTimeRange, "start"); } var storageAccount = TelemetryUtilities.GetStorageAccountName(endpointAddress); if (MediaContext.StorageAccounts.Where(c => c.Name == storageAccount).FirstOrDefault() == null) { throw new ArgumentException(StringTable.InvalidStorageAccount); } return Task.Factory.StartNew(() => { var telemetryStorage = new TelemetryStorage(new StorageCredentials(storageAccount, storageAccountKey), new Uri(endpointAddress)); return telemetryStorage.GetChannelMetrics( accountId, channelGuid, start, end); }); }