Skip to content

Commit 5880c4f

Browse files
committed
Working on building test asset (open-telemetry#4389)
1 parent 98b2546 commit 5880c4f

File tree

2 files changed

+101
-2
lines changed

2 files changed

+101
-2
lines changed

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/data/DelegatingMetricData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.opentelemetry.sdk.metrics.data;
22

3+
import static java.util.Objects.requireNonNull;
4+
35
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
46
import io.opentelemetry.sdk.resources.Resource;
57

6-
import static java.util.Objects.requireNonNull;
7-
88
public abstract class DelegatingMetricData implements MetricData {
99

1010
private final MetricData delegate;
@@ -17,6 +17,7 @@ protected DelegatingMetricData(MetricData delegate) {
1717
public Resource getResource() {
1818
return delegate.getResource();
1919
}
20+
2021
@Override
2122
public InstrumentationScopeInfo getInstrumentationScopeInfo() {
2223
return delegate.getInstrumentationScopeInfo();
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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

Comments
 (0)