gpt4 book ai didi

com.nike.wingtips.tags.ZipkinHttpTagStrategy类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 10:30:49 25 4
gpt4 key购买 nike

本文整理了Java中com.nike.wingtips.tags.ZipkinHttpTagStrategy类的一些代码示例,展示了ZipkinHttpTagStrategy类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipkinHttpTagStrategy类的具体详情如下:
包路径:com.nike.wingtips.tags.ZipkinHttpTagStrategy
类名称:ZipkinHttpTagStrategy

ZipkinHttpTagStrategy介绍

[英]Applies Zipkin standard tags for:

  • http.method

  • http.path

  • http.url

  • http.route

  • http.status_code

  • error
    The following known Zipkin tags are unimplemented in this strategy:

  • http.request.size

  • http.response.size

  • http.host
    [中]将Zipkin标准标记应用于:
    *http。方法
    *http。路径
    *http。网址
    *http。路线
    *http。状态代码
    *错误
    以下已知的Zipkin标签在此策略中未实现:
    *http。要求大小
    *http。回答大小
    *http。主办

代码示例

代码示例来源:origin: Nike-Inc/wingtips

/**
 * @return {@link ZipkinHttpTagStrategy#getDefaultInstance()}.
 */
protected HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> getZipkinHttpTagStrategy() {
  return ZipkinHttpTagStrategy.getDefaultInstance();
}

代码示例来源:origin: Nike-Inc/wingtips

@Override
protected void doHandleResponseAndErrorTagging(
  @NotNull Span span,
  @Nullable REQ request,
  @Nullable RES response,
  @Nullable Throwable error,
  @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter
) {
  // Now that we have both request and response, we'll re-try to get the route.
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_ROUTE, adapter.getRequestUriPathTemplate(request, response));
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_STATUS_CODE, adapter.getResponseHttpStatus(response));
  // For error tagging, we'll defer to the error Throwable if it's not null.
  if (error != null) {
    String message = error.getMessage();
    if (message == null) {
      message = error.getClass().getSimpleName();
    }
    addErrorTagToSpan(span, message);
  }
  else {
    // The error Throwable was null, so we'll see if the adapter thinks this is an error response.
    String errorTagValue = adapter.getErrorResponseTagValue(response);
    if (StringUtils.isNotBlank(errorTagValue)) {
      addErrorTagToSpan(span, errorTagValue);
    }
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void doHandleRequestTagging_puts_expected_tags_based_on_adapter_results() {
  // given
  String adapterHttpMethod = "httpmethod-" + UUID.randomUUID().toString();
  String adapterPath = "path-" + UUID.randomUUID().toString();
  String adapterHttpUrl = "url-" + UUID.randomUUID().toString();
  String adapterRoute = "route-" + UUID.randomUUID().toString();
  doReturn(adapterHttpMethod).when(adapterMock).getRequestHttpMethod(anyObject());
  doReturn(adapterPath).when(adapterMock).getRequestPath(anyObject());
  doReturn(adapterHttpUrl).when(adapterMock).getRequestUrl(anyObject());
  doReturn(adapterRoute).when(adapterMock).getRequestUriPathTemplate(anyObject(), anyObject());
  // when
  implSpy.doHandleRequestTagging(spanMock, requestMock, adapterMock);
  // then
  verify(adapterMock).getRequestHttpMethod(requestMock);
  verify(adapterMock).getRequestPath(requestMock);
  verify(adapterMock).getRequestUrl(requestMock);
  verify(adapterMock).getRequestUriPathTemplate(requestMock, null);
  
  verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_METHOD, adapterHttpMethod);
  verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_PATH, adapterPath);
  verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_URL, adapterHttpUrl);
  verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_ROUTE, adapterRoute);
}

代码示例来源:origin: Nike-Inc/wingtips

implSpy.doHandleResponseAndErrorTagging(spanMock, requestMock, responseMock, scenario.error, adapterMock);
verify(adapterMock).getResponseHttpStatus(responseMock);
verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_ROUTE, adapterRoute);
verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.HTTP_STATUS_CODE, adapterHttpStatus);
  verify(implSpy).putTagIfValueIsNotBlank(spanMock, KnownZipkinTags.ERROR, scenario.expectedErrorTagValue);

代码示例来源:origin: Nike-Inc/wingtips

@SuppressWarnings("WeakerAccess")
  protected void addErrorTagToSpan(Span span, String errorTagValue) {
    putTagIfValueIsNotBlank(span, KnownZipkinTags.ERROR, errorTagValue);
  }
}

代码示例来源:origin: Nike-Inc/wingtips

@Before
public void beforeMethod() {
  implSpy = spy(new ZipkinHttpTagStrategy<>());
  spanMock = mock(Span.class);
  requestMock = mock(Object.class);
  responseMock = mock(Object.class);
  errorMock = mock(Throwable.class);
  adapterMock = mock(HttpTagAndSpanNamingAdapter.class);
}

代码示例来源:origin: Nike-Inc/wingtips

@Override
protected void doHandleRequestTagging(
  @NotNull Span span,
  @NotNull REQ request,
  @NotNull HttpTagAndSpanNamingAdapter<REQ, ?> adapter
) {
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_METHOD, adapter.getRequestHttpMethod(request));
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_PATH, adapter.getRequestPath(request));
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_URL, adapter.getRequestUrl(request));
  putTagIfValueIsNotBlank(span, KnownZipkinTags.HTTP_ROUTE, adapter.getRequestUriPathTemplate(request, null));
}

代码示例来源:origin: com.nike.riposte/riposte-core

/**
 * Creates a new instance that uses {@link ZipkinHttpTagStrategy#getDefaultInstance()} and {@link
 * RiposteWingtipsNettyClientTagAdapter#getDefaultInstance()} to do the work of span naming and tagging.
 */
