Skip to content

Commit

Permalink
Working on building test asset (#4389)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasJazz committed Feb 11, 2024
1 parent db8ec73 commit 5a87234
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.opentelemetry.sdk.metrics.data;

import static java.util.Objects.requireNonNull;

import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.resources.Resource;

import static java.util.Objects.requireNonNull;

public abstract class DelegatingMetricData implements MetricData {

private final MetricData delegate;
Expand All @@ -17,6 +17,7 @@ protected DelegatingMetricData(MetricData delegate) {
public Resource getResource() {
return delegate.getResource();
}

@Override
public InstrumentationScopeInfo getInstrumentationScopeInfo() {
return delegate.getInstrumentationScopeInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package io.opentelemetry.sdk.testing.metrics;

import com.google.auto.value.AutoValue;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import io.opentelemetry.sdk.metrics.data.Data;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.data.MetricDataType;
import io.opentelemetry.sdk.resources.Resource;
import javax.annotation.concurrent.Immutable;

@Immutable
@AutoValue
public abstract class TestMetricData implements MetricData {
public static Builder builder() {
//TODO: Need to figure out how to set the Data value
return new AutoValue_TestMetricData.Builder()
.setResource(Resource.empty())
.setInstrumentationScopeInfo(InstrumentationScopeInfo.empty())
.setDescription("")
.setUnit("1")
.setType(MetricDataType.DOUBLE_GAUGE);
}

/** A builder for {@link TestMetricData}. */
@AutoValue.Builder
public abstract static class Builder {
abstract TestMetricData autoBuild();

/**
* Builds and returns a new {@link MetricData} instance from the data in {@code this}
*
* @return a new {@link MetricData} instance
*/
public TestMetricData build() {
return autoBuild();
}

/**
* Sets the resource of the metric
*
* @param resource the resource of the metric
* @return this
*/
public abstract Builder setResource(Resource resource);

/**
* Sets the name of the metric
*
* @param name the name of the metric
* @return this
*/
public abstract Builder setName(String name);

/**
* Sets the description of the metric
*
* @param description the description of the metric
* @return this
*/
public abstract Builder setDescription(String description);

/**
* Sets the unit of the metric
*
* @param unit the unit of the metric
* @return this
*/
public abstract Builder setUnit(String unit);

/**
* Sets the type of the metric
*
* @param type the type of the metric
* @return this
*/
public abstract Builder setType(MetricDataType type);

/**
* Sets the data of the metric
*
* @param data the data of the metric
* @return this
*/
public abstract Builder setData(Data<?> data);

/**
* Sets the Instrumentation scope of the metric
*
* @param instrumentationScopeInfo the instrumentation scope of the tracer which created this
* metric.
* @return this
*/
public abstract Builder setInstrumentationScopeInfo(
InstrumentationScopeInfo instrumentationScopeInfo);

}

}

0 comments on commit 5a87234

Please sign in to comment.