Example #1
0
        internal void FlushPostedProperties()
        {
            RequiresNotDisposed();
            if (postedProperties.Count == 0 || !scheduler.CanEnterTimedDelegate())
            {
                return;
            }
            TelemetryEvent    telemetryEvent = CreateTelemetryEvent("PostProperty");
            PostPropertyEntry result;

            while (postedProperties.TryDequeue(out result))
            {
                if (result.IsReserved)
                {
                    telemetryEvent.ReservedProperties[result.Key] = result.Value;
                }
                else
                {
                    telemetryEvent.Properties[result.Key] = result.Value;
                }
            }
            TelemetrySession.ValidateEvent(telemetryEvent);
            ValidateEventProperties(telemetryEvent);
            AddReservedPropertiesToTheEvent(telemetryEvent);
            hostSession.PostValidatedEvent(telemetryEvent);
            scheduler.ExitTimedDelegate();
        }
Example #2
0
 /// <summary>
 /// Create TelemetrySessionContext with the name
 /// </summary>
 /// <param name="contextName"></param>
 /// <param name="theHostedSession">Session which owns this context</param>
 /// <param name="theScheduler"></param>
 /// <param name="theOverrideInit"></param>
 /// <param name="initializationAction"></param>
 internal TelemetryContext(string contextName, TelemetrySession theHostedSession, ITelemetryScheduler theScheduler = null, bool theOverrideInit = false, Action <TelemetryContext> initializationAction = null)
 {
     if (!IsContextNameValid(contextName))
     {
         throw new ArgumentException("contextName is invalid, contextName must contain alphanumeric characters only");
     }
     CodeContract.RequiresArgumentNotNull <TelemetrySession>(theHostedSession, "theHostedSession");
     if (theScheduler == null)
     {
         theScheduler = new TelemetryScheduler();
         theScheduler.InitializeTimed(TimeSpan.FromSeconds(15.0));
     }
     ContextName  = contextName;
     hostSession  = theHostedSession;
     scheduler    = theScheduler;
     overrideInit = theOverrideInit;
     hostSession.AddContext(this);
     initializationAction?.Invoke(this);
     if (!overrideInit)
     {
         hostSession.PostValidatedEvent(BuildStartEvent());
     }
 }