Tabnine Logo
Span$Builder.withDurationNanos
Code IndexAdd Tabnine to your IDE (free)

How to use
withDurationNanos
method
in
com.nike.wingtips.Span$Builder

Best Java code snippets using com.nike.wingtips.Span$Builder.withDurationNanos (Showing top 9 results out of 315)

origin: Nike-Inc/wingtips

.withParentSpanId(badParentSpanId)
.withSpanStartTimeEpochMicros(Math.abs(random.nextLong()))
.withDurationNanos(Math.abs(random.nextLong()))
.build();
origin: Nike-Inc/wingtips

@UseDataProvider("idSanitizationScenarios")
@Test
public void convertWingtipsSpanToZipkinSpan_sanitizes_parentSpanId_as_expected_when_sanitization_is_enabled(
  IdSanitizationScenario scenario
) {
  // given
  impl = new WingtipsToZipkinSpanConverterDefaultImpl(true);
  final Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  final Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
                 .withParentSpanId(scenario.originalId)
                 .withSpanStartTimeEpochMicros(Math.abs(random.nextLong()))
                 .withDurationNanos(Math.abs(random.nextLong()))
                 .build();
  // when
  zipkin2.Span zipkinSpan = impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint);
  // then
  assertThat(zipkinSpan.parentId()).isEqualTo(scenario.expectedSanitizedResultForSpanIdOrParentSpanId);
  assertThat(zipkinSpan.tags().get("invalid.parent_id")).isEqualTo(scenario.originalId);
}
origin: Nike-Inc/wingtips

@UseDataProvider("idSanitizationScenarios")
@Test
public void convertWingtipsSpanToZipkinSpan_sanitizes_traceId_as_expected_when_sanitization_is_enabled(
  IdSanitizationScenario scenario
) {
  // given
  impl = new WingtipsToZipkinSpanConverterDefaultImpl(true);
  final Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  final Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
      .withTraceId(scenario.originalId)
      .withSpanStartTimeEpochMicros(Math.abs(random.nextLong()))
      .withDurationNanos(Math.abs(random.nextLong()))
      .build();
  String expectedZipkinInvalidIdTagValue = (scenario.expectedSanitizedResultForTraceId.equals(scenario.originalId))
                       ? null
                       : scenario.originalId;
  // when
  zipkin2.Span zipkinSpan = impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint);
  // then
  assertThat(zipkinSpan.traceId()).isEqualTo(scenario.expectedSanitizedResultForTraceId);
  assertThat(zipkinSpan.tags().get("invalid.trace_id")).isEqualTo(expectedZipkinInvalidIdTagValue);
}
origin: Nike-Inc/wingtips

.withSpanStartTimeEpochMicros(startTimeEpochMicrosForFullyCompleteSpan)
.withSpanStartTimeNanos(startTimeNanosForFullyCompleteSpan)
.withDurationNanos(durationNanosForFullyCompletedSpan)
.withTags(tags)
.withTag(extraTagKey, extraTagValue)
origin: Nike-Inc/wingtips

@DataProvider(value = {
    "   \t\n\r   ",
    ""
}, splitBy = "\\|")
@Test
@SuppressWarnings("UnnecessaryLocalVariable")
public void convertWingtipsSpanToZipkinSpan_throws_IllegalArgumentException_when_passed_wingtipsSpan_with_empty_traceId_format(
  final String emptyString
) {
  // given
  String emptyTraceId = emptyString;
  long startTimeEpochMicros = Math.abs(random.nextLong());
  long durationNanos = Math.abs(random.nextLong());
  final Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  final Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
      .withTraceId(emptyTraceId)
      .withSpanStartTimeEpochMicros(startTimeEpochMicros)
      .withDurationNanos(durationNanos)
      .build();
  // when
  Throwable ex = catchThrowable(() -> impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint));
  // then
  assertThat(ex)
    .isInstanceOf(IllegalArgumentException.class)
    .hasMessage("traceId is empty");
}
origin: Nike-Inc/wingtips

@UseDataProvider("idSanitizationScenarios")
@Test
public void convertWingtipsSpanToZipkinSpan_does_not_sanitize_ids_if_enableIdSanitization_is_false(
  IdSanitizationScenario scenario
) {
  // given
  impl = new WingtipsToZipkinSpanConverterDefaultImpl(false);
  final Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  final Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
                 .withTraceId(scenario.originalId)
                 .withSpanId(scenario.originalId)
                 .withSpanStartTimeEpochMicros(Math.abs(random.nextLong()))
                 .withDurationNanos(Math.abs(random.nextLong()))
                 .build();
  String expectedExceptionMessageSuffix = (scenario.originalId.length() > 16)
                      ? "id.length > 16"
                      : "should be lower-hex encoded with no prefix";
  // when
  Throwable ex = catchThrowable(() -> impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint));
  // then
  assertThat(ex)
    .isInstanceOf(IllegalArgumentException.class)
    .hasMessageEndingWith(expectedExceptionMessageSuffix);
}
origin: Nike-Inc/wingtips

