本文整理了Java中io.opencensus.common.Duration.toMillis()
方法的一些代码示例,展示了Duration.toMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.toMillis()
方法的具体详情如下:
包路径:io.opencensus.common.Duration
类名称:Duration
方法名:toMillis
[英]Converts a Duration to milliseconds.
[中]将持续时间转换为毫秒。
代码示例来源:origin: census-instrumentation/opencensus-java
OcAgentMetricsExporterWorker(
String endPoint,
boolean useInsecure,
Duration exportInterval,
Duration retryInterval,
String serviceName,
MetricProducerManager metricProducerManager) {
this.endPoint = endPoint;
this.useInsecure = useInsecure;
this.exportIntervalMillis = exportInterval.toMillis();
this.retryIntervalMillis = retryInterval.toMillis();
this.serviceName = serviceName;
this.metricProducerManager = metricProducerManager;
}
代码示例来源:origin: census-instrumentation/opencensus-java
private Worker(int bufferSize, Duration scheduleDelay) {
spans = new ArrayList<RecordEventsSpanImpl>(bufferSize);
this.bufferSize = bufferSize;
this.scheduleDelayMillis = scheduleDelay.toMillis();
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
private Worker(int bufferSize, Duration scheduleDelay) {
spans = new ArrayList<RecordEventsSpanImpl>(bufferSize);
this.bufferSize = bufferSize;
this.scheduleDelayMillis = scheduleDelay.toMillis();
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
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();
}
代码示例来源:origin: census-instrumentation/opencensus-java
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();
}
代码示例来源:origin: census-instrumentation/opencensus-java
private void refreshBucketList(Timestamp now) {
if (buckets.size() != N + 1) {
throw new AssertionError("Bucket list must have exactly " + (N + 1) + " buckets.");
}
Timestamp startOfLastBucket =
CheckerFrameworkUtils.castNonNull(buckets.peekLast()).getStart();
// TODO(songya): decide what to do when time goes backwards
checkArgument(
now.compareTo(startOfLastBucket) >= 0,
"Current time must be within or after the last bucket.");
long elapsedTimeMillis = now.subtractTimestamp(startOfLastBucket).toMillis();
long numOfPadBuckets = elapsedTimeMillis / bucketDuration.toMillis();
shiftBucketList(numOfPadBuckets, now);
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
private void refreshBucketList(Timestamp now) {
if (buckets.size() != N + 1) {
throw new AssertionError("Bucket list must have exactly " + (N + 1) + " buckets.");
}
Timestamp startOfLastBucket =
CheckerFrameworkUtils.castNonNull(buckets.peekLast()).getStart();
// TODO(songya): decide what to do when time goes backwards
checkArgument(
now.compareTo(startOfLastBucket) >= 0,
"Current time must be within or after the last bucket.");
long elapsedTimeMillis = now.subtractTimestamp(startOfLastBucket).toMillis();
long numOfPadBuckets = elapsedTimeMillis / bucketDuration.toMillis();
shiftBucketList(numOfPadBuckets, now);
}
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* 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")));
}
代码示例来源:origin: io.opencensus/opencensus-exporter-metrics-util
/**
* 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")));
}
代码示例来源:origin: census-instrumentation/opencensus-java
private IntervalMutableViewData(View view, Timestamp start) {
super(view);
Duration totalDuration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration();
this.totalDuration = totalDuration;
this.bucketDuration = Duration.fromMillis(totalDuration.toMillis() / N);
// When initializing. add N empty buckets prior to the start timestamp of this
// IntervalMutableViewData, so that the last bucket will be the current one in effect.
shiftBucketList(N + 1, start);
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
private IntervalMutableViewData(View view, Timestamp start) {
super(view);
Duration totalDuration = ((View.AggregationWindow.Interval) view.getWindow()).getDuration();
this.totalDuration = totalDuration;
this.bucketDuration = Duration.fromMillis(totalDuration.toMillis() / N);
// When initializing. add N empty buckets prior to the start timestamp of this
// IntervalMutableViewData, so that the last bucket will be the current one in effect.
shiftBucketList(N + 1, start);
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void toMillis() {
assertThat(Duration.create(10, 0).toMillis()).isEqualTo(10000L);
assertThat(Duration.create(10, 1000).toMillis()).isEqualTo(10000L);
assertThat(Duration.create(0, (int) 1e6).toMillis()).isEqualTo(1L);
assertThat(Duration.create(0, 0).toMillis()).isEqualTo(0L);
assertThat(Duration.create(-10, 0).toMillis()).isEqualTo(-10000L);
assertThat(Duration.create(-10, -1000).toMillis()).isEqualTo(-10000L);
assertThat(Duration.create(0, -(int) 1e6).toMillis()).isEqualTo(-1L);
}
}
内容来源于网络,如有侵权,请联系作者删除!