-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a new metric plugin called compound. This metric plugin contains a list of other metric plugins. Each time a metric is registered or unregistered in the compound registry, it is registered or unregistered in all other metric plugins. The metric plugins that are notified by the compound registry can be configured, but by default it notifies all other metric plugins in the classpath.
- Loading branch information
Showing
21 changed files
with
916 additions
and
5 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
pinot-plugins/pinot-metrics/pinot-compound-metrics/pom.xml
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,69 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you 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> | ||
<artifactId>pinot-metrics</artifactId> | ||
<groupId>org.apache.pinot</groupId> | ||
<version>1.3.0-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<artifactId>pinot-compound-metrics</artifactId> | ||
<name>Pinot Compound Metrics</name> | ||
<url>https://pinot.apache.org/</url> | ||
<properties> | ||
<pinot.root>${basedir}/../../..</pinot.root> | ||
<phase.prop>package</phase.prop> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.pinot</groupId> | ||
<artifactId>pinot-spi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.auto.service</groupId> | ||
<artifactId>auto-service-annotations</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
47 changes: 47 additions & 0 deletions
47
...s/src/main/java/org/apache/pinot/plugin/metrics/compound/AbstractCompoundPinotMetric.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,47 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import com.google.common.base.Preconditions; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.apache.pinot.spi.metrics.PinotMetric; | ||
|
||
|
||
public abstract class AbstractCompoundPinotMetric<M extends PinotMetric> implements PinotMetric { | ||
protected final List<M> _metrics; | ||
|
||
public AbstractCompoundPinotMetric(List<M> metrics) { | ||
Preconditions.checkArgument(!metrics.isEmpty(), "At least one meter is needed"); | ||
_metrics = metrics; | ||
} | ||
|
||
@Override | ||
public Object getMetric() { | ||
return _metrics.stream().map(PinotMetric::getMetric).collect(Collectors.toList()); | ||
} | ||
|
||
protected M getSomeMeter() { | ||
return _metrics.get(0); | ||
} | ||
|
||
public M getMeter(int index) { | ||
return _metrics.get(index); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...-metrics/src/main/java/org/apache/pinot/plugin/metrics/compound/CompoundPinotCounter.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,34 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import java.util.List; | ||
import org.apache.pinot.spi.metrics.PinotCounter; | ||
|
||
|
||
public class CompoundPinotCounter extends AbstractCompoundPinotMetric<PinotCounter> implements PinotCounter { | ||
public CompoundPinotCounter(List<PinotCounter> metrics) { | ||
super(metrics); | ||
} | ||
|
||
@Override | ||
public Object getCounter() { | ||
return getSomeMeter().getCounter(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...nd-metrics/src/main/java/org/apache/pinot/plugin/metrics/compound/CompoundPinotGauge.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,50 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
import org.apache.pinot.spi.metrics.PinotGauge; | ||
|
||
|
||
public class CompoundPinotGauge<T> extends AbstractCompoundPinotMetric<PinotGauge<T>> implements PinotGauge<T> { | ||
public CompoundPinotGauge(List<PinotGauge<T>> meters) { | ||
super(meters); | ||
} | ||
|
||
@Override | ||
public Object getGauge() { | ||
return getSomeMeter().getGauge(); | ||
} | ||
|
||
@Override | ||
public T value() { | ||
return getSomeMeter().value(); | ||
} | ||
|
||
@Override | ||
public void setValue(T value) { | ||
_metrics.forEach(m -> m.setValue(value)); | ||
} | ||
|
||
@Override | ||
public void setValueSupplier(Supplier<T> valueSupplier) { | ||
_metrics.forEach(m -> m.setValueSupplier(valueSupplier)); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...etrics/src/main/java/org/apache/pinot/plugin/metrics/compound/CompoundPinotHistogram.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,34 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import java.util.List; | ||
import org.apache.pinot.spi.metrics.PinotHistogram; | ||
|
||
|
||
public class CompoundPinotHistogram extends AbstractCompoundPinotMetric<PinotHistogram> implements PinotHistogram { | ||
public CompoundPinotHistogram(List<PinotHistogram> metrics) { | ||
super(metrics); | ||
} | ||
|
||
@Override | ||
public Object getHistogram() { | ||
return getMetric(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...rics/src/main/java/org/apache/pinot/plugin/metrics/compound/CompoundPinotJmxReporter.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,38 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import java.util.List; | ||
import org.apache.pinot.spi.metrics.PinotJmxReporter; | ||
|
||
|
||
public class CompoundPinotJmxReporter implements PinotJmxReporter { | ||
private final List<PinotJmxReporter> _reporters; | ||
|
||
public CompoundPinotJmxReporter(List<PinotJmxReporter> reporters) { | ||
_reporters = reporters; | ||
} | ||
|
||
@Override | ||
public void start() { | ||
for (PinotJmxReporter reporter : _reporters) { | ||
reporter.start(); | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...nd-metrics/src/main/java/org/apache/pinot/plugin/metrics/compound/CompoundPinotMeter.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,84 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.apache.pinot.plugin.metrics.compound; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.pinot.spi.metrics.PinotMeter; | ||
|
||
|
||
public class CompoundPinotMeter extends AbstractCompoundPinotMetric<PinotMeter> implements PinotMeter { | ||
public CompoundPinotMeter(List<PinotMeter> meters) { | ||
super(meters); | ||
} | ||
|
||
@Override | ||
public void mark() { | ||
for (PinotMeter meter : _metrics) { | ||
meter.mark(); | ||
} | ||
} | ||
|
||
@Override | ||
public void mark(long unitCount) { | ||
for (PinotMeter meter : _metrics) { | ||
meter.mark(unitCount); | ||
} | ||
} | ||
|
||
@Override | ||
public long count() { | ||
return getSomeMeter().count(); | ||
} | ||
|
||
@Override | ||
public Object getMetered() { | ||
return getSomeMeter().getMetered(); | ||
} | ||
|
||
@Override | ||
public TimeUnit rateUnit() { | ||
return getSomeMeter().rateUnit(); | ||
} | ||
|
||
@Override | ||
public String eventType() { | ||
return getSomeMeter().eventType(); | ||
} | ||
|
||
@Override | ||
public double fifteenMinuteRate() { | ||
return getSomeMeter().fifteenMinuteRate(); | ||
} | ||
|
||
@Override | ||
public double fiveMinuteRate() { | ||
return getSomeMeter().fiveMinuteRate(); | ||
} | ||
|
||
@Override | ||
public double meanRate() { | ||
return getSomeMeter().meanRate(); | ||
} | ||
|
||
@Override | ||
public double oneMinuteRate() { | ||
return getSomeMeter().oneMinuteRate(); | ||
} | ||
} |
Oops, something went wrong.