Tabnine Logo
BiPredicateWithTracing.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.nike.wingtips.util.asynchelperwrapper.BiPredicateWithTracing
constructor

Best Java code snippets using com.nike.wingtips.util.asynchelperwrapper.BiPredicateWithTracing.<init> (Showing top 12 results out of 315)

origin: Nike-Inc/wingtips

/**
 * @return A {@link BiPredicate} that wraps the given original so that the <b>current thread's</b> tracing and MDC
 * information is registered with the thread and therefore available during execution and unregistered after
 * execution.
 *
 * <p>NOTE: The current thread's tracing and MDC info will be extracted using {@link
 * Tracer#getCurrentSpanStackCopy()} and {@link MDC#getCopyOfContextMap()}.
 */
default <T, U> BiPredicate<T, U> biPredicateWithTracing(BiPredicate<T, U> biPredicate) {
  return new BiPredicateWithTracing<>(biPredicate);
}
origin: Nike-Inc/wingtips

/**
 * @return A {@link BiPredicate} that wraps the given original so that the given distributed tracing and MDC
 * information is registered with the thread and therefore available during execution and unregistered after
 * execution. You can pass in a {@link TracingState} for clearer less verbose code since it extends
 * {@code Pair<Deque<Span>, Map<String, String>>}.
 */
default <T, U> BiPredicate<T, U> biPredicateWithTracing(
  BiPredicate<T, U> biPredicate,
  Pair<Deque<Span>, Map<String, String>> threadInfoToLink
) {
  return new BiPredicateWithTracing<>(biPredicate, threadInfoToLink);
}
origin: Nike-Inc/wingtips

/**
 * @return A {@link BiPredicate} that wraps the given original so that the given distributed tracing and MDC
 * information is registered with the thread and therefore available during execution and unregistered after
 * execution.
 */
default <T, U> BiPredicate<T, U> biPredicateWithTracing(BiPredicate<T, U> biPredicate,
                            Deque<Span> spanStackToLink,
                            Map<String, String> mdcContextMapToLink) {
  return new BiPredicateWithTracing<>(biPredicate, spanStackToLink, mdcContextMapToLink);
}
origin: Nike-Inc/wingtips

/**
 * Equivalent to calling {@code new BiPredicateWithTracing(origBiPredicate)} - this allows you to do a static method
 * import for cleaner looking code in some cases. This method ultimately extracts the current tracing and MDC
 * information from the current thread using {@link Tracer#getCurrentSpanStackCopy()} and {@link
 * MDC#getCopyOfContextMap()}. That tracing and MDC information will be associated with the thread when the given
 * operation is executed.
 *
 * <p>The operation you pass in cannot be null (an {@link IllegalArgumentException} will be thrown if you pass in
 * null for the operation).
 *
 * @return {@code new BiPredicateWithTracing(origBiPredicate)}.
 * @see BiPredicateWithTracing#BiPredicateWithTracing(BiPredicate)
 * @see BiPredicateWithTracing
 */
public static <T, U> BiPredicateWithTracing<T, U> withTracing(BiPredicate<T, U> origBiPredicate) {
  return new BiPredicateWithTracing<>(origBiPredicate);
}
origin: Nike-Inc/wingtips

/**
 * Equivalent to calling {@code
 * new BiPredicateWithTracing(origBiPredicate, spanStackForExecution, mdcContextMapForExecution)} -
 * this allows you to do a static method import for cleaner looking code in some cases. This method uses the given
 * trace and MDC information, which will be associated with the thread when the given operation is executed.
 *
 * <p>The operation you pass in cannot be null (an {@link IllegalArgumentException} will be thrown if you pass in
 * null for the operation).
 *
 * <p>The trace and/or MDC info can be null and no error will be thrown, however any trace or MDC info that is null
 * means the corresponding info will not be available to the thread when the operation is executed.
 *
 * @return {@code new BiPredicateWithTracing(origBiPredicate, spanStackForExecution, mdcContextMapForExecution)}.
 * @see BiPredicateWithTracing#BiPredicateWithTracing(BiPredicate, Deque, Map)
 * @see BiPredicateWithTracing
 */
public static <T, U> BiPredicateWithTracing<T, U> withTracing(BiPredicate<T, U> origBiPredicate,
                               Deque<Span> spanStackForExecution,
                               Map<String, String> mdcContextMapForExecution) {
  return new BiPredicateWithTracing<>(origBiPredicate, spanStackForExecution, mdcContextMapForExecution);
}
origin: Nike-Inc/wingtips

/**
 * Equivalent to calling {@code new BiPredicateWithTracing(origBiPredicate, originalThreadInfo)} - this allows you
 * to do a static method import for cleaner looking code in some cases. This method uses the given trace and MDC
 * information, which will be associated with the thread when the given operation is executed.
 *
 * <p>The operation you pass in cannot be null (an {@link IllegalArgumentException} will be thrown if you pass in
 * null for the operation).
 *
 * <p>The {@link Pair} can be null, or you can pass null for the left and/or right side of the pair, and no error
 * will be thrown. Any trace or MDC info that is null means the corresponding info will not be available to the
 * thread when the operation is executed however.
 *
 * <p>You can pass in a {@link TracingState} for clearer less verbose code since it extends
 * {@code Pair<Deque<Span>, Map<String, String>>}.
 *
 * @return {@code new BiPredicateWithTracing(origBiPredicate, originalThreadInfo)}.
 * @see BiPredicateWithTracing#BiPredicateWithTracing(BiPredicate, Pair)
 * @see BiPredicateWithTracing
 */
