Skip to content

Commit

Permalink
Add abstract build method to MetricSnapshot.Builder (#969)
Browse files Browse the repository at this point in the history
Signed-off-by: Mickael Maison <mickael.maison@gmail.com>
  • Loading branch information
mimaison authored Sep 7, 2024
1 parent b2db709 commit 8a24bde
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public Builder dataPoint(CounterDataPointSnapshot dataPoint) {
return this;
}

@Override
public CounterSnapshot build() {
return new CounterSnapshot(buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ private Builder() {
}

/**
* Add a data point. This can be alled multiple times to add multiple data points.
* Add a data point. This can be called multiple times to add multiple data points.
*/
public Builder dataPoint(GaugeDataPointSnapshot dataPoint) {
dataPoints.add(dataPoint);
return this;
}

@Override
public GaugeSnapshot build() {
return new GaugeSnapshot(buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public Builder gaugeHistogram(boolean isGaugeHistogram) {
return this;
}

@Override
public HistogramSnapshot build() {
return new HistogramSnapshot(isGaugeHistogram, buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Builder unit(Unit unit) {
throw new IllegalArgumentException("Info metric cannot have a unit.");
}

@Override
public InfoSnapshot build() {
return new InfoSnapshot(buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public T unit(Unit unit) {
return self();
}

public abstract MetricSnapshot build();

protected MetricMetadata buildMetadata() {
return new MetricMetadata(name, help, unit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public Builder unit(Unit unit) {
throw new IllegalArgumentException("StateSet metric cannot have a unit.");
}

@Override
public StateSetSnapshot build() {
return new StateSetSnapshot(buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public Builder dataPoint(SummaryDataPointSnapshot data) {
return this;
}

@Override
public SummarySnapshot build() {
return new SummarySnapshot(buildMetadata(), dataPoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public Builder dataPoint(UnknownDataPointSnapshot data) {
return this;
}

@Override
public UnknownSnapshot build() {
return new UnknownSnapshot(buildMetadata(), dataPoints);
}
Expand Down

0 comments on commit 8a24bde

Please sign in to comment.