private void SendNewSessionRequests(IBeaconSendingContext context) { var newSessions = context.NewSessions; foreach (var newSession in newSessions) { if (!newSession.CanSendNewSessionRequest) { // already exceeded the maximum number of session requests, disable any further data collecting var currentConfiguration = newSession.BeaconConfiguration; var newConfiguration = new BeaconConfiguration(0, currentConfiguration.DataCollectionLevel, currentConfiguration.CrashReportingLevel); newSession.UpdateBeaconConfiguration(newConfiguration); continue; } var response = context.GetHTTPClient().SendNewSessionRequest(); if (response != null) { var currentConfiguration = newSession.BeaconConfiguration; var newConfiguration = new BeaconConfiguration(response.Multiplicity, currentConfiguration.DataCollectionLevel, currentConfiguration.CrashReportingLevel); newSession.UpdateBeaconConfiguration(newConfiguration); } else { // did not retrieve any response from server, maybe the cluster is down? newSession.DecreaseNumNewSessionRequests(); } } }
internal TestConfiguration(string deviceID, BeaconConfiguration beaconConfig, ISessionIDProvider sessionIDProvider) : base(OpenKitType.DYNATRACE, "", "", deviceID, "", sessionIDProvider, new SSLStrictTrustManager(), new Core.Device("", "", ""), "", new BeaconCacheConfiguration( BeaconCacheConfiguration.DEFAULT_MAX_RECORD_AGE_IN_MILLIS, BeaconCacheConfiguration.DEFAULT_LOWER_MEMORY_BOUNDARY_IN_BYTES, BeaconCacheConfiguration.DEFAULT_UPPER_MEMORY_BOUNDARY_IN_BYTES), beaconConfig) { EnableCapture(); }
ISessionInternals ISessionCreator.CreateSession(IOpenKitComposite parent) { var configuration = BeaconConfiguration.From(openKitConfiguration, privacyConfiguration, serverId); var beacon = new Beacon(this, configuration); var session = new Session(Logger, parent, beacon); SessionSequenceNumber++; return(session); }
public void SetUp() { logger = Substitute.For <ILogger>(); mockTimingProvider = Substitute.For <ITimingProvider>(); var beaconConfig = new BeaconConfiguration(1, DataCollectionLevel.USER_BEHAVIOR, CrashReportingLevel.OPT_IN_CRASHES); testConfiguration = new TestConfiguration("1", beaconConfig); beacon = new Beacon(logger, new BeaconCache(logger), testConfiguration, "127.0.0.1", Substitute.For <IThreadIDProvider>(), mockTimingProvider); }
public void AfterUpdatingTheBeaconConfigurationTheBeaconConfigurationIsSet() { // given var target = new SessionWrapper(wrappedSession); var newConfiguration = new BeaconConfiguration(42, DataCollectionLevel.OFF, CrashReportingLevel.OFF); // when updating target.UpdateBeaconConfiguration(newConfiguration); // then Assert.That(target.IsBeaconConfigurationSet, Is.True); // also verify that Session has been invoked Assert.That(wrappedSession.BeaconConfiguration, Is.SameAs(newConfiguration)); }
/// <summary> /// Send new session requests for all sessions where we currently don't have a multiplicity configuration. /// </summary> /// <param name="context">The state context.</param> /// <returns>The last status response received.</returns> private StatusResponse SendNewSessionRequests(IBeaconSendingContext context) { StatusResponse statusResponse = null; var newSessions = context.NewSessions; foreach (var newSession in newSessions) { if (!newSession.CanSendNewSessionRequest) { // already exceeded the maximum number of session requests, disable any further data collecting var currentConfiguration = newSession.BeaconConfiguration; var newConfiguration = new BeaconConfiguration(0, currentConfiguration.DataCollectionLevel, currentConfiguration.CrashReportingLevel); newSession.UpdateBeaconConfiguration(newConfiguration); continue; } statusResponse = context.GetHTTPClient().SendNewSessionRequest(); if (BeaconSendingResponseUtil.IsSuccessfulResponse(statusResponse)) { var currentConfiguration = newSession.BeaconConfiguration; var newConfiguration = new BeaconConfiguration(statusResponse.Multiplicity, currentConfiguration.DataCollectionLevel, currentConfiguration.CrashReportingLevel); newSession.UpdateBeaconConfiguration(newConfiguration); } else if (BeaconSendingResponseUtil.IsTooManyRequestsResponse(statusResponse)) { // server is currently overloaded, return immediately break; } else { // any other unsuccessful response newSession.DecreaseNumNewSessionRequests(); } } return(statusResponse); }
internal override OpenKitConfiguration BuildConfiguration() { var device = new Device(OperatingSystem, Manufacturer, ModelID); var beaconCacheConfig = new BeaconCacheConfiguration( BeaconCacheMaxBeaconAge, BeaconCacheLowerMemoryBoundary, BeaconCacheUpperMemoryBoundary); var beaconConfig = new BeaconConfiguration(BeaconConfiguration.DEFAULT_MULITPLICITY, DataCollectionLevel, CrashReportingLevel); return(new OpenKitConfiguration( OpenKitType.APPMON, applicationName, applicationName, DeviceID, EndpointURL, new DefaultSessionIDProvider(), TrustManager, device, ApplicationVersion, beaconCacheConfig, beaconConfig)); }
internal TestConfiguration(string deviceID, BeaconConfiguration beaconConfig) : this(deviceID, beaconConfig, new Providers.DefaultSessionIDProvider()) { }
internal TestConfiguration(string deviceID, BeaconConfiguration beaconConfig, ISessionIDProvider sessionIDProvider) : this("", deviceID, beaconConfig, sessionIDProvider) { }
/// <summary> /// Update the beacon's configuration. /// </summary> /// <param name="beaconConfiguration">The new beacon configuration.</param> internal void UpdateBeaconConfiguration(BeaconConfiguration beaconConfiguration) { Session.BeaconConfiguration = beaconConfiguration; beaconConfigurationSet = true; }