当前位置: 首页>>代码示例>>Java>>正文


Java QueryRequest类代码示例

本文整理汇总了Java中zipkin.storage.QueryRequest的典型用法代码示例。如果您正苦于以下问题:Java QueryRequest类的具体用法?Java QueryRequest怎么用?Java QueryRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryRequest类属于zipkin.storage包,在下文中一共展示了QueryRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTraces

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@RequestMapping(value = "/traces", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public String getTraces(
    @RequestParam(value = "serviceName", required = false) String serviceName,
    @RequestParam(value = "spanName", defaultValue = "all") String spanName,
    @RequestParam(value = "annotationQuery", required = false) String annotationQuery,
    @RequestParam(value = "minDuration", required = false) Long minDuration,
    @RequestParam(value = "maxDuration", required = false) Long maxDuration,
    @RequestParam(value = "endTs", required = false) Long endTs,
    @RequestParam(value = "lookback", required = false) Long lookback,
    @RequestParam(value = "limit", required = false) Integer limit) {
  QueryRequest queryRequest = QueryRequest.builder()
      .serviceName(serviceName)
      .spanName(spanName)
      .parseAnnotationQuery(annotationQuery)
      .minDuration(minDuration)
      .maxDuration(maxDuration)
      .endTs(endTs)
      .lookback(lookback != null ? lookback : defaultLookback)
      .limit(limit).build();

  return new String(Codec.JSON.writeTraces(storage.spanStore().getTraces(queryRequest)), UTF_8);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:23,代码来源:ZipkinQueryApiV1.java

示例2: processDependencies

import zipkin.storage.QueryRequest; //导入依赖的package包/类
/**
 * This processes the job as if it were a batch. For each day we had traces, run the job again.
 */
@Override public void processDependencies(List<Span> spans) {
  // TODO: this avoids overrunning the cluster, though we ought to deal with this upstream
  for (List<Span> nextChunk : Lists.partition(spans, 100)) {
    CallbackCaptor<Void> callback = new CallbackCaptor<>();
    storage().asyncSpanConsumer().accept(nextChunk, callback);
    callback.get();
  }

  Set<Long> days = new LinkedHashSet<>();
  for (List<Span> trace : storage().spanStore()
      .getTraces(QueryRequest.builder().limit(10000).build())) {
    days.add(midnightUTC(guessTimestamp(MergeById.apply(trace).get(0)) / 1000));
  }

  for (long day : days) {
    CassandraDependenciesJob.builder()
        .keyspace(storage.keyspace)
        .localDc(storage().localDc)
        .contactPoints(storage.contactPoints())
        .day(day).build().run();
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:26,代码来源:CassandraDependenciesTest.java

示例3: processDependencies

import zipkin.storage.QueryRequest; //导入依赖的package包/类
/**
 * This processes the job as if it were a batch. For each day we had traces, run the job again.
 */
@Override public void processDependencies(List<Span> spans) {
  try {
    esStorage().spanConsumer().accept(V2SpanConverter.fromSpans(spans)).execute();
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  }

  Set<Long> days = new LinkedHashSet<>();
  for (List<Span> trace : storage().spanStore()
      .getTraces(QueryRequest.builder().limit(10000).build())) {
    days.add(midnightUTC(guessTimestamp(MergeById.apply(trace).get(0)) / 1000));
  }

  for (long day : days) {
    ElasticsearchDependenciesJob.builder().index(INDEX).hosts(esNodes()).day(day).build().run();
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:21,代码来源:ElasticsearchDependenciesTest.java

示例4: processDependencies

import zipkin.storage.QueryRequest; //导入依赖的package包/类
/**
 * This processes the job as if it were a batch. For each day we had traces, run the job again.
 */
@Override
public void processDependencies(List<Span> spans) {
  CallbackCaptor<Void> callback = new CallbackCaptor<>();
  storage.asyncSpanConsumer().accept(spans, callback);
  callback.get();

  Set<Long> days = new LinkedHashSet<>();
  for (List<Span> trace : storage.spanStore()
      .getTraces(QueryRequest.builder().limit(10000).build())) {
    days.add(midnightUTC(guessTimestamp(MergeById.apply(trace).get(0)) / 1000));
  }

  for (long day : days) {
    MySQLDependenciesJob.builder().day(day).build().run();
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:20,代码来源:MySQLDependenciesTest.java

示例5: getTraces

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Override
public List<List<Span>> getTraces(QueryRequest request) {
  if (tracer.startNewSpan(component, "get-traces") != null) {
    tracer.submitBinaryAnnotation("request", request.toString());
  }
  try {
    return delegate.getTraces(request);
  } finally {
    tracer.finishSpan();
  }
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:12,代码来源:TracedSpanStore.java

示例6: overFetchesToCompensateForDuplicateIndexData

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void overFetchesToCompensateForDuplicateIndexData() {
  int traceCount = 100;

  List<Span> spans = new ArrayList<>();
  for (int i = 0; i < traceCount; i++) {
    final long delta = i * 1000; // all timestamps happen a millisecond later
    for (Span s : TestObjects.TRACE) {
      spans.add(TestObjects.TRACE.get(0).toBuilder()
          .traceId(s.traceId + i * 10)
          .id(s.id + i * 10)
          .timestamp(s.timestamp + delta)
          .annotations(s.annotations.stream()
              .map(a -> Annotation.create(a.timestamp + delta, a.value, a.endpoint))
              .collect(toList()))
          .build());
    }
  }

  accept(spans.toArray(new Span[spans.size()]));

  // Index ends up containing more rows than services * trace count, and cannot be de-duped
  // in a server-side query.
  assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN))
      .isGreaterThan(traceCount * store().getServiceNames().size());

  // Implementation over-fetches on the index to allow the user to receive unsurprising results.
  assertThat(
      store().getTraces(QueryRequest.builder().lookback(86400000L).limit(traceCount).build()))
      .hasSize(traceCount);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:32,代码来源:CassandraSpanStoreTest.java

示例7: annotationKeys_serviceNameRequired

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void annotationKeys_serviceNameRequired() {
  thrown.expect(IllegalArgumentException.class);

  CassandraUtil.annotationKeys(
      QueryRequest.builder().lookback(86400000L).addAnnotation("sr").build());
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:8,代码来源:CassandraUtilTest.java

示例8: annotationKeys

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void annotationKeys() {
  assertThat(CassandraUtil.annotationKeys(QueryRequest.builder()
      .lookback(86400000L)
      .serviceName("service")
      .addAnnotation(Constants.ERROR)
      .addBinaryAnnotation(TraceKeys.HTTP_METHOD, "GET").build()))
      .containsExactly("service:error", "service;http.method;GET");
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:10,代码来源:CassandraUtilTest.java

示例9: annotationKeys_dedupes

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void annotationKeys_dedupes() {
  assertThat(CassandraUtil.annotationKeys(QueryRequest.builder()
      .lookback(86400000L)
      .serviceName("service")
      .addAnnotation(Constants.ERROR)
      .addAnnotation(Constants.ERROR).build()))
      .containsExactly("service:error");
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:10,代码来源:CassandraUtilTest.java

示例10: overFetchesToCompensateForDuplicateIndexData

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void overFetchesToCompensateForDuplicateIndexData() {
  int traceCount = 100;

  List<Span> spans = new ArrayList<>();
  for (int i = 0; i < traceCount; i++) {
    final long delta = i * 1000; // all timestamps happen a millisecond later
    for (Span s : TestObjects.TRACE) {
      spans.add(TestObjects.TRACE.get(0).toBuilder()
          .traceId(s.traceId + i * 10)
          .id(s.id + i * 10)
          .timestamp(s.timestamp + delta)
          .annotations(s.annotations.stream()
              .map(a -> Annotation.create(a.timestamp + delta, a.value, a.endpoint))
              .collect(toList()))
          .build());
    }
  }

  accept(spans.toArray(new Span[0]));

  // Index ends up containing more rows than services * trace count, and cannot be de-duped
  // in a server-side query.
  assertThat(rowCount(Tables.SERVICE_NAME_INDEX))
      .isGreaterThan(traceCount * store().getServiceNames().size());

  // Implementation over-fetches on the index to allow the user to receive unsurprising results.
  assertThat(store().getTraces(QueryRequest.builder().limit(traceCount).build()))
      .hasSize(traceCount);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:31,代码来源:CassandraSpanStoreTest.java

示例11: annotationKeys

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void annotationKeys() {
  assertThat(CassandraUtil.annotationKeys(QueryRequest.builder()
      .serviceName("service")
      .addAnnotation(Constants.ERROR)
      .addBinaryAnnotation(TraceKeys.HTTP_METHOD, "GET").build()))
      .containsExactly("service:error", "service:http.method:GET");
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:9,代码来源:CassandraUtilTest.java

示例12: annotationKeys_dedupes

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void annotationKeys_dedupes() {
  assertThat(CassandraUtil.annotationKeys(QueryRequest.builder()
      .serviceName("service")
      .addAnnotation(Constants.ERROR)
      .addAnnotation(Constants.ERROR).build()))
      .containsExactly("service:error");
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:9,代码来源:CassandraUtilTest.java

示例13: toQueryRequest

import zipkin.storage.QueryRequest; //导入依赖的package包/类
static QueryRequest toQueryRequest(HttpUrl url) {
  return QueryRequest.builder().serviceName(url.queryParameter("serviceName"))
                               .spanName(url.queryParameter("spanName"))
                               .parseAnnotationQuery(url.queryParameter("annotationQuery"))
                               .minDuration(maybeLong(url.queryParameter("minDuration")))
                               .maxDuration(maybeLong(url.queryParameter("maxDuration")))
                               .endTs(maybeLong(url.queryParameter("endTs")))
                               .lookback(maybeLong(url.queryParameter("lookback")))
                               .limit(maybeInteger(url.queryParameter("limit"))).build();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:11,代码来源:ZipkinDispatcher.java

示例14: getTraces

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Override
public List<List<Span>> getTraces(QueryRequest request) {
  HttpUrl.Builder url = baseUrl.newBuilder("/api/v1/traces");
  maybeAddQueryParam(url, "serviceName", request.serviceName);
  maybeAddQueryParam(url, "spanName", request.spanName);
  maybeAddQueryParam(url, "annotationQuery", request.toAnnotationQuery());
  maybeAddQueryParam(url, "minDuration", request.minDuration);
  maybeAddQueryParam(url, "maxDuration", request.maxDuration);
  maybeAddQueryParam(url, "endTs", request.endTs);
  maybeAddQueryParam(url, "lookback", request.lookback);
  maybeAddQueryParam(url, "limit", request.limit);
  Response response = call(new Request.Builder().url(url.build()).build());
  return Codec.JSON.readTraces(responseBytes(response));
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:15,代码来源:HttpSpanStore.java

示例15: toQueryRequest

import zipkin.storage.QueryRequest; //导入依赖的package包/类
@Test
public void toQueryRequest() {
  HttpUrl url = baseUrl.newBuilder()
      .addQueryParameter("serviceName", "zipkin-server")
      .addQueryParameter("spanName", "get")
      .addQueryParameter("limit", "1000").build();

  QueryRequest request = ZipkinDispatcher.toQueryRequest(url);

  assertThat(request.serviceName).isEqualTo("zipkin-server");
  assertThat(request.spanName).isEqualTo("get");
  assertThat(request.limit).isEqualTo(1000);
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:14,代码来源:ZipkinDispatcherTest.java


注:本文中的zipkin.storage.QueryRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。