-
Notifications
You must be signed in to change notification settings - Fork 172
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 #194 from brharrington/composite
allow adding and removing from the composite
- Loading branch information
Showing
11 changed files
with
302 additions
and
171 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
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
65 changes: 65 additions & 0 deletions
65
spectator-api/src/main/java/com/netflix/spectator/api/RegistryMeter.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,65 @@ | ||
/** | ||
* Copyright 2015 Netflix, 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. | ||
*/ | ||
package com.netflix.spectator.api; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
/** | ||
* Wraps a registry as a meter that can be added to another registry. This is currently used to | ||
* manage the gauges for the composite registry. Since there is no activity gauges should get | ||
* polled and must get tracked as a group and added to each sub-registry. | ||
*/ | ||
class RegistryMeter implements Meter { | ||
|
||
private final Id id; | ||
private final Registry registry; | ||
|
||
/** Create a new instance. */ | ||
RegistryMeter(Id id) { | ||
this(id, new DefaultRegistry()); | ||
} | ||
|
||
/** Create a new instance. */ | ||
RegistryMeter(Id id, Registry registry) { | ||
this.id = id; | ||
this.registry = registry; | ||
} | ||
|
||
/** Register a meter with the wrapped registry. */ | ||
void register(Meter meter) { | ||
registry.register(meter); | ||
} | ||
|
||
@Override public Id id() { | ||
return id; | ||
} | ||
|
||
@Override public Iterable<Measurement> measure() { | ||
List<Measurement> ms = new ArrayList<>(); | ||
for (Meter m : registry) { | ||
for (Measurement measurement : m.measure()) { | ||
ms.add(measurement); | ||
} | ||
} | ||
return ms; | ||
} | ||
|
||
@Override public boolean hasExpired() { | ||
return false; | ||
} | ||
} |
Oops, something went wrong.