Пример #1
0
 protected TelemetryBase(string telememtryName, ITelemetryContext context, TData data)
 {
     this.TelemetryName = telememtryName;
     this.BaseType      = data.DataType;
     this.Data          = data;
     this.Context       = context;
 }
        /// <summary>
        /// Stringify the instance based on the provided Telemetry Context.
        /// </summary>
        /// <param name="context">The Telemetry Context.</param>
        /// <returns>System.String.</returns>
        public string AsStringWith(ITelemetryContext context)
        {
            var sb = new StringBuilder();

            sb.Append($"{RecordType}");
            sb.Append($"\t{context.Timestamp}");
            sb.Append($"\t{context.CorrelationId}");
            sb.Append($"\t{context.ChannelId}");
            sb.Append($"\t{context.ConversationId}");
            sb.Append($"\t{context.ActivityId}");
            sb.Append($"\t{context.UserId}");
            sb.Append($"\t{Json}");

            sb.Append($"\t{RequestIsCacheHit}");
            sb.Append($"\t{RequestMilliseconds}");
            sb.Append($"\t{RequestIsAmbiguous}");
            sb.Append($"\t{RequestQuality}");
            sb.Append($"\t{RequestIsAuthenticated}");

            sb.Append($"\t{IntentName}");
            sb.Append($"\t{IntentText}");
            sb.Append($"\t{IntentConfidenceScore}");

            sb.Append($"\t{EntityType}");
            sb.Append($"\t{EntityValue}");
            sb.Append($"\t{EntityConfidenceScore}");
            sb.Append($"\t{EntityIsAmbiguous}");

            sb.Append($"\t{ResponseText}");
            sb.Append($"\t{ResponseImageUrl}");
            sb.Append($"\t{ResponseJson}");
            sb.Append($"\t{ResponseType}");

            sb.Append($"\t{CounterCategory}");
            sb.Append($"\t{CounterName}");
            sb.Append($"\t{CounterValue}");

            sb.Append($"\t{MeasureCategory}");
            sb.Append($"\t{MeasureName}");
            sb.Append($"\t{MeasureValue}");

            sb.Append($"\t{ServiceResultName}");
            sb.Append($"\t{ServiceResultMilliseconds}");
            sb.Append($"\t{ServiceResultSuccess}");
            sb.Append($"\t{ServiceResultResponse}");

            sb.Append($"\t{TraceName}");
            sb.Append($"\t{TraceJson}");

            sb.Append($"\t{ExceptionComponent}");
            sb.Append($"\t{ExceptionContext}");
            sb.Append($"\t{ExceptionType}");
            sb.Append($"\t{ExceptionMessage}");
            sb.Append($"\t{ExceptionDetail}");

            sb.Append($"{Environment.NewLine}");

            return(sb.ToString());
        }
Пример #3
0
 protected virtual void WriteTelemetryContext(IJsonWriter json, ITelemetryContext context, IContextTagKeys keys)
 {
     if (context != null)
     {
         json.WriteProperty("iKey", context.InstrumentationKey);
         json.WriteProperty("tags", context.ToContextTags(keys));
     }
 }
 public MessageTelemetry(string message, eSeverityLevel?severityLevel, ITelemetryContext context, IMessageDataModel data, IDictionary <string, string> telemetryProperties = null)
     : base("Message", context, data)
 {
     this.Message       = message;
     this.SeverityLevel = severityLevel;
     if (telemetryProperties != null && telemetryProperties.Count > 0)
     {
         Utils.CopyDictionary <string>(telemetryProperties, this.Properties);
     }
 }
Пример #5
0
        public override void CopyFrom(ITelemetryContext source)
        {
            base.CopyFrom(source);

            var asSupportsDataKeyContext = source as ISupportDataKeyContext;

            if (asSupportsDataKeyContext != null)
            {
                asSupportsDataKeyContext.Data?.CopyTo(this.Data);
            }
        }
        public virtual void CopyFrom(ITelemetryContext source)
        {
            this.InstrumentationKey = source.InstrumentationKey;

            source.Component?.CopyTo(this.Component);
            source.Device?.CopyTo(this.Device);
            source.Cloud?.CopyTo(this.Cloud);
            source.Session?.CopyTo(this.Session);
            source.User?.CopyTo(this.User);
            source.Operation?.CopyTo(this.Operation);
            source.Location?.CopyTo(this.Location);
            source.Internal.CopyTo(this.Internal);
        }
        public EventTelemetry(string name, ITelemetryContext context, IEventDataModel data, IDictionary <string, string> telemetryProperties = null, IDictionary <string, double> telemetryMetrics = null)
            : base("Event", context, data)
        {
            this.Name = name;
            if (telemetryProperties != null && telemetryProperties.Count > 0)
            {
                Utils.CopyDictionary <string>(telemetryProperties, this.Properties);
            }

            if (telemetryMetrics != null && telemetryMetrics.Count > 0)
            {
                Utils.CopyDictionary <double>(telemetryMetrics, this.Metrics);
            }
        }
        public ExceptionTelemetry(Exception ex, ITelemetryContext context, IExceptionDataModel data, IDictionary <string, string> telemetryProperties = null, IDictionary <string, double> telemetryMetrics = null) : base("Exception", context, data)
        {
            this.Exception = ex;

            if (telemetryProperties != null && telemetryProperties.Count > 0)
            {
                Utils.CopyDictionary <string>(telemetryProperties, this.Properties);
            }

            if (telemetryMetrics != null && telemetryMetrics.Count > 0)
            {
                Utils.CopyDictionary <double>(telemetryMetrics, this.Metrics);
            }
        }
