Skip to content

Commit

Permalink
add coverage check (#1162)
Browse files Browse the repository at this point in the history
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
  • Loading branch information
zeitlinger authored Oct 18, 2024
1 parent f8e61b6 commit 28b4048
Show file tree
Hide file tree
Showing 14 changed files with 387 additions and 13 deletions.
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ This repository uses [Google Java Format](https://github.com/google/google-java-

Run `./mvnw spotless:apply` to format the code (only changed files) before committing.

Use `-Dspotless.check.skip=true` to skip the formatting check during development.

## Running Tests

If you're getting errors when running tests:

- Make sure that the IDE uses only the "Maven Shade" dependency of "prometheus-metrics-exposition-formats" and the "prometheus-metrics-tracer*" dependencies.


### Avoid failures while running tests

- Use `-Dspotless.check.skip=true` to skip the formatting check during development.
- Use `-Dcoverage.skip=true` to skip the coverage check during development.
- Use `-Dwarnings=-nowarn` to skip the warnings during development.

## Updating the Protobuf Java Classes

Use `PROTO_GENERATION=true mvn clean install` to generate protobuf classes.
2 changes: 1 addition & 1 deletion benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<jmh.version>1.37</jmh.version>
<simpleclient.version>0.16.0</simpleclient.version>
<codahale.version>3.0.2</codahale.version>
<jacoco.line-coverage>0.0</jacoco.line-coverage>
<coverage.skip>true</coverage.skip>
</properties>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</description>

<properties>
<jacoco.line-coverage>0.0</jacoco.line-coverage>
<coverage.skip>true</coverage.skip>
</properties>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</description>

<properties>
<jacoco.line-coverage>0.0</jacoco.line-coverage>
<coverage.skip>true</coverage.skip>
</properties>

<modules>
Expand Down
7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<otel.instrumentation.version>2.8.0-alpha</otel.instrumentation.version>
<java.version>8</java.version>
<jacoco.line-coverage>0.70</jacoco.line-coverage>
<coverage.skip>false</coverage.skip>
<warnings>-Werror</warnings>
</properties>

<licenses>
Expand Down Expand Up @@ -227,6 +229,7 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<configuration>
<skip>${coverage.skip}</skip>
<excludes>
<exclude>**/generated/**</exclude>
</excludes>
Expand Down Expand Up @@ -309,8 +312,8 @@
<target>${java.version}</target>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:all,-serial,-processing</arg>
<arg>-Werror</arg>
<arg>-Xlint:all,-serial,-processing,-options</arg>
<arg>${warnings}</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>
-Xplugin:ErrorProne
Expand Down
7 changes: 5 additions & 2 deletions prometheus-metrics-exporter-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

<properties>
<automatic.module.name>io.prometheus.metrics.exporter.opentelemetry</automatic.module.name>
<!-- todo: add tests -->
<jacoco.line-coverage>0.0</jacoco.line-coverage>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -96,6 +94,11 @@
<version>1.7.1-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;
import java.util.stream.Collectors;

@SuppressWarnings("this-escape")
public class PrometheusInfo extends PrometheusData<DoublePointData>
implements SumData<DoublePointData> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private String getNameWithoutUnit(MetricMetadata metricMetadata) {

// See
// https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/6cf4dec6cb42d87d8840e9f67d4acf66d4eb8fda/pkg/translator/prometheus/normalize_name.go#L19
private String convertUnit(Unit unit) {
static String convertUnit(Unit unit) {
if (unit == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class PrometheusStateSet extends PrometheusData<DoublePointData>

private final List<DoublePointData> points;

@SuppressWarnings("this-escape")
public PrometheusStateSet(StateSetSnapshot snapshot, long currentTimeMillis) {
super(MetricDataType.DOUBLE_SUM);
this.points = new ArrayList<>();
Expand Down
Loading

0 comments on commit 28b4048

Please sign in to comment.