Esempio n. 1
0
        /// <summary>
        /// Create new default session with specified parameters
        /// </summary>
        /// <param name="appInsightsIKey"></param>
        /// <param name="asimovIKey"></param>
        /// <returns></returns>
        public static TelemetrySession CreateAndGetDefaultSession(string appInsightsIKey, string asimovIKey)
        {
            bool flag = true;

            if (InternalDefaultSession == null)
            {
                lock (lockDefaultSessionCreation)
                {
                    if (InternalDefaultSession == null)
                    {
                        CodeContract.RequiresArgumentNotEmptyOrWhitespace(appInsightsIKey, "appInsightsIKey");
                        CodeContract.RequiresArgumentNotEmptyOrWhitespace(asimovIKey, "asimovIKey");
                        TelemetrySessionInitializer @default = TelemetrySessionInitializer.Default;
                        @default.AppInsightsInstrumentationKey = appInsightsIKey;
                        @default.AsimovInstrumentationKey      = asimovIKey;
                        InternalDefaultSession = TelemetrySession.Create(@default);
                        flag = false;
                    }
                }
            }
            if (flag)
            {
                throw new InvalidOperationException("Unable to create new default Telemetry Session with provided keys.");
            }
            return(InternalDefaultSession);
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new telemetry session from the given initializer.
 /// </summary>
 /// <param name="initializerObject"></param>
 /// <returns></returns>
 internal static TelemetrySession Create(TelemetrySessionInitializer initializerObject)
 {
     CodeContract.RequiresArgumentNotNull <TelemetrySessionInitializer>(initializerObject, "initializerObject");
     if (!TelemetrySessionSettings.IsSessionIdValid(initializerObject.SessionId))
     {
         throw new ArgumentException("Session ID in sessionSettings is not valid", "sessionSettings");
     }
     return(new TelemetrySession(new TelemetrySessionSettings(initializerObject.SessionId, initializerObject.InternalSettings, initializerObject.AppInsightsInstrumentationKey, initializerObject.AsimovInstrumentationKey, initializerObject.ProcessCreationTime), false, initializerObject));
 }
Esempio n. 3
0
        /// <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;
        }
Esempio n. 4
0
 /// <summary>
 /// Create TelemetrySession object from serialized session settings and
 /// using custom session initializer object
 /// </summary>
 /// <param name="serializedSession"></param>
 /// <param name="initializerObject"></param>
 internal TelemetrySession(string serializedSession, TelemetrySessionInitializer initializerObject)
     : this(TelemetrySessionSettings.Parse(serializedSession), true, initializerObject)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Create TelemetrySession object from serialized session settings and
 /// use the session settings to setup initializer
 /// </summary>
 /// <param name="telemetrySessionSettings"></param>
 internal TelemetrySession(TelemetrySessionSettings telemetrySessionSettings)
     : this(telemetrySessionSettings, true, TelemetrySessionInitializer.FromSessionSettings(telemetrySessionSettings))
 {
 }
Esempio n. 6
0
 public TelemetrySessionSettings(string id, IInternalSettings internalSettings, string appInsightsIKey, string asimovIKey)
     : this(id, internalSettings, appInsightsIKey, asimovIKey, TelemetrySessionInitializer.GetProcessCreationTime())
 {
 }