コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
 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();
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 internal TestConfiguration(string deviceID, BeaconConfiguration beaconConfig)
     : this(deviceID, beaconConfig, new Providers.DefaultSessionIDProvider())
 {
 }
コード例 #9
0
 internal TestConfiguration(string deviceID, BeaconConfiguration beaconConfig, ISessionIDProvider sessionIDProvider)
     : this("", deviceID, beaconConfig, sessionIDProvider)
 {
 }
コード例 #10
0
 /// <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;
 }