/// <summary> /// Instantiate builder itself with all necessary parameters. It is done from the /// TelemetrySessionInitializer object, thus TelemetrySession doesn't care what external /// dependencies are needed for creating EventProcessorChannel and EventProcessor objects. /// </summary> /// <param name="persistentPropertyBag"></param> /// <param name="telemetryScheduler"></param> public EventProcessorChannelBuilder(IPersistentPropertyBag persistentPropertyBag, ITelemetryScheduler telemetryScheduler) { CodeContract.RequiresArgumentNotNull <IPersistentPropertyBag>(persistentPropertyBag, "persistentPropertyBag"); CodeContract.RequiresArgumentNotNull <ITelemetryScheduler>(telemetryScheduler, "telemetryScheduler"); this.persistentPropertyBag = persistentPropertyBag; this.telemetryScheduler = telemetryScheduler; }
/// <summary> /// Constructs a builder using explicitly supplied member variables. /// </summary> /// <param name="theRemoteControlClient"></param> /// <param name="theSettings"></param> /// <param name="theManifestParser"></param> /// <param name="theScheduler"></param> public TelemetryManifestManagerBuilder(object theRemoteControlClient, ITelemetryManifestManagerSettings theSettings, ITelemetryManifestParser theManifestParser, ITelemetryScheduler theScheduler) { remoteControlClient = theRemoteControlClient; settings = theSettings; manifestParser = theManifestParser; scheduler = theScheduler; }
internal EventProcessorChannel(IEventProcessor theEventProcessor, ITelemetryScheduler theScheduler, TelemetrySession telemetrySession) { CodeContract.RequiresArgumentNotNull <IEventProcessor>(theEventProcessor, "theEventProcessor"); CodeContract.RequiresArgumentNotNull <ITelemetryScheduler>(theScheduler, "theScheduler"); CodeContract.RequiresArgumentNotNull <TelemetrySession>(telemetrySession, "telemetrySession"); eventProcessor = theEventProcessor; scheduler = theScheduler; scheduler.InitializeTimed(TimeSpan.FromSeconds(1.0)); this.telemetrySession = telemetrySession; }
public void Initialize(TelemetryContext telemetryContext, ITelemetryScheduler contextScheduler, TelemetryManifestMachineIdentityConfig machineIdentityConfig) { CodeContract.RequiresArgumentNotNull <TelemetryContext>(telemetryContext, "telemetryContext"); MachineIdentityConfig = (machineIdentityConfig ?? TelemetryManifestMachineIdentityConfig.DefaultConfig); networkInterfacesInformationProvider = new NetworkInterfacesInformationProvider(MachineIdentityConfig.SmaRules); (contextScheduler ?? new TelemetryScheduler()).Schedule(delegate { GetHardwareIdWithCalculationCompletedEvent(delegate { telemetryContext.SharedProperties[IdentityPropertyProvider.HardwareIdPropertyName] = HardwareId; }); }); }
/// <summary> /// Set up telemetry session properties /// </summary> /// <param name="settings"></param> /// <param name="initializerObject"></param> /// <param name="isCloned"></param> private TelemetrySession(TelemetrySessionSettings settings, bool isCloned, TelemetrySessionInitializer initializerObject) { CodeContract.RequiresArgumentNotNull <TelemetrySessionInitializer>(initializerObject, "initializerObject"); initializerObject.Validate(); initializerObject.AppInsightsInstrumentationKey = settings.AppInsightsInstrumentationKey; initializerObject.AsimovInstrumentationKey = settings.AsimovInstrumentationKey; TelemetryService.EnsureEtwProviderInitialized(); sessionInitializer = initializerObject; sessionSettings = settings; isSessionCloned = isCloned; cancellationTokenSource = initializerObject.CancellationTokenSource; diagnosticTelemetry = initializerObject.DiagnosticTelemetry; identityTelemetry = initializerObject.IdentityTelemetry; optinStatusReader = initializerObject.OptinStatusReader; channelValidators = initializerObject.ChannelValidators; telemetryBufferChannel = new TelemetryBufferChannel(); initializerObject.WatsonSessionChannelBuilder.Build(this); WatsonSessionChannel sessionChannel = initializerObject.WatsonSessionChannelBuilder.WatsonSessionChannel; if (IsValidChannel(sessionChannel)) { watsonSessionChannel = sessionChannel; } machineInformationProvider = initializerObject.MachineInformationProvider; macInformationProvider = initializerObject.MACInformationProvider; userInformationProvider = initializerObject.UserInformationProvider; defaultContextPropertyManager = initializerObject.DefaultContextPropertyManager; persistentPropertyBag = initializerObject.PersistentPropertyBag; initializerObject.EventProcessorChannelBuilder.Build(this); persistentSharedProperties = initializerObject.PersistentSharedProperties; EventProcessor = initializerObject.EventProcessorChannelBuilder.EventProcessor; if (initializerObject.CustomActionToAdd != null) { foreach (IEventProcessorAction item in initializerObject.CustomActionToAdd) { EventProcessor.AddCustomAction(item); } } eventProcessorChannel = initializerObject.EventProcessorChannelBuilder.EventProcessorChannel; telemetryManifestManager = new Lazy <ITelemetryManifestManager>(() => initializerObject.TelemetryManifestManagerBuilder.Build(this)); contextScheduler = initializerObject.ContextScheduler; if (initializerObject.ChannelsToAdd != null) { AddSessionChannels(initializerObject.ChannelsToAdd); } defaultContext = CreateDefaultContext(); macInformationProvider.MACAddressHashCalculationCompleted += MACAddressHashCalculationCompleted; identityTelemetry.IdentityInformationProvider.HardwareIdCalculationCompleted += HardwareIdCalculationCompleted; }
public TelemetryManifestManager(IRemoteControlClient theRemoteControlClient, ITelemetryManifestManagerSettings theSettings, ITelemetryManifestParser theManifestParser, ITelemetryScheduler theScheduler, TelemetrySession theMainSession) { CodeContract.RequiresArgumentNotNull <ITelemetryManifestParser>(theManifestParser, "theManifestParser"); CodeContract.RequiresArgumentNotNull <ITelemetryScheduler>(theScheduler, "theScheduler"); CodeContract.RequiresArgumentNotNull <TelemetrySession>(theMainSession, "theMainSession"); manifestParser = theManifestParser; scheduler = theScheduler; scheduler.InitializeTimed(ReadInterval); mainSession = theMainSession; remoteControlClient = theRemoteControlClient; settings = theSettings; RemoteControlClient.TelemetryLogger2 = ((Action <string, IDictionary <string, object>, IDictionary <string, object> >) delegate(string eventName, IDictionary <string, object> properties, IDictionary <string, object> piiProperties) { TelemetryEvent telemetryEvent = new TelemetryEvent(eventName); DictionaryExtensions.AddRange <string, object>(telemetryEvent.Properties, properties, true); DictionaryExtensions.AddRange <string, object>(telemetryEvent.Properties, (IDictionary <string, object>)((IEnumerable <KeyValuePair <string, object> >)piiProperties).ToDictionary((Func <KeyValuePair <string, object>, string>)((KeyValuePair <string, object> p) => p.Key), (Func <KeyValuePair <string, object>, object>)((KeyValuePair <string, object> p) => new TelemetryPiiProperty(p.Value))), true); mainSession.PostEvent(telemetryEvent); }); }
/// <summary> /// Create TelemetrySessionContext with the name /// </summary> /// <param name="contextName"></param> /// <param name="theHostedSession">Session which owns this context</param> /// <param name="theScheduler"></param> /// <param name="theOverrideInit"></param> /// <param name="initializationAction"></param> internal TelemetryContext(string contextName, TelemetrySession theHostedSession, ITelemetryScheduler theScheduler = null, bool theOverrideInit = false, Action <TelemetryContext> initializationAction = null) { if (!IsContextNameValid(contextName)) { throw new ArgumentException("contextName is invalid, contextName must contain alphanumeric characters only"); } CodeContract.RequiresArgumentNotNull <TelemetrySession>(theHostedSession, "theHostedSession"); if (theScheduler == null) { theScheduler = new TelemetryScheduler(); theScheduler.InitializeTimed(TimeSpan.FromSeconds(15.0)); } ContextName = contextName; hostSession = theHostedSession; scheduler = theScheduler; overrideInit = theOverrideInit; hostSession.AddContext(this); initializationAction?.Invoke(this); if (!overrideInit) { hostSession.PostValidatedEvent(BuildStartEvent()); } }
public void SchedulePostPersistedSharedPropertyAndSendAnyFaults(TelemetrySession telemetrySession, ITelemetryScheduler scheduler) { CodeContract.RequiresArgumentNotNull <TelemetrySession>(telemetrySession, "telemetrySession"); if (IsMachineStoreAccessible) { scheduler.Schedule(delegate { PostAnyFaultsGettingHardwareId(telemetrySession, telemetrySession.CancellationToken); }, telemetrySession.CancellationToken); scheduler.Schedule(delegate { PostPersistedSharedProperties(telemetrySession, telemetrySession.CancellationToken); }, telemetrySession.CancellationToken); } }
public IdentityTelemetry(IIdentityInformationProvider identityInformationProvider, ITelemetryScheduler scheduler) { CodeContract.RequiresArgumentNotNull <IIdentityInformationProvider>(identityInformationProvider, "identityInformationProvider"); Scheduler = (scheduler ?? new TelemetryScheduler()); IdentityInformationProvider = identityInformationProvider; }