Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for micrometer #10

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
72 changes: 72 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!--
Copyright 2017 Agilx, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ai.apptuit</groupId>
<artifactId>metrics-apptuit</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>metrics-apptuit-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>metrics-apptuit-client</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<version>${jacoco.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@

package ai.apptuit.metrics.client;

import java.io.*;
import static ai.apptuit.metrics.client.Sanitizer.DEFAULT_SANITIZER;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -28,7 +36,6 @@
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;

import static ai.apptuit.metrics.client.Sanitizer.DEFAULT_SANITIZER;

/**
* @author Rajiv Shivane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.junit.Assert.assertEquals;

import ai.apptuit.metrics.client.ApptuitPutClient.DatapointsHttpEntity;
import ai.apptuit.metrics.dropwizard.TagEncodedMetricName;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
Expand Down Expand Up @@ -56,8 +55,9 @@ public class ApptuitPutClientTest {

private static MockServer httpServer;

private TagEncodedMetricName tagEncodedMetricName;
private HashMap<String, String> globalTags;
private String metricName;
private HashMap<String, String> tags;

private static String streamToString(InputStream inputStream) throws IOException {
return new Scanner(new GZIPInputStream(inputStream)).useDelimiter("\0").next();
Expand All @@ -76,8 +76,9 @@ public static void tearDownClass() throws Exception {

@Before
public void setUp() throws Exception {
tagEncodedMetricName = TagEncodedMetricName.decode("proc.stat.cpu")
.withTags("type", "idle");
metricName = "proc.stat.cpu";
tags = new HashMap<>();
tags.put("type", "idle");

globalTags = new HashMap<>();
globalTags.put("host", "rajiv");
Expand Down Expand Up @@ -173,8 +174,8 @@ private ArrayList<DataPoint> createDataPoints(int numDataPoints) {
for (int i = 0; i < numDataPoints; i++) {
long value = 99 + i;
long epoch = System.currentTimeMillis() / 1000 - value;
DataPoint dataPoint = new DataPoint(tagEncodedMetricName.getMetricName(), epoch, value,
tagEncodedMetricName.getTags());
DataPoint dataPoint = new DataPoint(metricName, epoch, value,
tags);
dataPoints.add(dataPoint);
}
return dataPoints;
Expand Down
Loading