|
| 1 | +package io.opentelemetry.sdk.testing.metrics; |
| 2 | + |
| 3 | +import com.google.auto.value.AutoValue; |
| 4 | +import io.opentelemetry.sdk.common.InstrumentationScopeInfo; |
| 5 | +import io.opentelemetry.sdk.metrics.data.Data; |
| 6 | +import io.opentelemetry.sdk.metrics.data.MetricData; |
| 7 | +import io.opentelemetry.sdk.metrics.data.MetricDataType; |
| 8 | +import io.opentelemetry.sdk.resources.Resource; |
| 9 | +import javax.annotation.concurrent.Immutable; |
| 10 | + |
| 11 | +@Immutable |
| 12 | +@AutoValue |
| 13 | +public abstract class TestMetricData implements MetricData { |
| 14 | + public static Builder builder() { |
| 15 | + //TODO: Need to figure out how to set the Data value |
| 16 | + return new AutoValue_TestMetricData.Builder() |
| 17 | + .setResource(Resource.empty()) |
| 18 | + .setInstrumentationScopeInfo(InstrumentationScopeInfo.empty()) |
| 19 | + .setDescription("") |
| 20 | + .setUnit("1") |
| 21 | + .setType(MetricDataType.DOUBLE_GAUGE); |
| 22 | + } |
| 23 | + |
| 24 | + /** A builder for {@link TestMetricData}. */ |
| 25 | + @AutoValue.Builder |
| 26 | + public abstract static class Builder { |
| 27 | + abstract TestMetricData autoBuild(); |
| 28 | + |
| 29 | + /** |
| 30 | + * Builds and returns a new {@link MetricData} instance from the data in {@code this} |
| 31 | + * |
| 32 | + * @return a new {@link MetricData} instance |
| 33 | + */ |
| 34 | + public TestMetricData build() { |
| 35 | + return autoBuild(); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Sets the resource of the metric |
| 40 | + * |
| 41 | + * @param resource the resource of the metric |
| 42 | + * @return this |
| 43 | + */ |
| 44 | + public abstract Builder setResource(Resource resource); |
| 45 | + |
| 46 | + /** |
| 47 | + * Sets the name of the metric |
| 48 | + * |
| 49 | + * @param name the name of the metric |
| 50 | + * @return this |
| 51 | + */ |
| 52 | + public abstract Builder setName(String name); |
| 53 | + |
| 54 | + /** |
| 55 | + * Sets the description of the metric |
| 56 | + * |
| 57 | + * @param description the description of the metric |
| 58 | + * @return this |
| 59 | + */ |
| 60 | + public abstract Builder setDescription(String description); |
| 61 | + |
| 62 | + /** |
| 63 | + * Sets the unit of the metric |
| 64 | + * |
| 65 | + * @param unit the unit of the metric |
| 66 | + * @return this |
| 67 | + */ |
| 68 | + public abstract Builder setUnit(String unit); |
| 69 | + |
| 70 | + /** |
| 71 | + * Sets the type of the metric |
| 72 | + * |
| 73 | + * @param type the type of the metric |
| 74 | + * @return this |
| 75 | + */ |
| 76 | + public abstract Builder setType(MetricDataType type); |
| 77 | + |
| 78 | + /** |
| 79 | + * Sets the data of the metric |
| 80 | + * |
| 81 | + * @param data the data of the metric |
| 82 | + * @return this |
| 83 | + */ |
| 84 | + public abstract Builder setData(Data<?> data); |
| 85 | + |
| 86 | + /** |
| 87 | + * Sets the Instrumentation scope of the metric |
| 88 | + * |
| 89 | + * @param instrumentationScopeInfo the instrumentation scope of the tracer which created this |
| 90 | + * metric. |
| 91 | + * @return this |
| 92 | + */ |
| 93 | + public abstract Builder setInstrumentationScopeInfo( |
| 94 | + InstrumentationScopeInfo instrumentationScopeInfo); |
| 95 | + |
| 96 | + } |
| 97 | + |
| 98 | +} |
0 commit comments