/// <summary> /// Initializes a new instance of the <see cref="DiagnosticsTelemetryModule"/> class. /// </summary> public DiagnosticsTelemetryModule() { // Adding a dummy queue sender to keep the data to be sent to the portal before the initialize method is called this.Senders.Add(new PortalDiagnosticsQueueSender()); this.EventListener = new DiagnosticsListener(this.Senders); this.HeartbeatProvider = new HeartbeatProvider(); }
internal void CollectFrom(IHeartbeatProvider provider, CancellationToken token) { if (provider == null) throw new ArgumentNullException(nameof(provider)); string name = provider.GetType().Name; name = name.Strip("HeartbeatProvider").NullIfEmpty() ?? name; string[] messages = provider.CollectHeartbeatMessages(token)?.ToArray(); _groups.Add(new Group(name, messages ?? new string[0])); }
public Task <bool> SetDefaultPayload(IEnumerable <string> disabledFields, IHeartbeatProvider provider) { bool hasSetValues = false; var enabledProperties = this.DefaultFields.Except(disabledFields); foreach (string fieldName in enabledProperties) { // we don't need to report out any failure here, so keep this look within the Sdk Internal Operations as well try { switch (fieldName) { case "runtimeFramework": provider.AddHeartbeatProperty(fieldName, true, GetRuntimeFrameworkVer(), true); hasSetValues = true; break; case "baseSdkTargetFramework": provider.AddHeartbeatProperty(fieldName, true, GetBaseSdkTargetFramework(), true); hasSetValues = true; break; case "osType": provider.AddHeartbeatProperty(fieldName, true, GetRuntimeOsType(), true); hasSetValues = true; break; case "processSessionId": provider.AddHeartbeatProperty(fieldName, true, GetProcessSessionId(), true); hasSetValues = true; break; default: provider.AddHeartbeatProperty(fieldName, true, "UNDEFINED", true); break; } } catch (Exception ex) { CoreEventSource.Log.FailedToObtainDefaultHeartbeatProperty(fieldName, ex.ToString()); } } return(Task.FromResult(hasSetValues)); }
public static async Task <bool> PopulateDefaultPayload(IEnumerable <string> disabledFields, IEnumerable <string> disabledProviders, IHeartbeatProvider provider) { bool populatedFields = false; foreach (var payloadProvider in DefaultPayloadProviders) { if (disabledProviders != null && disabledProviders.Contains(payloadProvider.Name, StringComparer.OrdinalIgnoreCase)) { // skip any azure specific modules here continue; } bool fieldsAreSet = await payloadProvider.SetDefaultPayload(disabledFields, provider).ConfigureAwait(false); populatedFields = populatedFields || fieldsAreSet; } return(populatedFields); }
public static void PopulateDefaultPayload(IEnumerable <string> disabledFields, IHeartbeatProvider provider) { var enabledProperties = RemoveDisabledDefaultFields(disabledFields); var payload = new Dictionary <string, HeartbeatPropertyPayload>(); foreach (string fieldName in enabledProperties) { try { switch (fieldName) { case "runtimeFramework": provider.AddHeartbeatProperty(fieldName, GetRuntimeFrameworkVer(), true); break; case "baseSdkTargetFramework": provider.AddHeartbeatProperty(fieldName, GetBaseSdkTargetFramework(), true); break; default: provider.AddHeartbeatProperty(fieldName, "UNDEFINED", false); break; } } catch (Exception ex) { CoreEventSource.Log.FailedToObtainDefaultHeartbeatProperty(fieldName, ex.ToString()); } } }