コード例 #1
0
        private void DoFetchTrace()
        {
            try
            {
                using (var sessRows = _session.Execute(string.Format(SelectSessionsFormat, _traceId)))
                {
                    foreach (var sessRow in sessRows.GetRows())
                    {
                        _requestType = sessRow.GetValue <string>("request");
                        if (!sessRow.IsNull("duration"))
                        {
                            _duration = sessRow.GetValue <int>("duration");
                        }
                        _coordinator = sessRow.GetValue <IPAddress>("coordinator");
                        if (!sessRow.IsNull("parameters"))
                        {
                            _parameters = sessRow.GetValue <IDictionary <string, string> >("parameters");
                        }
                        _startedAt = sessRow.GetValue <DateTimeOffset>("started_at").ToFileTime(); //.getTime();

                        break;
                    }
                }

                _events = new List <Event>();

                using (var evRows = _session.Execute(string.Format(SelectEventsFormat, _traceId)))
                {
                    foreach (var evRow in evRows.GetRows())
                    {
                        _events.Add(new Event(evRow.GetValue <string>("activity"),
                                              new DateTimeOffset(Utils.GetTimestampFromGuid(evRow.GetValue <Guid>("event_id")) + (new DateTimeOffset(1582, 10, 15, 0, 0, 0, TimeSpan.Zero)).Ticks, TimeSpan.Zero),
                                              evRow.GetValue <IPAddress>("source"),
                                              evRow.IsNull("source_elapsed") ? 0 : evRow.GetValue <int>("source_elapsed"),
                                              evRow.GetValue <string>("thread")));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Unexpected exception while fetching query trace", ex);
                throw new TraceRetrievalException("Unexpected exception while fetching query trace", ex);
            }
        }
コード例 #2
0
        private void DoFetchTrace()
        {
            try
            {
                var sessionStatement = new SimpleStatement(string.Format(SelectSessionsFormat, _traceId))
                                       .SetConsistencyLevel(ConsistencyLevel.One);
                var sessionRow = _session.Execute(sessionStatement).First();
                _requestType = sessionRow.GetValue <string>("request");
                if (!sessionRow.IsNull("duration"))
                {
                    _duration = sessionRow.GetValue <int>("duration");
                }
                _coordinator = sessionRow.GetValue <IPAddress>("coordinator");
                if (!sessionRow.IsNull("parameters"))
                {
                    _parameters = sessionRow.GetValue <IDictionary <string, string> >("parameters");
                }
                _startedAt = sessionRow.GetValue <DateTimeOffset>("started_at").ToFileTime();
                if (sessionRow.GetColumn("client") != null)
                {
                    ClientAddress = sessionRow.GetValue <IPAddress>("client");
                }
                _events = new List <Event>();

                var eventStatement = new SimpleStatement(string.Format(SelectEventsFormat, _traceId))
                                     .SetConsistencyLevel(ConsistencyLevel.One);
                var eventRows = _session.Execute(eventStatement);
                foreach (var row in eventRows)
                {
                    _events.Add(new Event(row.GetValue <string>("activity"),
                                          new DateTimeOffset(
                                              Utils.GetTimestampFromGuid(row.GetValue <Guid>("event_id")) +
                                              (new DateTimeOffset(1582, 10, 15, 0, 0, 0, TimeSpan.Zero)).Ticks, TimeSpan.Zero),
                                          row.GetValue <IPAddress>("source"),
                                          row.IsNull("source_elapsed") ? 0 : row.GetValue <int>("source_elapsed"),
                                          row.GetValue <string>("thread")));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Unexpected exception while fetching query trace", ex);
                throw new TraceRetrievalException("Unexpected exception while fetching query trace", ex);
            }
        }