Skip to content

Commit

Permalink
Merge branch 'main' into ftorres/utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
fedetorres93 committed Jan 9, 2025
2 parents 7939aba + 7d091a7 commit b5260be
Show file tree
Hide file tree
Showing 46 changed files with 1,027 additions and 990 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updates:
# excluding simpleclient_archive from the update is not possible, only includes are supported
# when we use includes, we run into https://github.com/dependabot/dependabot-core/issues/10415 -
# even if we limit to 1 PR at a time
# therefore we just ignore the simpleclient_archive update for now
# therefore we just rename pom.xml in simpleclient_archive for now
# if this becomes a problem, we can move to renovate
directory: "/"
schedule:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: docker-compose.log
name: OATS logs
path: oats/yaml/build/**/*.log
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
java temurin-17.0.13+11
protoc 29.1
protoc 29.2
2 changes: 0 additions & 2 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<!-- this doesn't seem to be compatible with google auto-format
<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="2"/>
Expand All @@ -264,7 +263,6 @@
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
-->
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.google.common.io.Resources;
import io.prometheus.client.it.common.ExporterTest;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URLEncoder;
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/it-spring-boot-smoke-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.0</version>
<version>3.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -77,7 +77,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<version>2.44.1</version>
<configuration>
<java>
<googleJavaFormat/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.prometheus.client.it.common.ExporterTest;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import java.io.IOException;
import java.net.URL;
import java.util.List;
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<automatic.module.name>--module-name-need-to-be-overriden--</automatic.module.name>
<junit-jupiter.version>5.11.4</junit-jupiter.version>
<otel.instrumentation.version>2.10.0-alpha</otel.instrumentation.version>
<otel.instrumentation.version>2.11.0-alpha</otel.instrumentation.version>
<java.version>8</java.version>
<jacoco.line-coverage>0.70</jacoco.line-coverage>
<checkstyle.skip>false</checkstyle.skip>
Expand Down Expand Up @@ -116,13 +116,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.14.2</version>
<version>5.15.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
<version>3.27.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -223,7 +223,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<version>2.44.1</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
5 changes: 5 additions & 0 deletions prometheus-metrics-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<artifactId>prometheus-metrics-exposition-formats</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-instrumentation-dropwizard</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>prometheus-metrics-instrumentation-dropwizard5</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SlidingWindow<T> {
private int currentBucket;
private long lastRotateTimestampMillis;
private final long durationBetweenRotatesMillis;
LongSupplier currentTimeMillis = System::currentTimeMillis; // to be replaced in unit tests
private final LongSupplier currentTimeMillis;

/**
* Example: If the {@code maxAgeSeconds} is 60 and {@code ageBuckets} is 3, then 3 instances of
Expand All @@ -39,13 +39,24 @@ public class SlidingWindow<T> {
* @param maxAgeSeconds after this amount of time an instance of T gets evicted.
* @param ageBuckets number of age buckets.
*/
@SuppressWarnings("unchecked")
public SlidingWindow(
Class<T> clazz,
Supplier<T> constructor,
ObjDoubleConsumer<T> observeFunction,
long maxAgeSeconds,
int ageBuckets) {
this(clazz, constructor, observeFunction, maxAgeSeconds, ageBuckets, System::currentTimeMillis);
}

// VisibleForTesting
@SuppressWarnings("unchecked")
SlidingWindow(
Class<T> clazz,
Supplier<T> constructor,
ObjDoubleConsumer<T> observeFunction,
long maxAgeSeconds,
int ageBuckets,
LongSupplier currentTimeMillis) {
this.constructor = constructor;
this.observeFunction = observeFunction;
this.ringBuffer = (T[]) Array.newInstance(clazz, ageBuckets);
Expand All @@ -55,6 +66,7 @@ public SlidingWindow(
this.currentBucket = 0;
this.lastRotateTimestampMillis = currentTimeMillis.getAsLong();
this.durationBetweenRotatesMillis = TimeUnit.SECONDS.toMillis(maxAgeSeconds) / ageBuckets;
this.currentTimeMillis = currentTimeMillis;
}

/** Get the currently active instance of {@code T}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static org.assertj.core.data.Offset.offset;

import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfigTestUtil;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import io.prometheus.metrics.expositionformats.internal.PrometheusProtobufWriterImpl;
import io.prometheus.metrics.expositionformats.internal.ProtobufUtil;
import io.prometheus.metrics.model.snapshots.CounterSnapshot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.prometheus.metrics.core.datapoints.DistributionDataPoint;
import io.prometheus.metrics.core.exemplars.ExemplarSamplerConfigTestUtil;
import io.prometheus.metrics.expositionformats.OpenMetricsTextFormatWriter;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import io.prometheus.metrics.expositionformats.internal.PrometheusProtobufWriterImpl;
import io.prometheus.metrics.expositionformats.internal.ProtobufUtil;
import io.prometheus.metrics.model.snapshots.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import io.prometheus.metrics.expositionformats.OpenMetricsTextFormatWriter;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_1.Metrics;
import io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_29_2.Metrics;
import io.prometheus.metrics.expositionformats.internal.PrometheusProtobufWriterImpl;
import io.prometheus.metrics.expositionformats.internal.ProtobufUtil;
import io.prometheus.metrics.model.snapshots.EscapingScheme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ public void setUp() {
currentTimeMillis.set(startTime);
ringBuffer =
new SlidingWindow<>(
Observer.class, Observer::new, Observer::observe, maxAgeSeconds, ageBuckets);
ringBuffer.currentTimeMillis = currentTimeMillis::get;
Observer.class,
Observer::new,
Observer::observe,
maxAgeSeconds,
ageBuckets,
currentTimeMillis::get);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static String convertUnit(Unit unit) {
return null;
}
switch (unit.toString()) {
// Time
// Time
case "days":
return "d";
case "hours":
Expand All @@ -68,7 +68,7 @@ static String convertUnit(Unit unit) {
return "us";
case "nanoseconds":
return "ns";
// Bytes
// Bytes
case "bytes":
return "By";
case "kibibytes":
Expand All @@ -87,7 +87,7 @@ static String convertUnit(Unit unit) {
return "GBy";
case "terabytes":
return "TBy";
// SI
// SI
case "meters":
return "m";
case "volts":
Expand All @@ -100,14 +100,14 @@ static String convertUnit(Unit unit) {
return "W";
case "grams":
return "g";
// Misc
// Misc
case "celsius":
return "Cel";
case "hertz":
return "Hz";
case "percent":
return "%";
// default
// default
default:
return unit.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion prometheus-metrics-exposition-formats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<properties>
<automatic.module.name>io.prometheus.metrics.expositionformats</automatic.module.name>
<protobuf-java.version>4.29.1</protobuf-java.version>
<protobuf-java.version>4.29.2</protobuf-java.version>
</properties>

<dependencies>
Expand Down
Loading

0 comments on commit b5260be

Please sign in to comment.