public TelemetryService(ITelemetryClient telemetryClient) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); }
/// <summary> /// Creates a new instance of <see cref="CommandLinePredictor"/>. /// </summary> /// <param name="modelPredictions">List of suggestions from the model, sorted by frequency (most to least).</param> /// <param name="parameterValuePredictor">Provide the prediction to the parameter values.</param> /// <param name="telemetryClient">The telemetry client.</param> /// <param name="azContext">The current PowerShell conext.</param> public CommandLinePredictor(IList <PredictiveCommand> modelPredictions, ParameterValuePredictor parameterValuePredictor, ITelemetryClient telemetryClient, IAzContext azContext = null) { Validation.CheckArgument(modelPredictions, $"{nameof(modelPredictions)} cannot be null."); _telemetryClient = telemetryClient; _parameterValuePredictor = parameterValuePredictor; var commnadLines = new List <CommandLine>(); if (modelPredictions != null) { for (var i = 0; i < modelPredictions.Count; ++i) { try { this._commandLinePredictions.Add(new CommandLine(modelPredictions[i], azContext)); } catch (Exception e) { _telemetryClient?.OnParseCommandLineFailure(new CommandLineParsingTelemetryData(modelPredictions[i].Command, e)); } } } }
public TelemetryEventService(ITelemetryClient telemetryClient) { _timers = new Dictionary <string, Stopwatch>(); _telemetryClient = telemetryClient; }
public PullRequestEventHasher(ITelemetryClient telemetryClient) : base(telemetryClient) { }
public OrganizationPayloadHasher(ITelemetryClient telemetryClient) : base(telemetryClient) { }
public TelemetryService(ITelemetryClient telemetry, ISystemInfoService infoService) { _telemetry = telemetry; _infoService = infoService; }
protected AbstractMatsExecutor(ITelemetryClient mats) { _mats = mats; }
public static bool Upload(TelemetryConfiguration teleConfig, string profile, ITelemetryClient teleClient) { try { var fileEntries = Directory.GetFiles(teleConfig.LogsPath) .Where(f => Path.GetFileName(f) .StartsWith("portingAssistant-client-cli") && teleConfig.Suffix.ToArray().Any(x => f.EndsWith(x)) ).ToList(); var lastReadTokenFile = Path.Combine(teleConfig.LogsPath, "lastToken.json"); var fileLineNumberMap = new Dictionary <string, int>(); if (File.Exists(lastReadTokenFile)) { fileLineNumberMap = JsonConvert.DeserializeObject <Dictionary <string, int> >(File.ReadAllText(lastReadTokenFile)); } foreach (var file in fileEntries) { var logName = Path.GetFileNameWithoutExtension(file); var fileExtension = Path.GetExtension(file); if (fileExtension == ".log") { logName = $"{logName}-logs"; } else if (fileExtension == ".metrics") { logName = $"{logName}-metrics"; } // Add new files to fileLineNumberMap if (!fileLineNumberMap.ContainsKey(file)) { fileLineNumberMap[file] = 0; } var initLineNumber = fileLineNumberMap[file]; FileInfo fileInfo = new FileInfo(file); var success = false; using (FileStream fs = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader reader = new StreamReader(fs)) { // If put-log api works keep sending logs else wait and do it next time var logs = new ArrayList(); int currLineNumber = 0; for (; currLineNumber < initLineNumber; currLineNumber++) { string line = reader.ReadLine(); if (line == null) { return(true); } } while (!reader.EndOfStream) { currLineNumber++; logs.Add(reader.ReadLine()); // send 1000 lines of logs each time when there are large files if (logs.Count >= 1000) { // logs.TrimToSize(); success = PutLogData(logName, JsonConvert.SerializeObject(logs), profile, teleConfig, teleClient).Result; if (success) { logs = new ArrayList(); } else { return(false); } } } if (logs.Count != 0) { success = PutLogData(logName, JsonConvert.SerializeObject(logs), profile, teleConfig, teleClient).Result; if (!success) { return(false); } } if (success) { fileLineNumberMap[file] = currLineNumber; string jsonString = JsonConvert.SerializeObject(fileLineNumberMap); File.WriteAllText(lastReadTokenFile, jsonString); } } } } return(true); } catch (Exception ex) { Log.Logger.Error(ex.Message); return(false); } }
public ForkPayloadHasher(ITelemetryClient telemetryClient) : base(telemetryClient) { }
public TelemetryDiagnosticControls(ITelemetryClient telemetryClient) { _telemetryClient = telemetryClient; }
public TelemetryClientApplicationBaseExecutor(IClientApplicationBaseExecutor executor, ITelemetryClient mats) : base(mats) { _executor = executor; }
public EnrichmentMessageRouter(IDataSource dataSource, IDataSink dataSink, IIoTDeviceDataEnricher dataEnricher, ITelemetryClient telemetryClient, IConfiguration config, ILogger <EnrichmentMessageRouter> logger) { this.dataSource = dataSource; this.dataSink = dataSink; this.dataEnricher = dataEnricher; this.telemetryClient = telemetryClient; this.logger = logger; this.config = config; // handle messages as they arrive this.MessageBatchReceived += (sender, e) => { // process with parallelism Parallel.ForEach(e.Messages, async(message) => { // get the device id var deviceId = message.GetDeviceId(); // get the metadata var startTime = DateTime.UtcNow; var timer = System.Diagnostics.Stopwatch.StartNew(); try { var metadata = await this.dataEnricher.GetMetadataAsync(deviceId); if (metadata != null) { // enrich the message message.EnrichMessage(metadata); // output the message await this.dataSink.WriteMessageAsync(message); // send the telemetry timer.Stop(); telemetryClient.TrackDependency("gRPC call", "IoTClient", "GetMetadataAzync", startTime, timer.Elapsed, true); } } catch { // send the telemetry timer.Stop(); logger.LogDebug($"gRPC call took {timer.Elapsed.Milliseconds} ms"); telemetryClient.TrackDependency("gRPC call", "IoTClient", "GetMetadataAzync", startTime, timer.Elapsed, false); } finally { Interlocked.Decrement(ref waiting); } }); }; }
public IssueCommentPayloadHasher(ITelemetryClient telemetryClient) : base(telemetryClient) { }
/// <summary> /// Adds the client. /// </summary> /// <param name="client">The client.</param> /// <returns></returns> public static ITelemetryClient AddClient(ITelemetryClient client) { LogConsumer.Trace("Adding telemetry client of type {0}", client.GetType().FullName); Clients.Add(client); return(client); }
public TelemetryDiagnosticControls() { _telemetryClient = new TelemetryClient(); }
public LoggerDiagnosticsSource(ITelemetryClient telemetryClient, ILogger logger) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public IHttpWebRequest CreateWebRequest(Uri address, string dependencyName, ITelemetryFactory telemetryFactory, ITelemetryClient telemetryClient) { return(new InstrumentedHttpWebRequestWrapper(address, telemetryFactory, telemetryClient, dependencyName)); }
public TelemetryService(ITelemetryClient telemetryClient, IDictionary <string, string> globalDimensions) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); GlobalDimensions = globalDimensions ?? throw new ArgumentNullException(nameof(globalDimensions)); }
/// <summary> /// Requests preditions and collects telemetry event. /// </summary> /// <param name="azPredictorService">The service to send the request.</param> /// <param name="telemetryClient">The telemetry client to collect the data.</param> /// <param name="predictionClient">The client that initiate the telemetry event.</param> /// <param name="commands">A list of commands.</param> /// <param name="telemetryWaitTask">The task to wait before we collect the telemetry data.</param> /// <param name="cancellationToken">The cancellation token.</param> public static async Task RequestPredictionAndCollectTelemetryAync(IAzPredictorService azPredictorService, ITelemetryClient telemetryClient, PredictionClient predictionClient, IEnumerable <string> commands, TaskCompletionSource telemetryWaitTask, CancellationToken cancellationToken) { var requestId = Guid.NewGuid().ToString(); bool? hasSentHttpRequest = default; Exception exception = null; try { hasSentHttpRequest = await azPredictorService.RequestPredictionsAsync(commands, requestId, cancellationToken); } catch (ServiceRequestException e) { hasSentHttpRequest = e.IsRequestSent; exception = e.InnerException; } catch (Exception e) when(!(e is OperationCanceledException)) { exception = e; } finally { if (telemetryWaitTask != null) { await telemetryWaitTask.Task; } if (hasSentHttpRequest.HasValue) { telemetryClient.RequestId = requestId; telemetryClient.OnRequestPrediction(new RequestPredictionTelemetryData(predictionClient, commands, hasSentHttpRequest.Value, exception)); } } }
public AisABTestAdapter(Dictionary <string, string> applicationSettings, ITelemetryClient telemetryClient) { this.adapterSettings = applicationSettings; this.telemetryClient = telemetryClient; }
public TrackExceptionsFilterAttribute(ITelemetryClient telemetryClient) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); }
public IssueCommentEventHasher(ITelemetryClient telemetryClient) : base(telemetryClient) { }
public TelemetryService(ITelemetryClient telemetryClient) { _telemetryClient = telemetryClient; }
public TelemetryPublicClientExecutor(IPublicClientApplicationExecutor executor, ITelemetryClient mats) : base(mats) { _executor = executor; }
public TelemetryService(ITelemetryClient telemetryClient, IOptionsSnapshot <MonitorConfiguration> configuration) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _subscription = _configuration.Value.Subscription; }
public LoggerDiagnosticsService(ILoggerFactory loggerFactory, ITelemetryClient telemetryClient) { _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); }
private static void ConfigureForAzureStorage(ContainerBuilder builder, IGalleryConfigurationService configuration, ITelemetryClient telemetryClient) { /// The goal here is to initialize a <see cref="ICloudBlobClient"/> and <see cref="IFileStorageService"/> /// instance for each unique connection string. Each dependent of <see cref="IFileStorageService"/> (that /// is, each service that has a <see cref="IFileStorageService"/> constructor parameter) is registered in /// <see cref="StorageDependent.GetAll(IAppConfiguration)"/> and is grouped by the respective storage /// connection string. Each group is given a binding key which refers to the appropriate instance of the /// <see cref="IFileStorageService"/>. var completedBindingKeys = new HashSet <string>(); foreach (var dependent in StorageDependent.GetAll(configuration.Current)) { if (completedBindingKeys.Add(dependent.BindingKey)) { builder.RegisterInstance(new CloudBlobClientWrapper(dependent.AzureStorageConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant)) .AsSelf() .As <ICloudBlobClient>() .SingleInstance() .Keyed <ICloudBlobClient>(dependent.BindingKey); builder.RegisterType <CloudBlobFileStorageService>() .WithParameter(new ResolvedParameter( (pi, ctx) => pi.ParameterType == typeof(ICloudBlobClient), (pi, ctx) => ctx.ResolveKeyed <ICloudBlobClient>(dependent.BindingKey))) .AsSelf() .As <IFileStorageService>() .As <ICoreFileStorageService>() .As <ICloudStorageStatusDependency>() .SingleInstance() .Keyed <IFileStorageService>(dependent.BindingKey); } var registration = builder.RegisterType(dependent.ImplementationType) .WithParameter(new ResolvedParameter( (pi, ctx) => pi.ParameterType.IsAssignableFrom(typeof(IFileStorageService)), (pi, ctx) => ctx.ResolveKeyed <IFileStorageService>(dependent.BindingKey))) .AsSelf() .As(dependent.InterfaceType); if (dependent.IsSingleInstance) { registration.SingleInstance(); } else { registration.InstancePerLifetimeScope(); } } // when running on Windows Azure, we use a back-end job to calculate stats totals and store in the blobs builder.RegisterInstance(new JsonAggregateStatsService(configuration.Current.AzureStorage_Statistics_ConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant)) .AsSelf() .As <IAggregateStatsService>() .SingleInstance(); // when running on Windows Azure, pull the statistics from the warehouse via storage builder.RegisterInstance(new CloudReportService(configuration.Current.AzureStorage_Statistics_ConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant)) .AsSelf() .As <IReportService>() .As <ICloudStorageStatusDependency>() .SingleInstance(); // when running on Windows Azure, download counts come from the downloads.v1.json blob var downloadCountService = new CloudDownloadCountService( telemetryClient, configuration.Current.AzureStorage_Statistics_ConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant); builder.RegisterInstance(downloadCountService) .AsSelf() .As <IDownloadCountService>() .SingleInstance(); ObjectMaterializedInterception.AddInterceptor(new DownloadCountObjectMaterializedInterceptor(downloadCountService)); builder.RegisterType <JsonStatisticsService>() .AsSelf() .As <IStatisticsService>() .SingleInstance(); builder.RegisterInstance(new TableErrorLog(configuration.Current.AzureStorage_Errors_ConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant)) .As <ErrorLog>() .SingleInstance(); builder.RegisterType <FlatContainerContentFileMetadataService>() .As <IContentFileMetadataService>() .SingleInstance(); }
public TelemetryService(ILogger logger, ITelemetryClient telemetry, ISystemInfoService infoService) { _logger = logger; _telemetry = telemetry; _infoService = infoService; }
public GitHubRateLimiter(string organizationId, ICache <RateLimitTableEntity> rateLimiterCache, IHttpClient httpClient, ITelemetryClient telemetryClient, double maxUsageBeforeDelayStarts, string apiDomain) : base(RateLimitTableEntity.GlobalOrganizationId, organizationName: organizationId.Equals(RateLimitTableEntity.GlobalOrganizationId) ? string.Empty : organizationId, rateLimiterCache, telemetryClient, expectRateLimitingHeaders: true) { this.httpClient = httpClient; this.maxUsageBeforeDelayStarts = maxUsageBeforeDelayStarts; this.usageCheckUrl = $"https://{apiDomain}/rate_limit"; }
public GitHubCollector(GitHubHttpClient httpClient, IAuthentication authentication, ITelemetryClient telemetryClient, List <IRecordWriter> recordWriters) : base(authentication, telemetryClient, recordWriters) { this.httpClient = httpClient; }
public TelemetryServiceWrapper(IDiagnosticsService diagnosticsService, ITelemetryClient telemetryClient) : base(diagnosticsService, telemetryClient) { }
public TelemetryDiagnosticControls(ITelemetryClient telemetryClient) { this._telemetryClient=telemetryClient; }