/** * * * <pre> * Optional. The `bucket_options` are required when the logs-based metric is * using a DISTRIBUTION value type and it describes the bucket boundaries * used to create a histogram of the extracted values. * </pre> * * <code>.google.api.Distribution.BucketOptions bucket_options = 8;</code> */ public Builder mergeBucketOptions(com.google.api.Distribution.BucketOptions value) { if (bucketOptionsBuilder_ == null) { if (bucketOptions_ != null) { bucketOptions_ = com.google.api.Distribution.BucketOptions.newBuilder(bucketOptions_) .mergeFrom(value) .buildPartial(); } else { bucketOptions_ = value; } onChanged(); } else { bucketOptionsBuilder_.mergeFrom(value); } return this; } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.logging.v2.LogMetric)) { return super.equals(obj); } com.google.logging.v2.LogMetric other = (com.google.logging.v2.LogMetric) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getDescription().equals(other.getDescription()); result = result && getFilter().equals(other.getFilter()); result = result && (hasMetricDescriptor() == other.hasMetricDescriptor()); if (hasMetricDescriptor()) { result = result && getMetricDescriptor().equals(other.getMetricDescriptor()); } result = result && getValueExtractor().equals(other.getValueExtractor()); result = result && internalGetLabelExtractors().equals(other.internalGetLabelExtractors()); result = result && (hasBucketOptions() == other.hasBucketOptions()); if (hasBucketOptions()) { result = result && getBucketOptions().equals(other.getBucketOptions()); } result = result && version_ == other.version_; result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * Optional. The `bucket_options` are required when the logs-based metric is * using a DISTRIBUTION value type and it describes the bucket boundaries * used to create a histogram of the extracted values. * </pre> * * <code>.google.api.Distribution.BucketOptions bucket_options = 8;</code> */ public com.google.api.Distribution.BucketOptionsOrBuilder getBucketOptionsOrBuilder() { if (bucketOptionsBuilder_ != null) { return bucketOptionsBuilder_.getMessageOrBuilder(); } else { return bucketOptions_ == null ? com.google.api.Distribution.BucketOptions.getDefaultInstance() : bucketOptions_; } } /**
com.google.api.Distribution.BucketOptions.Builder subBuilder = null; if (bucketOptions_ != null) { subBuilder = bucketOptions_.toBuilder(); bucketOptions_ = input.readMessage(com.google.api.Distribution.BucketOptions.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(bucketOptions_);
.setMean(timeDomain ? snapshot.mean(getBaseTimeUnit()) : snapshot.mean()) .setCount(snapshot.count()) .setBucketOptions(Distribution.BucketOptions.newBuilder() .setExplicitBuckets(Distribution.BucketOptions.Explicit.newBuilder() .addAllBounds(bucketBoundaries)
if (hasBucketOptions()) { result = result && getBucketOptions() .equals(other.getBucketOptions());
hash = (53 * hash) + getBucketOptions().hashCode();
/** * <pre> * Defines the histogram bucket boundaries. * </pre> * * <code>.google.api.Distribution.BucketOptions bucket_options = 6;</code> */ public Builder mergeBucketOptions(com.google.api.Distribution.BucketOptions value) { if (bucketOptionsBuilder_ == null) { if (bucketOptions_ != null) { bucketOptions_ = com.google.api.Distribution.BucketOptions.newBuilder(bucketOptions_).mergeFrom(value).buildPartial(); } else { bucketOptions_ = value; } onChanged(); } else { bucketOptionsBuilder_.mergeFrom(value); } return this; } /**
public Builder mergeFrom(com.google.api.Distribution.BucketOptions other) { if (other == com.google.api.Distribution.BucketOptions.getDefaultInstance()) return this; switch (other.getOptionsCase()) { case LINEAR_BUCKETS: { mergeLinearBuckets(other.getLinearBuckets()); break; } case EXPONENTIAL_BUCKETS: { mergeExponentialBuckets(other.getExponentialBuckets()); break; } case EXPLICIT_BUCKETS: { mergeExplicitBuckets(other.getExplicitBuckets()); break; } case OPTIONS_NOT_SET: { break; } } onChanged(); return this; }
@Test public void createTimeSeriesList_Distribution() { List<TimeSeries> timeSeriesList = StackdriverExportUtils.createTimeSeriesList( DISTRIBUTION_METRIC, DEFAULT_RESOURCE, CUSTOM_OPENCENSUS_DOMAIN); assertThat(timeSeriesList.size()).isEqualTo(1); TimeSeries timeSeries = timeSeriesList.get(0); assertThat(timeSeries.getPointsCount()).isEqualTo(1); assertThat(timeSeries.getPoints(0).getValue().getDistributionValue()) .isEqualTo( com.google.api.Distribution.newBuilder() .setCount(3) .setMean(0.6666666666666666) .setBucketOptions( BucketOptions.newBuilder() .setExplicitBuckets( Explicit.newBuilder() .addAllBounds(Arrays.asList(0.0, 1.0, 3.0, 5.0)) .build()) .build()) .addAllBucketCounts(Arrays.asList(0L, 3L, 1L, 2L, 4L)) .setSumOfSquaredDeviation(14) .build()); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
/** * <pre> * Defines the histogram bucket boundaries. * </pre> * * <code>.google.api.Distribution.BucketOptions bucket_options = 6;</code> */ public com.google.api.Distribution.BucketOptions getBucketOptions() { if (bucketOptionsBuilder_ == null) { return bucketOptions_ == null ? com.google.api.Distribution.BucketOptions.getDefaultInstance() : bucketOptions_; } else { return bucketOptionsBuilder_.getMessage(); } } /**
public com.google.api.Distribution.BucketOptions getDefaultInstanceForType() { return com.google.api.Distribution.BucketOptions.getDefaultInstance(); }
/** * <pre> * Defines the histogram bucket boundaries. * </pre> * * <code>.google.api.Distribution.BucketOptions bucket_options = 6;</code> */ public com.google.api.Distribution.BucketOptionsOrBuilder getBucketOptionsOrBuilder() { if (bucketOptionsBuilder_ != null) { return bucketOptionsBuilder_.getMessageOrBuilder(); } else { return bucketOptions_ == null ? com.google.api.Distribution.BucketOptions.getDefaultInstance() : bucketOptions_; } } /**
private Stream<TimeSeries> createFunctionTimer(Batch batch, FunctionTimer timer) { long count = (long) timer.count(); Distribution.Builder distribution = Distribution.newBuilder() .setMean(timer.mean(getBaseTimeUnit())) .setCount(count) .setBucketOptions(Distribution.BucketOptions.newBuilder() .setExplicitBuckets(Distribution.BucketOptions.Explicit.newBuilder() .addBounds(0.0) .build())) .addBucketCounts(0) .addBucketCounts(count); return Stream.of(batch.createTimeSeries(timer, distribution.build())); }
public static Builder newBuilder(com.google.api.Distribution.BucketOptions prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() {
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(com.google.api.Distribution.BucketOptions prototype) {
@Override public BucketOptions apply(ExplicitOptions arg) { BucketOptions.Builder builder = BucketOptions.newBuilder(); Explicit.Builder explicitBuilder = Explicit.newBuilder(); // The first bucket bound should be 0.0 because the Metrics first bucket is // [0, first_bound) but Stackdriver monitoring bucket bounds begin with -infinity // (first bucket is (-infinity, 0)) explicitBuilder.addBounds(0.0); explicitBuilder.addAllBounds(arg.getBucketBoundaries()); builder.setExplicitBuckets(explicitBuilder.build()); return builder.build(); } };
@Test public void createBucketOptions_Null() { assertThat(StackdriverExportUtils.createBucketOptions(null)) .isEqualTo(BucketOptions.newBuilder().build()); }
@Test public void createBucketOptions() { assertThat(StackdriverExportUtils.createBucketOptions(BUCKET_OPTIONS)) .isEqualTo( BucketOptions.newBuilder() .setExplicitBuckets( Explicit.newBuilder().addAllBounds(Arrays.asList(0.0, 1.0, 3.0, 5.0))) .build()); }