Esempio n. 1
0
 private void SetInternalUserNameIfApplicable(TelemetryManifest telemetryManifest)
 {
     if ((IsUserMicrosoftInternal && telemetryManifest.ShouldSendAliasForAllInternalUsers) || CanCollectPrivateInformation)
     {
         DefaultContext.SharedProperties["VS.Core.Internal.UserName"] = Guard(() => Environment.UserName, "Unknown");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Post diagnostic information about telemetry manifest rules and actions.
 /// </summary>
 /// <param name="newManifest"></param>
 private void PostDiagnosticInformation(TelemetryManifest newManifest)
 {
     foreach (IEventProcessorAction customAction in customActionList)
     {
         (customAction as IEventProcessorActionDiagnostics)?.PostDiagnosticInformation(mainSession, newManifest);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Passes default construction of channels and UserInformationManager to Initialize method
 /// </summary>
 /// <param name="checkPendingAsimovEvents">Do we need to check whether
 /// pending events exists and explicitly start Vortex channel</param>
 private void InitializeWithDefaultChannels(bool checkPendingAsimovEvents)
 {
     EventProcessor.CurrentManifest = TelemetryManifest.BuildDefaultManifest();
     ManifestManager.UpdateTelemetryManifestStatusEvent += TelemetryManifestUpdateStatus;
     AddSessionChannels(sessionInitializer.CreateSessionChannels(this, checkPendingAsimovEvents));
     AddSessionChannel(GlobalTelemetryTestChannel.Instance);
     ManifestManager.Start(HostName, startedDisposing == 1);
 }
 private void Reset(TelemetrySession mainSession, TelemetryManifest newManifest, DateTimeOffset timeToReset)
 {
     if (mainSession != null && (counter > threshold || whitelistCounter > threshold))
     {
         string            value           = "Unknown";
         TelemetryManifest currentManifest = mainSession.EventProcessor.CurrentManifest;
         if (currentManifest != null)
         {
             value = currentManifest.Version;
         }
         Dictionary <string, object> dictionary = new Dictionary <string, object>();
         dictionary["VS.TelemetryApi.DynamicTelemetry.Manifest.Version"] = value;
         dictionary["VS.TelemetryApi.DynamicTelemetry.HostName"]         = mainSession.HostName;
         dictionary["VS.TelemetryApi.ClientSideThrottling.Threshold"]    = threshold;
         dictionary["VS.TelemetryApi.ClientSideThrottling.TimerReset"]   = resetCounter;
         dictionary["VS.TelemetryApi.ClientSideThrottling.BucketStart"]  = bucketStartTime.UtcDateTime.ToString("MM/dd/yy H:mm:ss.fffffff", CultureInfo.InvariantCulture);
         if (counter > threshold)
         {
             long           num            = counter - threshold;
             TelemetryEvent telemetryEvent = new TelemetryEvent("VS/TelemetryApi/ClientSideThrottling");
             DictionaryExtensions.AddRange <string, object>(telemetryEvent.Properties, (IDictionary <string, object>)dictionary, true);
             telemetryEvent.Properties["VS.TelemetryApi.ClientSideThrottling.TotalDropped"] = num;
             telemetryEvent.Properties["VS.TelemetryApi.ClientSideThrottling.Events"]       = StringExtensions.Join((IEnumerable <string>)droppedEvents, ",");
             mainSession.PostEvent(telemetryEvent);
         }
         if (whitelistCounter > threshold)
         {
             long           num2            = whitelistCounter - threshold;
             TelemetryEvent telemetryEvent2 = new TelemetryEvent("VS/TelemetryApi/ClientSideThrottling/NoisyWhitelist");
             DictionaryExtensions.AddRange <string, object>(telemetryEvent2.Properties, (IDictionary <string, object>)dictionary, true);
             telemetryEvent2.Properties["VS.TelemetryApi.ClientSideThrottling.TotalNoise"] = num2;
             telemetryEvent2.Properties["VS.TelemetryApi.ClientSideThrottling.Events"]     = StringExtensions.Join((IEnumerable <string>)noisyWhiteListEvents, ",");
             mainSession.PostEvent(telemetryEvent2);
         }
     }
     counter          = 0L;
     whitelistCounter = 0L;
     bucketStartTime  = timeToReset;
     if (newManifest != null)
     {
         if (newManifest.ThrottlingThreshold > 0)
         {
             threshold = newManifest.ThrottlingThreshold;
         }
         if (newManifest.ThrottlingTimerReset > 0.0)
         {
             resetCounter = newManifest.ThrottlingTimerReset;
         }
     }
     droppedEvents.Clear();
     noisyWhiteListEvents.Clear();
 }
Esempio n. 5
0
        private void InstrumentLoad(TelemetryManifest telemetryManifest, long streamSize, string message, string errorDetails, double duration)
        {
            if (mainSession.IsSessionCloned)
            {
                return;
            }
            bool           flag           = telemetryManifest != null;
            TelemetryEvent telemetryEvent = new TelemetryEvent("VS/TelemetryApi/Manifest/Load");

            telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.HostName"]   = mainSession.HostName;
            telemetryEvent.Properties["VS.TelemetryApi.Manifest.Load.IsLoadSuccess"] = flag;
            if (streamSize > 0)
            {
                telemetryEvent.Properties["VS.TelemetryApi.Manifest.Load.StreamSize"] = streamSize;
            }
            if (flag)
            {
                if (telemetryManifest != null)
                {
                    telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.Version"]       = telemetryManifest.Version;
                    telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.FormatVersion"] = 2u;
                    if (telemetryManifest.InvalidRules.Any())
                    {
                        telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.UnrecognizedRules"] = StringExtensions.Join(telemetryManifest.InvalidRules, ",");
                    }
                    telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.UnrecognizedRules.Count"]   = telemetryManifest.InvalidRules.Count();
                    telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.UnrecognizedActions.Count"] = telemetryManifest.InvalidActionCount;
                    string text = StringExtensions.Join(from path in telemetryManifest.GetAllSamplings()
                                                        where path.Sampling.IsSampleActive
                                                        select path.FullName, ",");
                    if (text != string.Empty)
                    {
                        telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.EnabledSamplings"] = text;
                    }
                }
                telemetryEvent.Properties["VS.TelemetryApi.Manifest.Load.Duration"] = duration;
            }
            else
            {
                telemetryEvent.Properties["VS.TelemetryApi.Manifest.Load.ErrorMessage"] = message;
                if (errorDetails != null)
                {
                    telemetryEvent.Properties["VS.TelemetryApi.Manifest.Load.ErrorDetails"] = new TelemetryPiiProperty(errorDetails);
                }
            }
            mainSession.PostEvent(telemetryEvent);
        }
Esempio n. 6
0
 public void PostDiagnosticInformation(TelemetrySession mainSession, TelemetryManifest newManifest)
 {
     if (totalPropertyCount != 0)
     {
         string            value           = "Unknown";
         TelemetryManifest currentManifest = mainSession.EventProcessor.CurrentManifest;
         if (currentManifest != null)
         {
             value = currentManifest.Version;
         }
         TelemetryEvent telemetryEvent = new TelemetryEvent("VS/TelemetryApi/" + DiagnosticName);
         telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.Manifest.Version"] = value;
         telemetryEvent.Properties["VS.TelemetryApi.DynamicTelemetry.HostName"]         = mainSession.HostName;
         telemetryEvent.Properties["VS.TelemetryApi." + DiagnosticName + ".TotalCount"] = totalPropertyCount;
         telemetryEvent.Properties["VS.TelemetryApi." + DiagnosticName + ".Properties"] = StringExtensions.Join(properties.Select((string x) => x.ToLower(CultureInfo.InvariantCulture)), ",");
         mainSession.PostEvent(telemetryEvent);
     }
 }
Esempio n. 7
0
 private void UpdateManifest(TelemetryManifest manifestToBeUpdated)
 {
     lock (updateManifestLock)
     {
         if (diagnosticNeedsToBePosted)
         {
             PostDiagnosticInformation(manifestToBeUpdated);
         }
         if (manifestToBeUpdated != null)
         {
             currentManifest           = manifestToBeUpdated;
             diagnosticNeedsToBePosted = true;
         }
         else
         {
             diagnosticNeedsToBePosted = false;
         }
     }
 }
Esempio n. 8
0
        private async Task LoadManifest(BehaviorOnStale staleBehavior, CancellationToken token = default(CancellationToken))
        {
            //IL_000a: Unknown result type (might be due to invalid IL or missing references)
            //IL_000b: Unknown result type (might be due to invalid IL or missing references)
            Stopwatch watch = Stopwatch.StartNew();
            Tuple <TelemetryManifest, long> tuple = await ReadAndParseManifest(staleBehavior).ConfigureAwait(false);

            watch.Stop();
            if (!token.IsCancellationRequested && (CurrentManifest == null || (tuple.Item1 != null && !(CurrentManifest.Version == tuple.Item1.Version))))
            {
                string message = "Manifest is null";
                if (tuple.Item1 != null)
                {
                    CurrentManifest = tuple.Item1;
                    message         = null;
                }
                OnUpdateTelemetryManifestStatusEvent(new TelemetryManifestEventArgs(tuple.Item1));
                InstrumentLoad(tuple.Item1, tuple.Item2, message, null, watch.ElapsedMilliseconds);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Handles the TelemetryManifestUpdateStatus event from the downloader by giving the
 /// loaded TelemetryManifest to the EventProcessor in case of the success.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TelemetryManifestUpdateStatus(object sender, TelemetryManifestEventArgs e)
 {
     if (!base.IsDisposed)
     {
         if (e.IsSuccess)
         {
             TelemetryManifest telemetryManifest = e.TelemetryManifest;
             CalculatedSamplings            = telemetryManifest.CalculateAllSamplings(this);
             EventProcessor.CurrentManifest = telemetryManifest;
         }
         else
         {
             CalculatedSamplings = "e.IsSuccess == false";
         }
         if (!isManifestCompleted)
         {
             identityTelemetry.IdentityInformationProvider.Initialize(defaultContext, contextScheduler, e.TelemetryManifest?.MachineIdentityConfig);
             SetInternalInformationProperties(EventProcessor.CurrentManifest);
         }
         isManifestCompleted = true;
         InitializeSession();
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Add 3 Internal datapoints in case we are allowed to do it.
 /// </summary>
 private void SetInternalInformationProperties(TelemetryManifest telemetryManifest)
 {
     SetInternalUserNameIfApplicable(telemetryManifest);
     SetInternalComputerNameIfApplicable();
     SetInternalDomainNameIfApplicable();
 }
Esempio n. 11
0
 public void PostDiagnosticInformation(TelemetrySession mainSession, TelemetryManifest newManifest)
 {
     Reset(mainSession, newManifest, default(DateTimeOffset));
 }
Esempio n. 12
0
 public TelemetryManifestEventArgs(TelemetryManifest telemetryManifest)
 {
     TelemetryManifest = telemetryManifest;
     IsSuccess         = (telemetryManifest != null);
 }