Пример #9
0
        public RequestTelemetry(string source, Uri url, ITelemetryContext context, IRequestDataModel dataModel, IDictionary <string, string> telemetryProperties = null, IDictionary <string, double> telemetryMetrics = null)
            : base("Request", context, dataModel)
        {
            this.Url    = url;
            this.Source = source;
            if (telemetryProperties != null && telemetryProperties.Count > 0)
            {
                Utils.CopyDictionary <string>(telemetryProperties, this.Properties);
            }

            if (telemetryMetrics != null && telemetryMetrics.Count > 0)
            {
                Utils.CopyDictionary <double>(telemetryMetrics, this.Metrics);
            }
        }
        /// <summary>
        /// Sets the context from the provided activity and/or telemetry context.
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <param name="context">The telemetry context.</param>
        /// <returns>Task.</returns>
        public Task SetContextFrom(IActivity activity, ITelemetryContext context = null)
        {
            if (null == context)
            {
                context = new TelemetryContext(new DateTimeProvider());
            }

            context.ActivityId     = activity.Id;
            context.ChannelId      = activity.ChannelId;
            context.ConversationId = activity.Conversation.Id;
            context.UserId         = activity.Conversation.Name;

            //flow the context through to all the children objects which depend upon it
            SetContext(context);

            return(Task.Delay(0));
        }
Пример #11
0
 internal OperationalTelemetryBase(string telememtryName, ITelemetryContext context, TData data)
     : base(telememtryName, context, data)
 {
 }
        public DependencyTelemetry(string dependencyTypeName, string target, string dependencyName, string dependencyData, ITelemetryContext context, IDependencyDataModel dataModel, IDictionary <string, string> telemetryProperties = null, IDictionary <string, double> telemetryMetrics = null)
            : base("RemoteDependency", context, dataModel)
        {
            this.DependencyType = dependencyTypeName;
            this.Name           = dependencyName;
            this.Target         = target;
            this.DependencyData = dependencyData;

            if (telemetryProperties != null && telemetryProperties.Count > 0)
            {
                Utils.CopyDictionary <string>(telemetryProperties, this.Properties);
            }

            if (telemetryMetrics != null && telemetryMetrics.Count > 0)
            {
                Utils.CopyDictionary <double>(telemetryMetrics, this.Metrics);
            }
        }
 public TelemetryClientFactory(ITelemetryContext context, ITelemetryInitializerChain telemetryInitializers)
 {
     this.telemetryContext = context;
     this.InitializerChain = telemetryInitializers;
 }
Пример #14
0
 public TelemetryRepository(ITelemetryContext context)
 {
     this._context = context;
 }
 /// <summary>
 /// Sets the telemetry context.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 public void SetContext(ITelemetryContext context)
 {
     TelemetryWriters.ForEach(tw => tw.SetContext(context));
 }
Пример #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppInsightsTelemetryWriter"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        public AppInsightsTelemetryWriter(AppInsightsTelemetryWriterConfiguration configuration, ITelemetryContext context)
        {
            SetField.NotNull(out _configuration, nameof(configuration), configuration);
            SetField.NotNull(out _context, nameof(context), context);

            Initialize();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MachineOptimizedOutputFormatter"/> class.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 public MachineOptimizedOutputFormatter(ITelemetryContext context)
 {
     SetField.NotNull(out _context, nameof(context), context);
 }
        internal protected ComponentTelemetryClient(string applicationName, ITelemetrySink telemetrySink, ITelemetryContext telemetryContext, ITelemetryInitializerChain initializers, IDictionary <string, string> contextProperties = null)
            : base()
        {
            this.TelemetrySink   = telemetrySink;
            this.Context         = telemetryContext;
            this.Initializers    = initializers;
            this.ApplicationName = applicationName;

            if (contextProperties != null && contextProperties.Count > 0)
            {
                Utils.CopyDictionary <string>(contextProperties, this.Context.Properties);
            }
        }
 /// <summary>
 /// Sets the telemetry context.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 public virtual void SetContext(ITelemetryContext context)
 {
     OutputFormatter.SetContext(context);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadabilityOptimizedOutputFormatter"/> class.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 public ReadabilityOptimizedOutputFormatter(ITelemetryContext context)
 {
     SetField.NotNull(out _context, nameof(context), context);
 }
 /// <summary>
 /// Generates the correlation identifier from a given telemetry context.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 /// <returns>System.String.</returns>
 public string GenerateCorrelationIdFrom(ITelemetryContext context)
 {
     return($"{context.ChannelId}{context.ConversationId}{context.ActivityId}{context.UserId}{context.Timestamp}");
 }
Пример #22
0
 /// <summary>
 /// Sets the telemetry context.
 /// </summary>
 /// <param name="context">The telemetry context.</param>
 public void SetContext(ITelemetryContext context)
 {
     _context = context;
 }