예제 #1
0
 @Nullable
 public Snapshot readSnapshot(String id) {
   logger.debug("readSnapshot(): id={}", id);
   List<PartiallyHydratedTrace> partiallyHydratedTraces;
   try {
     partiallyHydratedTraces =
         dataSource.query(
             "select id, stuck, start_time,"
                 + " capture_time, duration, background, grouping, error_message, user,"
                 + " attributes, metrics, jvm_info, spans, coarse_merged_stack_tree,"
                 + " fine_merged_stack_tree from snapshot where id = ?",
             ImmutableList.of(id),
             new TraceRowMapper());
   } catch (SQLException e) {
     logger.error(e.getMessage(), e);
     return null;
   }
   if (partiallyHydratedTraces.isEmpty()) {
     return null;
   } else if (partiallyHydratedTraces.size() > 1) {
     logger.error("multiple records returned for id: {}", id);
   }
   // read from rolling file outside of jdbc connection
   return partiallyHydratedTraces.get(0).fullyHydrate();
 }
예제 #2
0
 public ImmutableList<TracePoint> readPoints(TracePointQuery query) {
   logger.debug("readPoints(): query={}", query);
   try {
     ParameterizedSql parameterizedSql = query.getParameterizedSql();
     return dataSource.query(
         parameterizedSql.getSql(), parameterizedSql.getArgs(), new PointRowMapper());
   } catch (SQLException e) {
     logger.error(e.getMessage(), e);
     return ImmutableList.of();
   }
 }
예제 #3
0
 @OnlyUsedByTests
 @Nullable
 public Snapshot getLastSnapshot(boolean summary) throws SQLException {
   List<String> ids =
       dataSource.query(
           "select id from snapshot order by capture_time desc" + " limit 1",
           ImmutableList.of(),
           new RowMapper<String>() {
             @Override
             public String mapRow(ResultSet resultSet) throws SQLException {
               return resultSet.getString(1);
             }
           });
   if (ids.isEmpty()) {
     return null;
   }
   if (summary) {
     return readSnapshotWithoutDetail(ids.get(0));
   } else {
     return readSnapshot(ids.get(0));
   }
 }
예제 #4
0
 @Nullable
 public Snapshot readSnapshotWithoutDetail(String id) {
   logger.debug("readSnapshot(): id={}", id);
   List<Snapshot> snapshots;
   try {
     snapshots =
         dataSource.query(
             "select id, stuck, start_time, capture_time, duration,"
                 + " background, grouping, error_message, user, attributes, metrics,"
                 + " jvm_info from snapshot where id = ?",
             ImmutableList.of(id),
             new SnapshotRowMapper());
   } catch (SQLException e) {
     logger.error(e.getMessage(), e);
     return null;
   }
   if (snapshots.isEmpty()) {
     return null;
   } else if (snapshots.size() > 1) {
     logger.error("multiple records returned for id: {}", id);
   }
   return snapshots.get(0);
 }