-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from manolama/tweaks
Add validation around null tag strings and drop the measurements with a
- Loading branch information
Showing
14 changed files
with
275 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2020, Oath Inc. | ||
// Licensed under the terms of the Apache License 2.0 license. See LICENSE file in Ultrabrew Metrics | ||
// for terms. | ||
package io.ultrabrew.metrics.util; | ||
|
||
public class Strings { | ||
|
||
///CLOVER:OFF | ||
private Strings() { | ||
// static class | ||
} | ||
///CLOVER:ON | ||
|
||
/** | ||
* Whether or not the string is empty or null. | ||
* @param s A string to test. | ||
* @return True if the string is empty or null, false if not. | ||
*/ | ||
public static boolean isNullOrEmpty(String s) { | ||
return s == null || s.isEmpty(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
core/src/test/java/io/ultrabrew/metrics/util/StringsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2020, Oath Inc. | ||
// Licensed under the terms of the Apache License 2.0 license. See LICENSE file in Ultrabrew Metrics | ||
// for terms. | ||
package io.ultrabrew.metrics.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class StringsTest { | ||
|
||
@Test | ||
public void testIsNullOrEmpty() { | ||
assertTrue(Strings.isNullOrEmpty(null)); | ||
assertTrue(Strings.isNullOrEmpty("")); | ||
assertFalse(Strings.isNullOrEmpty("foo")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# InfluxReporter | ||
|
||
This reporter will push batches of metrics to an InfluxDB V1x HTTP API server as JSON object. Note that a database name must be included. | ||
|
||
Configuration parameters include: | ||
|
||
* **baseUri** - *(required)* A hostname including protocol, host and optional port. E.g. `http://localhost:4242`. Note that the host must start with a protocol of either `http://` or `https://`. | ||
* **endpoint** - *(Default: `/write?db=`)* A string with the endpoint to post results to. Note that the endpoint must start with a forward slash and can be `/?db=`. If this parameter is set then the `database` parameter will be ignored and must be supplied as a query parameter in the endpoint string. | ||
* **database** - *(required)* A string denoting the InfluxDB database to send measurements to. | ||
* **bufferSize** - *(Default: `64 * 1024`)* The maximum size of the buffer before it's flushed. | ||
* **windowSize** - (Default: `1`) How often to report to the API in seconds. | ||
|
||
To instantiate and run the reporter execute: | ||
|
||
```Java | ||
InfluxDBReporter.Builder reporter_builder = | ||
InfluxDBReporter.builder() | ||
.withBaseUri(URI.create("http://localhost:4242"))) | ||
.withDatabase("Ultrabrew") | ||
.withWindowSize(60); | ||
|
||
InfluxDBReporter reporter = reporter_builder.build(); | ||
MetricRegistry metricRegistry = new MetricRegistry(); | ||
metric_registry.addReporter(reporter); | ||
|
||
// on program shutdown | ||
reporter.close(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dependencies { | ||
compile project(':core') | ||
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6' | ||
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dependencies { | ||
compile project(':core') | ||
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6' | ||
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' | ||
} |
Oops, something went wrong.