Search in sources :

Example 1 with Duration

use of io.opencensus.common.Duration in project instrumentation-java by census-instrumentation.

the class SignalFxStatsConfigurationTest method buildWithFields.

@Test
public void buildWithFields() throws URISyntaxException {
    URI url = new URI("http://example.com");
    Duration duration = Duration.create(5, 0);
    SignalFxStatsConfiguration configuration = SignalFxStatsConfiguration.builder().setToken(TEST_TOKEN).setIngestEndpoint(url).setExportInterval(duration).build();
    assertEquals(TEST_TOKEN, configuration.getToken());
    assertEquals(url, configuration.getIngestEndpoint());
    assertEquals(duration, configuration.getExportInterval());
}
Also used : Duration(io.opencensus.common.Duration) URI(java.net.URI) Test(org.junit.Test)

Example 2 with Duration

use of io.opencensus.common.Duration in project instrumentation-java by census-instrumentation.

the class OcAgentMetricsExporterConfigurationTest method setAndGet.

@Test
public void setAndGet() throws SSLException {
    Duration oneMinute = Duration.create(60, 0);
    Duration fiveMinutes = Duration.create(300, 0);
    SslContext sslContext = SslContextBuilder.forClient().build();
    OcAgentMetricsExporterConfiguration configuration = OcAgentMetricsExporterConfiguration.builder().setEndPoint("192.168.0.1:50051").setServiceName("service").setUseInsecure(false).setSslContext(sslContext).setRetryInterval(fiveMinutes).setExportInterval(oneMinute).build();
    assertThat(configuration.getEndPoint()).isEqualTo("192.168.0.1:50051");
    assertThat(configuration.getServiceName()).isEqualTo("service");
    assertThat(configuration.getUseInsecure()).isFalse();
    assertThat(configuration.getSslContext()).isEqualTo(sslContext);
    assertThat(configuration.getRetryInterval()).isEqualTo(fiveMinutes);
    assertThat(configuration.getExportInterval()).isEqualTo(oneMinute);
}
Also used : Duration(io.opencensus.common.Duration) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Example 3 with Duration

use of io.opencensus.common.Duration in project instrumentation-java by census-instrumentation.

the class IntervalMetricReader method create.

/**
 * Creates a new {@link IntervalMetricReader}.
 *
 * @param metricExporter the {@link MetricExporter} to be called after.
 * @param metricReader the {@link MetricReader} to be used to read metrics.
 * @param options the {@link Options} for the new {@link IntervalMetricReader}.
 * @return a new {@link IntervalMetricReader}.
 * @since 0.19
 */
public static IntervalMetricReader create(MetricExporter metricExporter, MetricReader metricReader, Options options) {
    checkNotNull(options, "options");
    Duration exportInterval = checkNotNull(options.getExportInterval(), "exportInterval");
    checkArgument(exportInterval.compareTo(ZERO) > 0, "Export interval must be positive");
    return new IntervalMetricReader(new Worker(checkNotNull(metricExporter, "metricExporter"), exportInterval.toMillis(), checkNotNull(metricReader, "metricReader")));
}
Also used : Duration(io.opencensus.common.Duration)

Example 4 with Duration

use of io.opencensus.common.Duration in project instrumentation-java by census-instrumentation.

the class IntervalBucket method getFraction.

/*
   * Returns how much fraction of duration has passed in this IntervalBucket. For example, if this
   * bucket starts at 10s and has a duration of 20s, and now is 15s, then getFraction() should
   * return (15 - 10) / 20 = 0.25.
   *
   * This IntervalBucket must be current, i.e. the current timestamp must be within
   * [this.start, this.start + this.duration).
   */
double getFraction(Timestamp now) {
    Duration elapsedTime = now.subtractTimestamp(start);
    checkArgument(elapsedTime.compareTo(ZERO) >= 0 && elapsedTime.compareTo(duration) < 0, "This bucket must be current.");
    return ((double) elapsedTime.toMillis()) / duration.toMillis();
}
Also used : Duration(io.opencensus.common.Duration)

Example 5 with Duration

use of io.opencensus.common.Duration in project instrumentation-java by census-instrumentation.

the class OcAgentTraceExporterConfigurationTest method setAndGet.

@Test
public void setAndGet() throws SSLException {
    Duration oneMinute = Duration.create(60, 0);
    SslContext sslContext = SslContextBuilder.forClient().build();
    OcAgentTraceExporterConfiguration configuration = OcAgentTraceExporterConfiguration.builder().setEndPoint("192.168.0.1:50051").setServiceName("service").setUseInsecure(false).setSslContext(sslContext).setRetryInterval(oneMinute).setEnableConfig(false).setDeadline(oneMinute).build();
    assertThat(configuration.getEndPoint()).isEqualTo("192.168.0.1:50051");
    assertThat(configuration.getServiceName()).isEqualTo("service");
    assertThat(configuration.getUseInsecure()).isFalse();
    assertThat(configuration.getSslContext()).isEqualTo(sslContext);
    assertThat(configuration.getRetryInterval()).isEqualTo(oneMinute);
    assertThat(configuration.getEnableConfig()).isFalse();
    assertThat(configuration.getDeadline()).isEqualTo(oneMinute);
}
Also used : Duration(io.opencensus.common.Duration) SslContext(io.netty.handler.ssl.SslContext) Test(org.junit.Test)

Aggregations

Duration (io.opencensus.common.Duration)5 Test (org.junit.Test)3 SslContext (io.netty.handler.ssl.SslContext)2 URI (java.net.URI)1