public DefaultRiposteProxyRouterSpanNamingAndTaggingStrategy() {
  this(ZipkinHttpTagStrategy.getDefaultInstance(), RiposteWingtipsNettyClientTagAdapter.getDefaultInstance());
}

代码示例来源:origin: com.nike.riposte/riposte-core

/**
 * Creates a new instance that uses {@link ZipkinHttpTagStrategy#getDefaultInstance()} and {@link
 * RiposteWingtipsServerTagAdapter#getDefaultInstance()} to do the work of span naming and tagging.
 */
public DefaultRiposteServerSpanNamingAndTaggingStrategy() {
  this(ZipkinHttpTagStrategy.getDefaultInstance(), RiposteWingtipsServerTagAdapter.getDefaultInstance());
}

代码示例来源:origin: Nike-Inc/riposte

/**
 * Creates a new instance that uses {@link ZipkinHttpTagStrategy#getDefaultInstance()} and {@link
 * RiposteWingtipsServerTagAdapter#getDefaultInstance()} to do the work of span naming and tagging.
 */
public DefaultRiposteServerSpanNamingAndTaggingStrategy() {
  this(ZipkinHttpTagStrategy.getDefaultInstance(), RiposteWingtipsServerTagAdapter.getDefaultInstance());
}

代码示例来源:origin: Nike-Inc/riposte

/**
 * Creates a new instance that uses {@link ZipkinHttpTagStrategy#getDefaultInstance()} and {@link
 * AsyncHttpClientHelperTagAdapter#getDefaultInstance()} to do the work of span naming and tagging.
 */
public DefaultAsyncHttpClientHelperSpanNamingAndTaggingStrategy() {
  this(ZipkinHttpTagStrategy.getDefaultInstance(), AsyncHttpClientHelperTagAdapter.getDefaultInstance());
}

代码示例来源:origin: Nike-Inc/riposte

/**
 * Creates a new instance that uses {@link ZipkinHttpTagStrategy#getDefaultInstance()} and {@link
 * RiposteWingtipsNettyClientTagAdapter#getDefaultInstance()} to do the work of span naming and tagging.
 */
public DefaultRiposteProxyRouterSpanNamingAndTaggingStrategy() {
  this(ZipkinHttpTagStrategy.getDefaultInstance(), RiposteWingtipsNettyClientTagAdapter.getDefaultInstance());
}

代码示例来源:origin: Nike-Inc/wingtips

/**
 * Creates a new instance with the subspan option set to the value of the {@code surroundCallsWithSubspan}
 * argument, and the default {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter}
 * ({@link ZipkinHttpTagStrategy} and {@link ApacheHttpClientTagAdapter}).
 *
 * @param surroundCallsWithSubspan Pass in true to have requests surrounded in a subspan, false to disable the
 * subspan option.
 */
public WingtipsHttpClientBuilder(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, HttpResponse>getDefaultInstance(),
    ApacheHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: Nike-Inc/wingtips

/**
 * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default
 * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used
 * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}).
 *
 * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only
 * propagate the current span's info downstream (no subspan).
 */
public WingtipsAsyncClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(),
    SpringHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: Nike-Inc/wingtips

/**
 * Creates a new instance with the subspan option set to the value of the {@code surroundCallsWithSubspan}
 * argument, and the default {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter}
 * ({@link ZipkinHttpTagStrategy} and {@link ApacheHttpClientTagAdapter}).
 *
 * @param surroundCallsWithSubspan Pass in true to have requests surrounded in a subspan, false to disable the
 * subspan option.
 */
public WingtipsApacheHttpClientInterceptor(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, HttpResponse>getDefaultInstance(),
    ApacheHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: Nike-Inc/wingtips

/**
 * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default
 * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used
 * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}).
 * 
 * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only
 * propagate the current span's info downstream (no subspan).
 */
public WingtipsClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(),
    SpringHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: com.nike.wingtips/wingtips-spring

/**
 * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default
 * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used
 * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}).
 * 
 * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only
 * propagate the current span's info downstream (no subspan).
 */
public WingtipsClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(),
    SpringHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: com.nike.wingtips/wingtips-spring

/**
 * Constructor that lets you choose whether downstream calls will be surrounded with a subspan. The default
 * {@link HttpTagAndSpanNamingStrategy} and {@link HttpTagAndSpanNamingAdapter} will be used
 * ({@link ZipkinHttpTagStrategy} and {@link SpringHttpClientTagAdapter}).
 *
 * @param surroundCallsWithSubspan pass in true to have downstream calls surrounded with a new span, false to only
 * propagate the current span's info downstream (no subspan).
 */
public WingtipsAsyncClientHttpRequestInterceptor(boolean surroundCallsWithSubspan) {
  this(
    surroundCallsWithSubspan,
    ZipkinHttpTagStrategy.<HttpRequest, ClientHttpResponse>getDefaultInstance(),
    SpringHttpClientTagAdapter.getDefaultInstance()
  );
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void getDefaultInstance_returns_DEFAULT_INSTANCE() {
  // expect
  assertThat(ZipkinHttpTagStrategy.getDefaultInstance()).isSameAs(ZipkinHttpTagStrategy.DEFAULT_INSTANCE);
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void default_constructor_sets_fields_as_expected() {
  // when
  WingtipsApacheHttpClientInterceptor impl = new WingtipsApacheHttpClientInterceptor();
  // then
  assertThat(impl.surroundCallsWithSubspan).isTrue();
  assertThat(impl.tagAndNamingStrategy).isSameAs(ZipkinHttpTagStrategy.getDefaultInstance());
  assertThat(impl.tagAndNamingAdapter).isSameAs(ApacheHttpClientTagAdapter.getDefaultInstance());
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com