예제 #1
0
        private string GetMetricJsonString(DateTime timestamp, AiMetric aiMetric)
        {
            var logRequest = new AiLogRequest
            {
                Name = $"Microsoft.ApplicationInsights.{this._instrumentationKey}.Metric",
                Time = timestamp.ToString("O"),
                InstrumentationKey = this._instrumentationKey,
                Tags = new AiTags
                {
                    RoleInstance        = null,
                    OperationName       = "xrmEvent",
                    AuthenticatedUserId = this._authenticatedUserId
                },
                Data = new AiData
                {
                    BaseType = "MetricData",
                    BaseData = new AiBaseData
                    {
                        Metrics = new List <AiMetric> {
                            aiMetric
                        },
                        Properties = this.EventProperties
                    }
                }
            };

            logRequest.Tags.OperationId = this.EventProperties.OperationId;

            var json = SerializationHelper.SerializeObject <AiLogRequest>(logRequest);

            return(json);
        }
예제 #2
0
        private string GetEventJsonString(
            DateTime timestamp,
            AiEvent aiEvent,
            Dictionary <string, double> measurements,
            string opName,
            string opid)
        {
            var logRequest = new AiLogRequest
            {
                Name = $"Microsoft.ApplicationInsights.{this._instrumentationKey}.Event",
                Time = timestamp.ToString("O"),
                InstrumentationKey = this._instrumentationKey,
                Tags = new AiTags
                {
                    RoleInstance        = null,
                    OperationName       = opName,
                    OperationId         = opid,
                    AuthenticatedUserId = this._authenticatedUserId
                },
                Data = new AiData {
                    BaseType = "EventData", BaseData = aiEvent
                }
            };

            var json = SerializationHelper.SerializeObject <AiLogRequest>(logRequest);

            json = InsertMetricsJson(measurements, json);

            return(json);
        }
예제 #3
0
        private string GetExceptionJsonString(DateTime timestamp, AiException aiException)
        {
            var logRequest = new AiLogRequest
            {
                Name = $"Microsoft.ApplicationInsights.{this._instrumentationKey}.Exception",
                Time = timestamp.ToString("O"),
                InstrumentationKey = this._instrumentationKey,
                Tags = new AiTags
                {
                    RoleInstance        = null,
                    OperationName       = null,
                    AuthenticatedUserId = this._authenticatedUserId
                },
                Data = new AiData
                {
                    BaseType = "ExceptionData",
                    BaseData = new AiBaseData
                    {
                        Properties = this.EventProperties,
                        Exceptions =
                            new List <AiException> {
                            aiException
                        }
                    }
                }
            };

            var json = SerializationHelper.SerializeObject <AiLogRequest>(logRequest);

            return(json);
        }
예제 #4
0
        private string GetTraceJsonString(DateTime timestamp, AiTrace aiTrace)
        {
            var logRequest = new AiLogRequest
            {
                Name = $"Microsoft.ApplicationInsights.{this._instrumentationKey}.Message",
                Time = timestamp.ToString("O"),
                InstrumentationKey = this._instrumentationKey,
                Tags = new AiTags
                {
                    OperationName       = null,
                    RoleInstance        = null,
                    AuthenticatedUserId = this._authenticatedUserId
                },
                Data = new AiData {
                    BaseType = "MessageData", BaseData = aiTrace
                }
            };

            var json = SerializationHelper.SerializeObject <AiLogRequest>(logRequest);

            return(json);
        }
예제 #5
0
        private string GetDependencyJsonString(DateTime timestamp, AiBaseData aiDependency, string operationName)
        {
            var logRequest = new AiLogRequest
            {
                Name =
                    $"Microsoft.ApplicationInsights.{this._instrumentationKey}.RemoteDependency",
                Time = timestamp.ToString("O"),
                InstrumentationKey = this._instrumentationKey,
                Tags = new AiTags
                {
                    RoleInstance        = string.Empty,
                    OperationName       = operationName,
                    AuthenticatedUserId = this._authenticatedUserId
                },
                Data = new AiData {
                    BaseType = "RemoteDependencyData", BaseData = aiDependency
                }
            };

            var json = SerializationHelper.SerializeObject <AiLogRequest>(logRequest);

            return(json);
        }