/// <summary> /// Initializes a new instance of the <see cref="RollbarTelemetryOptions"/> class. /// </summary> /// <param name="enabled">if set to <c>true</c> [enabled].</param> /// <param name="queueDepth">The queue depth.</param> /// <param name="telemetryTypes">The telemetry types.</param> /// <param name="autoCollectionInterval">The automatic collection interval.</param> public RollbarTelemetryOptions(bool enabled, int queueDepth, TelemetryType telemetryTypes, TimeSpan autoCollectionInterval) { this.TelemetryEnabled = enabled; this.TelemetryQueueDepth = queueDepth; this.TelemetryAutoCollectionTypes = telemetryTypes; this.TelemetryAutoCollectionInterval = autoCollectionInterval; }
/// <summary> /// Initializes a new instance of the <see cref="LogTelemetry"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="message">The message.</param> protected LogTelemetry( TelemetryType type, string message ) : this(type, message, null) { }
public TelemetryService AddConsoleLogger(TelemetryType telemetryType, ITelemetryLogger logger) { logger.Verify(nameof(logger)).IsNotNull(); _pipeline.DoAction(x => logger.Write(x), x => x.TelemetryType.IsReplay() || x.TelemetryType.FilterLevel(telemetryType)); return(this); }
private void TrackTelemetryData(TelemetryType type) { switch (type) { case TelemetryType.Event: Dictionary <string, string> properties = new Dictionary <string, string> (); properties.Add("Xamarin Key", "Custom Property Value"); TelemetryManager.TrackEvent("My custom event", properties); break; case TelemetryType.Metric: TelemetryManager.TrackMetric("My custom metric", 2.2); break; case TelemetryType.Message: TelemetryManager.TrackTrace("My custom message"); break; case TelemetryType.PageView: TelemetryManager.TrackPageView("My custom page view", 100); break; case TelemetryType.Session: ApplicationInsights.RenewSessionWithId(new DateTime().Date.ToString()); break; default: break; } }
/// <summary> /// Provides a telemetry filter based on its type /// </summary> /// <param name="telemetryType">Current telemetry type that should be filtered</param> /// <param name="isTrackingEnabled">Indication whether or not this telemetry type should be tracked</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="telemetryType"/> is outside the bounds of the enumeration.</exception> public static TelemetryTypeFilter On(TelemetryType telemetryType, bool isTrackingEnabled) { Guard.For(() => !Enum.IsDefined(typeof(TelemetryType), telemetryType), new ArgumentOutOfRangeException(nameof(telemetryType), telemetryType, "Requires a type of telemetry that's within the supported value range of the enumeration")); return(new TelemetryTypeFilter(telemetryType, isTrackingEnabled)); }
public AddTelemetryFilter(string action, TelemetryType type, ITelemetry telemetry, IOptions <AppSettings> appSettingsAccessor, ApplicationConfigurationService applicationConfigurationService) { _action = action; _type = type; _telemetry = telemetry; _applicationConfigurationService = applicationConfigurationService; _appSettings = appSettingsAccessor.Value; }
public void CreateFilterWithTracked_WithTelemetryTypeOutsideEnum_Fails(TelemetryType telemetryType) { // Arrange bool isTrackingEnabled = _bogusGenerator.Random.Bool(); // Act / Assert Assert.ThrowsAny <ArgumentException>(() => TelemetryTypeFilter.On(telemetryType, isTrackingEnabled)); }
private TelemetryTypeFilter(TelemetryType telemetryType, bool?isTrackingEnabled) { Guard.For(() => !Enum.IsDefined(typeof(TelemetryType), telemetryType), new ArgumentOutOfRangeException(nameof(telemetryType), telemetryType, "Requires a type of telemetry that's within the supported value range of the enumeration")); TelemetryType = telemetryType; IsTrackingEnabled = isTrackingEnabled; }
public Telemetry GetCurrent(int poolId, TelemetryType telemetryType) { TelemetryFilter filter = new TelemetryFilter { Type = telemetryType }; return(telemetryRepository.GetLastTelemetry(poolId, filter)); }
/// <summary> /// Initializes a new instance of the <see cref="LogTelemetry"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="message">The message.</param> /// <param name="arbitraryKeyValuePairs">The arbitrary key value pairs.</param> protected LogTelemetry( TelemetryType type, string message, IDictionary <string, object> arbitraryKeyValuePairs ) : base(type, arbitraryKeyValuePairs) { this.Message = message; }
/// <summary> /// Initializes a new instance of the <see cref="RollbarTelemetryOptions"/> class. /// </summary> /// <param name="enabled">if set to <c>true</c> [enabled].</param> /// <param name="telemetryTypes">The telemetry types.</param> /// <param name="autoCollectionInterval">The automatic collection interval.</param> public RollbarTelemetryOptions(bool enabled, TelemetryType telemetryTypes, TimeSpan autoCollectionInterval) : this( enabled, RollbarTelemetryOptions.defaultQueueDepth, telemetryTypes, autoCollectionInterval ) { }
//Create telemetry data text for the right panel //Index 0 is at the top of the panel void CreateTelemetryText(TelemetryData t, int index, TelemetryType ttype) { if (t == null) { return; } float offset; if (ttype == TelemetryType.NUMERICAL) { offset = -1.5f; } else if (ttype == TelemetryType.SWITCH) { offset = 4.0f; } else { offset = 7.5f; } GameObject textNameClone = Instantiate(telemetryTextName, textPanel.GetComponent <Transform>(), false); GameObject textNumberClone = Instantiate(telemetryTextNumber, textPanel.GetComponent <Transform>(), false); textNameClone.GetComponent <RectTransform>().localPosition = new Vector3((float)0.75, (float)(3.5 - 0.4 * index) - offset, 0); textNumberClone.GetComponent <RectTransform>().localPosition = new Vector3((float)-0.75, (float)(3.5 - 0.4 * index) - offset, 0); //Set color based on severity switch (t.severity) { case Severity.NOMINAL: textNameClone.GetComponentInChildren <Text>().color = Constants.WHITE; textNumberClone.GetComponentInChildren <Text>().color = Constants.WHITE; break; case Severity.WARNING: textNameClone.GetComponentInChildren <Text>().color = Constants.YELLOW; textNumberClone.GetComponentInChildren <Text>().color = Constants.YELLOW; break; case Severity.CRITICAL: textNameClone.GetComponentInChildren <Text>().color = Constants.RED; textNumberClone.GetComponentInChildren <Text>().color = Constants.RED; break; case Severity.UNKNOWN: textNameClone.GetComponentInChildren <Text>().color = Constants.RED; textNumberClone.GetComponentInChildren <Text>().color = Constants.RED; break; } //Set text textNameClone.GetComponentInChildren <Text>().text = t.GetNameText(); textNumberClone.GetComponentInChildren <Text>().text = t.GetValueText(); }
public FnLogInitPackage(string logServer, string programName, Version programVersion, TelemetryType telemetry, string fileName, string encryptionKey) { LogServer = logServer; ProgramName = programName; ProgramVersion = programVersion; Telemetry = telemetry; FileName = fileName; EncryptionKey = encryptionKey; }
public TelemetryMessage(IWorkContext context, TelemetryType telemetryType, string eventSourceName, string eventName, string?message, double value, IEventDimensions?eventDimensions = null) { context = context ?? throw new ArgumentNullException(nameof(context)); WorkContext = context; TelemetryType = telemetryType; EventSourceName = eventSourceName; EventName = eventName; Message = message; Value = value; EventDimensions = new EventDimensions(eventDimensions?.Select(x => x) ?? Standard.EventDimensions.Empty) + context.Dimensions; }
private void TrackTelemetryData(TelemetryType type) { switch (type) { case TelemetryType.Event: Dictionary <string, string> properties = new Dictionary <string, string> (); properties.Add("Xamarin Key", "Custom Property Value"); TelemetryManager.TrackEvent("My custom event", properties); break; case TelemetryType.Metric: TelemetryManager.TrackMetric("My custom metric", 2.2); break; case TelemetryType.Message: TelemetryManager.TrackTrace("My custom message"); break; case TelemetryType.PageView: TelemetryManager.TrackPageView("My custom page view"); break; case TelemetryType.Session: ApplicationInsights.RenewSessionWithId(new DateTime().Date.ToString()); break; case TelemetryType.HandledException: try { throw(new NullReferenceException()); }catch (Exception e) { // App shouldn't crash because of that } break; case TelemetryType.UnhandledException: int value = 1 / int.Parse("0"); break; case TelemetryType.UnmanagedSignal: #if __IOS__ DummyLibrary.TriggerSignalCrash(); #endif break; case TelemetryType.UnmanagedException: DummyLibrary.TriggerExceptionCrash(); break; default: break; } }
/// <summary> /// Send module load telemetry as a metric. /// For modules we send the module name (if allowed), and the version. /// Some modules (CIM) will continue use the string alternative method. /// </summary> /// <param name="telemetryType">The type of telemetry that we'll be sending.</param> /// <param name="moduleName">The module name to report. If it is not allowed, then it is set to 'anonymous'.</param> /// <param name="moduleVersion">The module version to report. The default value is the anonymous version '0.0.0.0'.</param> internal static void SendModuleTelemetryMetric(TelemetryType telemetryType, string moduleName, string moduleVersion = AnonymousVersion) { try { string allowedModuleName = GetModuleName(moduleName); string allowedModuleVersion = allowedModuleName == Anonymous ? AnonymousVersion : moduleVersion; s_telemetryClient.GetMetric(telemetryType.ToString(), "uuid", "SessionId", "ModuleName", "Version").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, allowedModuleName, allowedModuleVersion); } catch { // Ignore errors. } }
/// <summary> /// Initializes a new instance of the <see cref="TelemetryConfig" /> class. /// </summary> /// <param name="telemetryEnabled">if set to <c>true</c> [telemetry enabled].</param> /// <param name="telemetryQueueDepth">The telemetry queue depth.</param> /// <param name="telemetryAutoCollectionTypes">The telemetry automatic collection types.</param> /// <param name="telemetryCollectionInterval">The telemetry collection interval.</param> public TelemetryConfig( bool telemetryEnabled, int telemetryQueueDepth, TelemetryType telemetryAutoCollectionTypes, TimeSpan telemetryCollectionInterval ) { this.SetDefaults(); this.TelemetryEnabled = telemetryEnabled; this.TelemetryQueueDepth = telemetryQueueDepth; this.TelemetryAutoCollectionTypes = telemetryAutoCollectionTypes; this.TelemetryAutoCollectionInterval = telemetryCollectionInterval; }
public void GetAsEnum_WithoutEnumType_Fails() { // Arrange string propertyKey = _bogusGenerator.Random.Word(); TelemetryType telemetryType = _bogusGenerator.Random.Enum <TelemetryType>(); var properties = new ReadOnlyDictionary <string, LogEventPropertyValue>( new Dictionary <string, LogEventPropertyValue> { [propertyKey] = new ScalarValue(telemetryType) }); // Act / Assert Assert.ThrowsAny <FormatException>(() => properties.GetAsEnum <TimeSpan>(propertyKey)); }
public static TelemetryType[] CreateTelemetry( TelemetryGen[] input, DateTimeOffset startTime, int millisecondIncrements = 200) { return(input.Select( (item, idx) => { var enqueuedTime = startTime.AddMilliseconds((idx + 1) * millisecondIncrements); return TelemetryType.CreateNumeric( DeviceId: $"dev{item.DevId}", Property: $"prop{item.PropId}", EnqueuedTime: enqueuedTime, Time: enqueuedTime.AddMilliseconds(item.NegMs), NumericValue: 42 ); // <- Now we have a complex object with strings and datetimes } ) .ToArray()); }
public void GetAsEnum_WithParsablePropertyValue_Succeeds() { // Arrange string propertyKey = _bogusGenerator.Random.Word(); TelemetryType expected = _bogusGenerator.Random.Enum <TelemetryType>(); var properties = new ReadOnlyDictionary <string, LogEventPropertyValue>( new Dictionary <string, LogEventPropertyValue> { [propertyKey] = new ScalarValue(expected) }); // Act TelemetryType?actual = properties.GetAsEnum <TelemetryType>(propertyKey); // Assert Assert.Equal(expected, actual); }
public void LogEventAsTelemetry_FiltersInCorrectTelemetry_Succeeds(TelemetryType telemetryType, string logEntryKey) { // Arrange DateTimeOffset timestamp = _bogusGenerator.Date.RecentOffset(); var level = _bogusGenerator.Random.Enum <LogEventLevel>(); var logEvent = new LogEvent(timestamp, level, exception: null, MessageTemplate.Empty, new [] { new LogEventProperty(logEntryKey, new ScalarValue("something that represents the telemetry")) }); var filter = TelemetryTypeFilter.On(telemetryType); // Act bool isEnabled = filter.IsEnabled(logEvent); // Assert Assert.True(isEnabled); }
public static async void Incriment(TelemetryType type, int key, long time) { switch (type) { case TelemetryType.downloaded_threads: IncrimentKey(downloadedThreadStats, overallDownloads, overallDownloadedThreads, key, time); break; case TelemetryType.downloaded_pages: IncrimentKey(downloadedPageStats, overallDownloads, overallDownloadedPages, key, time); break; case TelemetryType.processed_threads: IncrimentKey(processedThreadStats, overallProcessed, overallProcessedThreads, key, time); break; case TelemetryType.processed_pages: IncrimentKey(processedPageStats, overallProcessed, overallProcessedPages, key, time); break; } }
/// <summary> /// Send telemetry as a metric. /// </summary> /// <param name="metricId">The type of telemetry that we'll be sending.</param> /// <param name="data">The specific details about the telemetry.</param> internal static void SendTelemetryMetric(TelemetryType metricId, string data) { if (!CanSendTelemetry) { return; } SendPSCoreStartupTelemetry("hosted"); string metricName = metricId.ToString(); try { switch (metricId) { case TelemetryType.ApplicationType: case TelemetryType.PowerShellCreate: case TelemetryType.RemoteSessionOpen: case TelemetryType.ExperimentalEngineFeatureActivation: s_telemetryClient.GetMetric(metricName, "uuid", "SessionId", "Detail").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, data); break; case TelemetryType.ExperimentalModuleFeatureActivation: string experimentalFeatureName = GetExperimentalFeatureName(data); s_telemetryClient.GetMetric(metricName, "uuid", "SessionId", "Detail").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, experimentalFeatureName); break; case TelemetryType.ModuleLoad: case TelemetryType.WinCompatModuleLoad: string moduleName = GetModuleName(data); // This will return anonymous if the modulename is not on the report list s_telemetryClient.GetMetric(metricName, "uuid", "SessionId", "Detail").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, moduleName); break; } } catch { // do nothing, telemetry can't be sent // don't send the panic telemetry as if we have failed above, it will likely fail here. } }
public TelemetryService AddErrorReplay(IWorkContext context, TelemetryType console, ITelemetryQuery logger, ITelemetryService telemetryService) { context.Verify(nameof(context)).IsNotNull(); logger.Verify(nameof(logger)).IsNotNull(); telemetryService.Verify(nameof(telemetryService)).IsNotNull(); void action(TelemetryMessage x) { IReadOnlyList <TelemetryMessage> loggedMessages = logger.Query(y => x.WorkContext.Cv == y.WorkContext.Cv, 30, 100); loggedMessages.ForEach(y => telemetryService.Write(y.WithReplay())); } bool filter(TelemetryMessage x) => (console != TelemetryType.Verbose) && (!x.TelemetryType.IsReplay()) && (x.TelemetryType.IsEvent()) && (x.TelemetryType.IsErrorOrCritical()) && (x?.WorkContext?.Cv != null); _pipeline.DoAction(action, filter); return(this); }
/// <summary> /// Send telemetry as a metric. /// </summary> /// <param name="metricId">The type of telemetry that we'll be sending.</param> /// <param name="data">The specific details about the telemetry.</param> internal static void SendTelemetryMetric(TelemetryType metricId, string data) { if (!CanSendTelemetry) { return; } // These should be handled by SendModuleTelemetryMetric. Debug.Assert(metricId != TelemetryType.ModuleLoad, "ModuleLoad should be handled by SendModuleTelemetryMetric."); Debug.Assert(metricId != TelemetryType.WinCompatModuleLoad, "WinCompatModuleLoad should be handled by SendModuleTelemetryMetric."); string metricName = metricId.ToString(); try { switch (metricId) { case TelemetryType.ApplicationType: case TelemetryType.PowerShellCreate: case TelemetryType.RemoteSessionOpen: case TelemetryType.ExperimentalEngineFeatureActivation: s_telemetryClient.GetMetric(metricName, "uuid", "SessionId", "Detail").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, data); break; case TelemetryType.ExperimentalModuleFeatureActivation: string experimentalFeatureName = GetExperimentalFeatureName(data); s_telemetryClient.GetMetric(metricName, "uuid", "SessionId", "Detail").TrackValue(metricValue: 1.0, s_uniqueUserIdentifier, s_sessionId, experimentalFeatureName); break; } } catch { // do nothing, telemetry can't be sent // don't send the panic telemetry as if we have failed above, it will likely fail here. } }
/// <summary> /// Initializes a new instance of the <see cref="TelemetryBody"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="arbitraryKeyValuePairs">The arbitrary key value pairs.</param> protected TelemetryBody(TelemetryType type, IDictionary <string, object?>?arbitraryKeyValuePairs) : base(arbitraryKeyValuePairs) { this.Type = type; }
private void TrackTelemetryData(TelemetryType type){ switch (type) { case TelemetryType.Event: Dictionary<string, string> properties = new Dictionary<string, string> (); properties.Add ("Xamarin Key", "Custom Property Value"); TelemetryManager.TrackEvent ("My custom event", properties); break; case TelemetryType.Metric: TelemetryManager.TrackMetric ("My custom metric", 2.2); break; case TelemetryType.Message: TelemetryManager.TrackTrace ("My custom message"); break; case TelemetryType.PageView: TelemetryManager.TrackPageView ("My custom page view"); break; case TelemetryType.Session: ApplicationInsights.RenewSessionWithId (new DateTime().Date.ToString()); break; case TelemetryType.HandledException: try { throw(new NullReferenceException()); }catch (Exception e){ // App shouldn't crash because of that } break; case TelemetryType.UnhandledException: int value = 1 / int.Parse("0"); break; case TelemetryType.UnmanagedSignal: #if __IOS__ DummyLibrary.TriggerSignalCrash (); #endif break; case TelemetryType.UnmanagedException: DummyLibrary.TriggerExceptionCrash (); break; default: break; } }
public static bool IsReplay(this TelemetryType telemetryType) => (telemetryType & TelemetryType.Replay) == TelemetryType.Replay;
public static bool IsEvent(this TelemetryType telemetryType) => (telemetryType & TelemetryType.Event) == TelemetryType.Event;
public static bool IsErrorOrCritical(this TelemetryType telemetryType) => FilterLevel(telemetryType, TelemetryType.Error);
public static bool IsMetric(this TelemetryType telemetryType) => (telemetryType & TelemetryType.LevelMask) == TelemetryType.Metric;