public RecordingMethodManager(IExecutionCache executionCache, IThreadIdProvider threadProvider, IExecutionStack executionStack, ISerializationHelper serializationHelper) { _executionCache = executionCache; _threadProvider = threadProvider; _executionStack = executionStack; _serializationHelper = serializationHelper; }
public PerformanceTelemetryPayloadFactory( IErrorContextFactory errorContextFactory, ITelemetryLogger logger, IThreadIdProvider threadIdProvider, IPerformanceContainer container) { if (errorContextFactory == null) { throw new ArgumentNullException("errorContextFactory"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (threadIdProvider == null) { throw new ArgumentNullException("threadIdProvider"); } if (container == null) { throw new ArgumentNullException("container"); } _errorContextFactory = errorContextFactory; _logger = logger; _threadIdProvider = threadIdProvider; _container = container; }
public void SetUp() { mockLogger = Substitute.For <ILogger>(); mockOpenKitConfiguration = Substitute.For <IOpenKitConfiguration>(); mockOpenKitConfiguration.ApplicationId.Returns(string.Empty); mockOpenKitConfiguration.ApplicationName.Returns(string.Empty); mockOpenKitConfiguration.ApplicationVersion.Returns(string.Empty); mockOpenKitConfiguration.DeviceId.Returns(DeviceId); mockPrivacyConfiguration = Substitute.For <IPrivacyConfiguration>(); mockBeaconCache = Substitute.For <IBeaconCache>(); mockSessionIdProvider = Substitute.For <ISessionIdProvider>(); mockThreadIdProvider = Substitute.For <IThreadIdProvider>(); mockTimingProvider = Substitute.For <ITimingProvider>(); mockParent = Substitute.For <IOpenKitComposite>(); mockInput = Substitute.For <ISessionCreatorInput>(); mockInput.Logger.Returns(mockLogger); mockInput.OpenKitConfiguration.Returns(mockOpenKitConfiguration); mockInput.PrivacyConfiguration.Returns(mockPrivacyConfiguration); mockInput.BeaconCache.Returns(mockBeaconCache); mockInput.SessionIdProvider.Returns(mockSessionIdProvider); mockInput.ThreadIdProvider.Returns(mockThreadIdProvider); mockInput.TimingProvider.Returns(mockTimingProvider); mockInput.CurrentServerId.Returns(ServerId); }
public static IThreadIdProvider SetProvider(IThreadIdProvider provider) { IThreadIdProvider result = ThreadIdProvider.provider; ThreadIdProvider.provider = provider; return(result); }
public OpenKitInitializer(IOpenKitBuilder builder) { logger = builder.Logger; privacyConfiguration = PrivacyConfiguration.From(builder); openKitConfiguration = OpenKitConfiguration.From(builder); timingProvider = new DefaultTimingProvider(); threadIdProvider = new DefaultThreadIdProvider(); sessionIdProvider = new DefaultSessionIdProvider(); beaconCache = new BeaconCache(logger); beaconCacheEvictor = new BeaconCacheEvictor(logger, beaconCache, BeaconCacheConfiguration.From(builder), timingProvider); var httpClientConfig = HttpClientConfiguration.From(openKitConfiguration); // shared thread suspender between BeaconSender and HttpClient. HttpClient will be woken up when // BeaconSender shuts down var beaconSenderThreadSuspender = new InterruptibleThreadSuspender(); beaconSender = new BeaconSender( logger, httpClientConfig, new DefaultHttpClientProvider(logger, beaconSenderThreadSuspender), timingProvider, beaconSenderThreadSuspender); var watchdogThreadSuspender = new InterruptibleThreadSuspender(); sessionWatchdog = new SessionWatchdog( logger, new SessionWatchdogContext(timingProvider, watchdogThreadSuspender)); }
public void SetUp() { mockLogger = Substitute.For <ILogger>(); mockLogger.IsInfoEnabled.Returns(true); mockLogger.IsDebugEnabled.Returns(true); mockPrivacyConfig = Substitute.For <IPrivacyConfiguration>(); mockPrivacyConfig.DataCollectionLevel.Returns(ConfigurationDefaults.DefaultDataCollectionLevel); mockPrivacyConfig.CrashReportingLevel.Returns(ConfigurationDefaults.DefaultCrashReportingLevel); mockOpenKitConfig = Substitute.For <IOpenKitConfiguration>(); mockOpenKitConfig.ApplicationId.Returns(AppId); mockOpenKitConfig.DeviceId.Returns(DeviceId); mockOpenKitConfig.ApplicationName.Returns(AppName); mockOpenKitConfig.OperatingSystem.Returns(string.Empty); mockOpenKitConfig.Manufacturer.Returns(string.Empty); mockOpenKitConfig.ModelId.Returns(string.Empty); mockTimingProvider = Substitute.For <ITimingProvider>(); mockThreadIdProvider = Substitute.For <IThreadIdProvider>(); mockSessionIdProvider = Substitute.For <ISessionIdProvider>(); mockBeaconCache = Substitute.For <IBeaconCache>(); mockBeaconSender = Substitute.For <IBeaconSender>(); mockBeaconCacheEvictor = Substitute.For <IBeaconCacheEvictor>(); mockSessionWatchdog = Substitute.For <ISessionWatchdog>(); }
internal TestBeaconBuilder() { logger = Substitute.For <ILogger>(); beaconCache = Substitute.For <IBeaconCache>(); clientIpAddress = "127.0.0.1"; sessionIdProvider = Substitute.For <ISessionIdProvider>(); threadIdProvider = Substitute.For <IThreadIdProvider>(); timingProvider = Substitute.For <ITimingProvider>(); randomGenerator = Substitute.For <IPrnGenerator>(); }
public TestOpenKitBuilder() { logger = Substitute.For <ILogger>(); privacyConfig = Substitute.For <IPrivacyConfiguration>(); openKitConfig = Substitute.For <IOpenKitConfiguration>(); threadIdProvider = Substitute.For <IThreadIdProvider>(); timingProvider = Substitute.For <ITimingProvider>(); sessionIdProvider = Substitute.For <ISessionIdProvider>(); beaconCache = Substitute.For <IBeaconCache>(); beaconSender = Substitute.For <IBeaconSender>(); beaconCacheEvictor = Substitute.For <IBeaconCacheEvictor>(); sessionWatchdog = Substitute.For <ISessionWatchdog>(); }
/// <summary> /// Constructor for creating an OpenKit instance. /// </summary> /// <param name="initializer">provider to get all OpenKit related configuration parameters.</param> internal OpenKit(IOpenKitInitializer initializer) { logger = initializer.Logger; privacyConfiguration = initializer.PrivacyConfiguration; openKitConfiguration = initializer.OpenKitConfiguration; timingProvider = initializer.TimingProvider; threadIdProvider = initializer.ThreadIdProvider; sessionIdProvider = initializer.SessionIdProvider; beaconCache = initializer.BeaconCache; beaconCacheEvictor = initializer.BeaconCacheEvictor; beaconSender = initializer.BeaconSender; sessionWatchdog = initializer.SessionWatchdog; LogOpenKitInstanceCreation(logger, openKitConfiguration); }
public PerformanceTelemetryPayload( IErrorContext errorContext, ITelemetryLogger logger, IThreadIdProvider threadIdProvider, IPerformanceContainer container, string className, string methodName) { if (errorContext == null) { throw new ArgumentNullException("errorContext"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (threadIdProvider == null) { throw new ArgumentNullException("threadIdProvider"); } if (container == null) { throw new ArgumentNullException("container"); } if (className == null) { throw new ArgumentNullException("className"); } if (methodName == null) { throw new ArgumentNullException("methodName"); } this._errorContext = errorContext; this._logger = logger; this._container = container; this._manageThreadId = threadIdProvider.GetCurrentThreadId(); this._record = _container.OpenPerformanceSession( this._manageThreadId, className, methodName); }
/// <summary> /// Creates a new instance of type Beacon /// </summary> /// <param name="initializer">provider of relevant parameters to initialize / create the beacon</param> /// <param name="configuration">OpenKit related configuration</param> internal Beacon(IBeaconInitializer initializer, IBeaconConfiguration configuration) { beaconCache = initializer.BeaconCache; var beaconId = initializer.SessionIdProvider.GetNextSessionId(); SessionSequenceNumber = initializer.SessionSequenceNumber; beaconKey = new BeaconKey(beaconId, SessionSequenceNumber); SessionNumber = DetermineSessionNumber(configuration, beaconId); this.configuration = configuration; threadIdProvider = initializer.ThreadIdProvider; timingProvider = initializer.TimingProvider; SessionStartTime = timingProvider.ProvideTimestampInMilliseconds(); DeviceId = CreateDeviceId(configuration, initializer.RandomNumberGenerator); TrafficControlValue = initializer.RandomNumberGenerator.NextPercentageValue(); logger = initializer.Logger; var ipAddress = initializer.ClientIpAddress; if (ipAddress == null) { // A client IP address, which is a null, is valid. // The real IP address is determined on the server side. clientIpAddress = null; } else if (InetAddressValidator.IsValidIP(ipAddress)) { clientIpAddress = ipAddress; } else { if (logger.IsWarnEnabled) { logger.Warn($"Beacon: Client IP address validation failed: {ipAddress}"); } clientIpAddress = null; // determined on server side, based on remote IP address } basicBeaconData = CreateBasicBeaconData(); }
internal TestOpenKitBuilder With(IThreadIdProvider provider) { this.threadIdProvider = provider; return(this); }
internal TestBeaconBuilder With(IThreadIdProvider provider) { threadIdProvider = provider; return(this); }