@Test
@SuppressWarnings("UnnecessaryLocalVariable")
public void convertWingtipsSpanToZipkinSpan_works_as_expected_for_128_bit_trace_id() {
  // given
  String high64Bits = "463ac35c9f6413ad";
  String low64Bits = "48485a3953bb6124";
  String traceId128Bits = high64Bits + low64Bits;
  long startTimeEpochMicros = Math.abs(random.nextLong());
  long durationNanos = Math.abs(random.nextLong());
  Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
              .withTraceId(traceId128Bits)
              .withSpanStartTimeEpochMicros(startTimeEpochMicros)
              .withDurationNanos(durationNanos)
              .build();
  // when
  zipkin2.Span zipkinSpan = impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint);
  // then
  assertThat(zipkinSpan.traceId()).isEqualTo(traceId128Bits);
}

origin: Nike-Inc/wingtips

@UseDataProvider("idSanitizationScenarios")
@Test
public void convertWingtipsSpanToZipkinSpan_sanitizes_spanId_as_expected_when_sanitization_is_enabled(
  IdSanitizationScenario scenario
) {
  // given
  impl = new WingtipsToZipkinSpanConverterDefaultImpl(true);
  final Endpoint zipkinEndpoint = Endpoint.newBuilder().serviceName(UUID.randomUUID().toString()).build();
  final Span wingtipsSpan = Span.newBuilder("foo", SpanPurpose.CLIENT)
                 .withSpanId(scenario.originalId)
                 .withSpanStartTimeEpochMicros(Math.abs(random.nextLong()))
                 .withDurationNanos(Math.abs(random.nextLong()))
                 .build();
  // when
  zipkin2.Span zipkinSpan = impl.convertWingtipsSpanToZipkinSpan(wingtipsSpan, zipkinEndpoint);
  // then
  assertThat(zipkinSpan.id()).isEqualTo(scenario.expectedSanitizedResultForSpanIdOrParentSpanId);
  assertThat(zipkinSpan.tags().get("invalid.span_id")).isEqualTo(scenario.originalId);
}
origin: Nike-Inc/wingtips

/**
 * @param spanName The {@link Span#getSpanName()} to use for the new child sub-span.
 * @param spanPurpose The {@link SpanPurpose} for the new child span. See the javadocs for {@link SpanPurpose} for full details on what each enum option
 *                    means. If you pass in null for this then {@link SpanPurpose#UNKNOWN} will be used.
 * @return A new uncompleted span representing a child of this instance. The returned instance's {@link #getParentSpanId()} will be this instance's
 *          {@link #getSpanId()}, its {@link #getSpanName()} will be the given value, its {@link #getSpanId()} will be randomly generated, and its
 *          {@link #getSpanStartTimeEpochMicros()} and {@link #getSpanStartTimeNanos()} values will be set to the appropriate values based on when this
 *          method is called. It will share this instance's {@link #getTraceId()}, {@link #isSampleable()}, and {@link #getUserId()} values.
 */
public Span generateChildSpan(String spanName, SpanPurpose spanPurpose) {
  return Span.newBuilder(spanName, spanPurpose)
        .withTraceId(this.getTraceId())
        .withSampleable(this.isSampleable())
        .withUserId(this.getUserId())
        .withParentSpanId(this.getSpanId())
        .withSpanId(TraceAndSpanIdGenerator.generateId())
        .withSpanStartTimeEpochMicros(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()))
        .withSpanStartTimeNanos(System.nanoTime())
        .withDurationNanos(null)
        .build();
}
com.nike.wingtipsSpan$BuilderwithDurationNanos

Javadoc

Sets the duration of the span in nanoseconds, or null if this Span should not be considered Span#isCompleted() yet.

NOTE: Under most circumstances you will want this to be null (which is the default) since there are not many use cases where you need to create an already-completed Span.

Popular methods of Span$Builder

  • build
    Returns a Span built from the parameters set via the various with*(...) methods on this builder inst
  • withParentSpanId
    Sets the ID of the span that spawned this span instance (the logical "parent" of this span), or pass
  • withSampleable
    Set this to true if this span is sampleable and should be output to the logging/span collection syst
  • withUserId
    Sets the ID of the user logically associated with this span, or pass in null if no such user ID exis
  • withTraceId
    Sets the The ID associated with the overall distributed trace - a.k.a. the trace tree ID. All spans
  • withSpanId
    Sets the ID for this span of work in the distributed trace. Don't confuse this with #withTraceId(Str
  • withSpanStartTimeEpochMicros
    Sets the start timestamp in microseconds since the epoch for this span (*not* milliseconds), or pas
  • withSpanStartTimeNanos
    TLDR; Passing in null (or not calling this method at all) is always a safe option - when in doubt le
  • <init>
  • withSpanName
    Sets the human-readable name for this span. This should never be null - if you set this to null and
  • withSpanPurpose
    Sets the SpanPurpose for this span. See the javadocs on that class for details on what each enum opt
  • withTag
    Sets the value of a tag for the respective key. This will replace an existing tag value for the resp
  • withSpanPurpose,
  • withTag,
  • withTags,
  • withTimestampedAnnotation,
  • withTimestampedAnnotations

Popular in Java

  • Reading from database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • JOptionPane (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top 12 Jupyter Notebook extensions
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