Skip to content

Commit

Permalink
Merge pull request #298 from brharrington/tagset-search
Browse files Browse the repository at this point in the history
restrict search to used portion of array
  • Loading branch information
brharrington committed Apr 29, 2016
2 parents 4d76790 + 59dc2a8 commit 44f2cc7
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To instrument your code you need to depend on the api library. This provides the
for you to code against and build test cases. The only dependency is slf4j.

```
com.netflix.spectator:spectator-api:0.38.0
com.netflix.spectator:spectator-api:0.38.1
```

If running at Netflix with the standard platform, see the
Expand Down
2 changes: 1 addition & 1 deletion docs/ext/jvm-gc.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to 7u40. For G1 it is recommended to be on the latest version available.
### Dependencies

```
com.netflix.spectator:spectator-ext-gc:0.38.0
com.netflix.spectator:spectator-ext-gc:0.38.1
```

### Start Reporting
Expand Down
2 changes: 1 addition & 1 deletion docs/ext/log4j2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ log messages reported.
To use it simply add a dependency:

```
com.netflix.spectator:spectator-ext-log4j2:0.38.0
com.netflix.spectator:spectator-ext-log4j2:0.38.1
```

Then in your application initialization:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ you are new to the library it is highly recommended to read the pages in the
At a minimum you will need to:

1. Depend on the api library. It is in maven central, for gradle the dependency
would be `com.netflix.spectator:spectator-api:0.38.0`.
would be `com.netflix.spectator:spectator-api:0.38.1`.
2. Instrument some code, see the usage guides for [counters](intro/counter.md),
[timers](intro/timer.md), and [gauges](intro/gauge.md).
3. Pick a registry to bind to when initializing the application. See the sidebar
Expand Down
4 changes: 2 additions & 2 deletions docs/intro/netflix.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ section for the type of project you are working on:
For libraries, the only dependency that should be needed is:

```
com.netflix.spectator:spectator-api:0.38.0
com.netflix.spectator:spectator-api:0.38.1
```

The bindings to integrate internally should be included with the application. In your code,
Expand Down Expand Up @@ -80,7 +80,7 @@ If you are only interested in getting the GC logging, there is a library with an
singleton that can be used:

```
com.netflix.spectator:spectator-nflx:0.38.0
com.netflix.spectator:spectator-nflx:0.38.1
```

Assuming you are using karyon/base-server or governator with `com.netflix` in the list of base
Expand Down
2 changes: 1 addition & 1 deletion docs/registry/metrics3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ underlying implementation. To use the metrics registry, add a dependency on the
`spectator-reg-metrics3` library. For gradle:

```
com.netflix.spectator:spectator-reg-metrics3:0.38.0
com.netflix.spectator:spectator-reg-metrics3:0.38.1
```

Then when initializing the application, use the `MetricsRegistry`. For more
Expand Down
2 changes: 1 addition & 1 deletion docs/registry/servo.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ implementation. To use the servo registry, add a dependency on the
`spectator-reg-servo` library. For gradle:

```
com.netflix.spectator:spectator-reg-servo:0.38.0
com.netflix.spectator:spectator-reg-servo:0.38.1
```

Then when initializing the application, use the `ServoRegistry`. If using guice
Expand Down
2 changes: 1 addition & 1 deletion docs/registry/tdigest.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assume it is being used [internally at Netflix](Netflix-Integration).
To use it simply add a dependency:

```
com.netflix.spectator:spectator-reg-tdigest:0.38.0
com.netflix.spectator:spectator-reg-tdigest:0.38.1
```

Add the `TDigestModule` to the set of modules used with guice:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ArrayTagSet add(String k, String v) {
/** Add a new tag to the set. */
ArrayTagSet add(Tag tag) {
Tag[] newTags;
int pos = Arrays.binarySearch(tags, tag, TAG_COMPARATOR);
int pos = Arrays.binarySearch(tags, 0, length, tag, TAG_COMPARATOR);
if (pos < 0) {
// Not found in list
newTags = new Tag[length + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,24 @@ public void testMergeMultipleValuesAsMap() {
ArrayTagSet actual = initial.addAll(extra);
Assert.assertEquals(expected, actual);
}

@Test
public void addAllTagArrayEmpty() {
ArrayTagSet ts = ArrayTagSet.EMPTY.addAll(new Tag[0]);
Assert.assertSame(ArrayTagSet.EMPTY, ts);
}

@Test
public void addAllStringArrayEmpty() {
ArrayTagSet ts = ArrayTagSet.EMPTY.addAll(new String[0]);
Assert.assertSame(ArrayTagSet.EMPTY, ts);
}

@Test
public void addAllIterable() {
// Add an arbitrary iterable that isn't a collection or ArrayTagSet
Collection<Tag> tags = Collections.singletonList(new BasicTag("app", "foo"));
ArrayTagSet ts = ArrayTagSet.EMPTY.addAll(tags::iterator);
Assert.assertEquals(ArrayTagSet.EMPTY.addAll(tags), ts);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,38 @@ public void testWithTagsMap() {
DefaultId id = (new DefaultId("foo")).withTags(map);
Assert.assertEquals("foo:k1=v1:k2=v2", id.toString());
}

@Test
public void addTagAppend() {
Id id = new DefaultId("TotalTime")
.withTag("app", "foo")
.withTag("exception.thrown", "pvr");
Assert.assertEquals("TotalTime:app=foo:exception.thrown=pvr", id.toString());
}

@Test
public void addTagPrepend() {
Id id = new DefaultId("TotalTime")
.withTag("app", "foo")
.withTag("aaa", "pvr");
Assert.assertEquals("TotalTime:aaa=pvr:app=foo", id.toString());
}

@Test
public void addTagInsert() {
Id id = new DefaultId("TotalTime")
.withTag("app", "foo")
.withTag("exception.thrown", "pvr")
.withTag("bbb", "bar");
Assert.assertEquals("TotalTime:app=foo:bbb=bar:exception.thrown=pvr", id.toString());
}

@Test
public void dedupAndAppend() {
Id id = new DefaultId("TotalTime")
.withTag("app", "foo")
.withTags("app", "foo")
.withTag("exception.thrown", "pvr");
Assert.assertEquals("TotalTime:app=foo:exception.thrown=pvr", id.toString());
}
}

0 comments on commit 44f2cc7

Please sign in to comment.