Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions java-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>java-lib</artifactId>
<version>2022-10.2-SNAPSHOT</version>
<version>proxy-new-SNAPSHOT</version>

<parent>
<groupId>com.wavefront</groupId>
<artifactId>javalib</artifactId>
<version>2022-10.2-SNAPSHOT</version>
<version>proxy-new-SNAPSHOT</version>
</parent>

<name>Wavefront Shared Java Library</name>
Expand Down Expand Up @@ -117,11 +117,11 @@
<scope>test</scope>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -250,4 +250,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
12 changes: 8 additions & 4 deletions java-lib/src/main/java/com/wavefront/api/EventAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.wavefront.dto.Event;

import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
Expand All @@ -25,4 +22,11 @@ public interface EventAPI {
@Path("v2/wfproxy/event")
Response proxyEvents(@HeaderParam("X-WF-PROXY-ID") final UUID proxyId,
final List<Event> eventBatch);

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@Path("v2/wfproxy/event")
Response proxyEventsString(@HeaderParam("X-WF-PROXY-ID") final UUID proxyId,
final String eventBatch);
}
11 changes: 7 additions & 4 deletions java-lib/src/main/java/com/wavefront/api/LogAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.wavefront.dto.Log;

import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
Expand All @@ -23,4 +20,10 @@ public interface LogAPI {
@Consumes(MediaType.APPLICATION_JSON)
@Path("le-mans/v1/streams/ingestion-pipeline-stream")
Response proxyLogs(@HeaderParam("agent") final String agentProxyId, final List<Log> logBatch);

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
@Path("le-mans/v1/streams/ingestion-pipeline-stream")
Response proxyLogsStr(@HeaderParam("agent") final String agentProxyId, final String logBatch);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.SortedMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.Nullable;
import javax.annotation.RegEx;

import static com.wavefront.common.MetricsToTimeseries.sanitize;

Expand Down Expand Up @@ -146,24 +149,19 @@ private static void writeBuildMetrics(ResourceBundle props, JsonGenerator json,
}

static int extractVersion(String versionStr) {
int version = 0;
String[] components = versionStr.split("\\.");
for (int i = 0; i < Math.min(3, components.length); i++) {
String component = components[i];
if (StringUtils.isNotBlank(component) && StringUtils.isNumeric(component)) {
version *= 1000; // we'll assume this will fit. 3.123.0 will become 3123000.
version += Integer.valueOf(component);
} else {
version = 0; // not actually a convertable name (probably something with SNAPSHOT).
break;
final String regex = "^(\\d*)\\.(\\d*)\\.?(\\d*)?";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(versionStr);

int x = 0, y = 0, z = 0;
if (matcher.find()) {
x = Integer.valueOf(matcher.group(1));
y = Integer.valueOf(matcher.group(2));
if (!matcher.group(3).equals("")) {
z = Integer.valueOf(matcher.group(3));
}
}
if (components.length == 2) {
version *= 1000;
} else if (components.length == 1) {
version *= 1000000; // make sure 3 outputs 3000000
}
return version;
return (x * 1_000_000 + y * 1_000 + z);
}

private static void mergeMapIntoJson(JsonGenerator jsonGenerator, Map<String, Double> metrics) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.atomic.AtomicLong;

import static com.google.common.truth.Truth.assertThat;
import static com.wavefront.metrics.JsonMetricsGenerator.extractVersion;

/**
* Basic unit tests around {@link JsonMetricsGenerator}
Expand Down Expand Up @@ -278,4 +279,15 @@ public void testWavefrontHistogramBulkUpdateHandlesNullParams() throws IOExcepti

assertThat(json).isEqualTo("{\"test.metric\":{\"bins\":[]}}");
}

@Test
public void testExtractVersion(){
assertThat(extractVersion("12.1")).isEqualTo(12_001_000);
assertThat(extractVersion("12.1.0")).isEqualTo(12_001_000);
assertThat(extractVersion("12.1.1")).isEqualTo(12_001_001);
assertThat(extractVersion("12.1-SNAPSHOT")).isEqualTo(12_001_000);
assertThat(extractVersion("12.1.0-SNAPSHOT")).isEqualTo(12_001_000);
assertThat(extractVersion("12")).isEqualTo(0);
assertThat(extractVersion("SNAPSHOT")).isEqualTo(0);
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.wavefront</groupId>
<artifactId>javalib</artifactId>
<version>2022-10.2-SNAPSHOT</version>
<version>proxy-new-SNAPSHOT</version>
<modules>
<module>java-lib</module>
<module>yammer-metrics</module>
Expand Down Expand Up @@ -378,4 +378,4 @@
</build>
</profile>
</profiles>
</project>
</project>
6 changes: 3 additions & 3 deletions yammer-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<parent>
<artifactId>javalib</artifactId>
<groupId>com.wavefront</groupId>
<version>2022-10.2-SNAPSHOT</version>
<version>proxy-new-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>yammer-metrics</artifactId>
<version>2022-10.2-SNAPSHOT</version>
<version>proxy-new-SNAPSHOT</version>
<name>Wavefront Yammer Metrics</name>
<dependencies>
<dependency>
Expand Down Expand Up @@ -94,4 +94,4 @@
</plugins>
</build>

</project>
</project>