public static <T, U> BiPredicateWithTracing<T, U> withTracing(
  BiPredicate<T, U> origBiPredicate,
  Pair<Deque<Span>, Map<String, String>> originalThreadInfo
) {
  return new BiPredicateWithTracing<>(origBiPredicate, originalThreadInfo);
}
origin: Nike-Inc/wingtips

@Test
public void constructors_throw_exception_if_passed_null_operator() {
  // given
  final Deque<Span> spanStackMock = mock(Deque.class);
  final Map<String, String> mdcInfoMock = mock(Map.class);
  // expect
  assertThat(catchThrowable(() -> new BiPredicateWithTracing(null)))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null)))
    .isInstanceOf(IllegalArgumentException.class);
  // and expect
  assertThat(catchThrowable(() -> new BiPredicateWithTracing(null, Pair.of(spanStackMock, mdcInfoMock))))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null, Pair.of(spanStackMock, mdcInfoMock))))
    .isInstanceOf(IllegalArgumentException.class);
  // and expect
  assertThat(catchThrowable(() -> new BiPredicateWithTracing(null, spanStackMock, mdcInfoMock)))
    .isInstanceOf(IllegalArgumentException.class);
  assertThat(catchThrowable(() -> withTracing(null, spanStackMock, mdcInfoMock)))
    .isInstanceOf(IllegalArgumentException.class);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void kitchen_sink_constructor_sets_fields_as_expected(boolean useStaticFactory) {
  // given
  Deque<Span> spanStackMock = mock(Deque.class);
  Map<String, String> mdcInfoMock = mock(Map.class);
  // when
  BiPredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(biPredicateMock, spanStackMock, mdcInfoMock)
                   : new BiPredicateWithTracing(biPredicateMock, spanStackMock, mdcInfoMock);
  // then
  assertThat(instance.origBiPredicate).isSameAs(biPredicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) {
  // when
  BiPredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(biPredicateMock, (Pair)null)
                   : new BiPredicateWithTracing(biPredicateMock, (Pair)null);
  // then
  assertThat(instance.origBiPredicate).isSameAs(biPredicateMock);
  assertThat(instance.spanStackForExecution).isNull();
  assertThat(instance.mdcContextMapForExecution).isNull();
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true   |   true    |   true",
  "true   |   false   |   true",
  "false  |   true    |   true",
  "false  |   false   |   true",
  "true   |   true    |   false",
  "true   |   false   |   false",
  "false  |   true    |   false",
  "false  |   false   |   false",
}, splitBy = "\\|")
@Test
public void pair_constructor_sets_fields_as_expected(
  boolean nullSpanStack, boolean nullMdcInfo, boolean useStaticFactory
) {
  // given
  Deque<Span> spanStackMock = (nullSpanStack) ? null : mock(Deque.class);
  Map<String, String> mdcInfoMock = (nullMdcInfo) ? null : mock(Map.class);
  // when
  BiPredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(biPredicateMock, Pair.of(spanStackMock, mdcInfoMock))
                   : new BiPredicateWithTracing(biPredicateMock, Pair.of(spanStackMock, mdcInfoMock)
                   );
  // then
  assertThat(instance.origBiPredicate).isSameAs(biPredicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
origin: Nike-Inc/wingtips

@DataProvider(value = {
  "true",
  "false"
})
@Test
public void current_thread_info_constructor_sets_fields_as_expected(boolean useStaticFactory) {
  // given
  Tracer.getInstance().startRequestWithRootSpan("request-" + UUID.randomUUID().toString());
  Deque<Span> spanStackMock = Tracer.getInstance().getCurrentSpanStackCopy();
  Map<String, String> mdcInfoMock = MDC.getCopyOfContextMap();
  // when
  BiPredicateWithTracing instance = (useStaticFactory)
                   ? withTracing(biPredicateMock)
                   : new BiPredicateWithTracing(biPredicateMock);
  // then
  assertThat(instance.origBiPredicate).isSameAs(biPredicateMock);
  assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock);
  assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock);
}
origin: Nike-Inc/wingtips

Deque<Span> spanStack = Tracer.getInstance().getCurrentSpanStackCopy();
Map<String, String> mdcInfo = MDC.getCopyOfContextMap();
BiPredicateWithTracing instance = new BiPredicateWithTracing(
  biPredicateMock, spanStack, mdcInfo
);
com.nike.wingtips.util.asynchelperwrapperBiPredicateWithTracing<init>

Javadoc

Constructor that extracts the current tracing and MDC information from the current thread using Tracer#getCurrentSpanStackCopy() and MDC#getCopyOfContextMap(), and forwards the information to the BiPredicateWithTracing#BiPredicateWithTracing(BiPredicate,Deque,Map)constructor. That tracing and MDC information will be associated with the thread when the given operation is executed.

The operation you pass in cannot be null (an IllegalArgumentException will be thrown if you pass in null for the operation).

Popular methods of BiPredicateWithTracing

  • test
  • withTracing
    Equivalent to calling new BiPredicateWithTracing(origBiPredicate, spanStackForExecution, mdcContextM

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now