示例#1
0
        private DateTime InsertSpan(MetaDataDto metadata, string part)
        {
            DateTime time;
            var      errorSet         = JsonConvert.DeserializeObject <SpanDto>(part, new ApmDateTimeConverter());
            var      errorDetailsJson = errorSet.Span?.ToString();
            var      spanInfo         = JsonConvert.DeserializeObject <SpanDto.TransactionDtoInternal>(errorDetailsJson, new ApmDateTimeConverter());

            time = spanInfo.Timestamp;
            var dataDb = new TransactionData()
            {
                Time          = time,
                Name          = spanInfo.name,
                Host          = metadata?.Metadata?.System.HostName,
                App           = metadata?.Metadata?.Service?.Name,
                Type          = spanInfo.Type,
                Id            = spanInfo.id,
                TransactionId = spanInfo.Transaction_id,
                Duration      = Math.Round(spanInfo.duration, 2),
                ParentId      = spanInfo.Parent_id,
                Data          = JsonConvert.SerializeObject(errorSet.Span)
            };

            _crud.Insert(dataDb);
            return(time);
        }
示例#2
0
        private MetaDataDto BuildMetaDataResponse(IEnumerable <MetaData> data)
        {
            var metaDataDto = new MetaDataDto()
            {
                Team        = new List <TeamDto>(),
                ImpactStats = new List <ImpactStatsDto>()
            };

            foreach (var stat in data)
            {
                switch (stat.Section)
                {
                case "team":
                    metaDataDto.Team.Add(_mapper.Map <TeamDto>(stat));
                    break;

                case "impact":
                    metaDataDto.ImpactStats.Add(_mapper.Map <ImpactStatsDto>(stat));
                    break;

                default:
                    break;
                }
            }

            return(metaDataDto);
        }
示例#3
0
        private DateTime InsertMetrics(MetaDataDto metadata, string part)
        {
            DateTime time;
            var      metricset    = JsonConvert.DeserializeObject <MetricsetDto>(part, new ApmDateTimeConverter());
            var      metricValues = metricset.Metricset.Samples.Select(x => new { x.Key, x.Value.Value }).ToDictionary(x => x.Key, x => x.Value);

            time = metricset.Metricset.Timestamp;

            var dataDb = new MetricData()
            {
                Time    = time,
                Host    = metadata?.Metadata?.System.HostName,
                Metrics = JsonConvert.SerializeObject(metricValues)
            };

            _crud.Insert(dataDb);
            return(time);
        }
示例#4
0
        private DateTime InsertError(MetaDataDto metadata, string part)
        {
            DateTime time;
            var      errorSet         = JsonConvert.DeserializeObject <ErrorsetDto>(part, new ApmDateTimeConverter());
            var      errorDetailsJson = errorSet.Error.ToString();
            var      errorInfo        = JsonConvert.DeserializeObject <ErrorsetDto.ErrorDtoInternal>(errorDetailsJson, new ApmDateTimeConverter());

            time = errorInfo.Timestamp;
            var dataDb = new ErrorData()
            {
                Time          = time,
                Host          = metadata?.Metadata?.System.HostName,
                ErrorInfo     = errorSet.Error.ToString(),
                TransactionId = errorInfo.Transaction_Id,
                //App = errorInfo.Culprit,
                App      = metadata?.Metadata?.Service?.Name ?? errorInfo.Culprit,
                ParentId = errorInfo.ParentId,
                ErrorId  = errorInfo.Id,
            };

            _crud.Insert(dataDb);
            return(time);
        }