-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pre-release' into 'master'
Add threads, logs etc. See merge request openhab/prometheus-metrics!2
- Loading branch information
Showing
38 changed files
with
864 additions
and
385 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
Binary file added
BIN
+366 KB
com.kuguhome.openhab.prometheusmetrics.target/bundles/pax-logging-api-1.10.1.jar
Binary file not shown.
Binary file added
BIN
+1.38 MB
com.kuguhome.openhab.prometheusmetrics.target/bundles/pax-logging-log4j2-1.10.1.jar
Binary file not shown.
Binary file added
BIN
+802 KB
com.kuguhome.openhab.prometheusmetrics.target/bundles/pax-logging-service-1.10.1.jar
Binary file not shown.
Binary file added
BIN
+16.8 KB
com.kuguhome.openhab.prometheusmetrics.target/bundles/simpleclient_hotspot-0.4.0.jar
Binary file not shown.
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
8 changes: 8 additions & 0 deletions
8
...theusmetrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.api.DefaultMetricManager.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.api.DefaultMetricManager"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.DefaultMetricManager"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.MetricManager"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.api.DefaultMetricManager"/> | ||
</scr:component> |
9 changes: 9 additions & 0 deletions
9
...eusmetrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.InboxCountMetric.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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.exposable.InboxCountMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.InboxCountMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
</service> | ||
<reference bind="setInbox" cardinality="1..1" interface="org.eclipse.smarthome.config.discovery.inbox.Inbox" name="Inbox" policy="dynamic" unbind="unsetInbox"/> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.InboxCountMetric"/> | ||
</scr:component> |
8 changes: 8 additions & 0 deletions
8
...metheusmetrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.LoggerMetric.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.kuguhome.openhab.prometheusmetrics.exposable.LoggerMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.LoggerMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.LoggerMetric"/> | ||
</scr:component> |
8 changes: 8 additions & 0 deletions
8
...cs/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABBundleStateMetric.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABBundleStateMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABBundleStateMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABBundleStateMetric"/> | ||
</scr:component> |
9 changes: 9 additions & 0 deletions
9
...ics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABThingStateMetric.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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABThingStateMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABThingStateMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
</service> | ||
<reference bind="setThingRegistry" cardinality="1..1" interface="org.eclipse.smarthome.core.thing.ThingRegistry" name="ThingRegistry" policy="dynamic" unbind="unsetThingRegistry"/> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABThingStateMetric"/> | ||
</scr:component> |
9 changes: 9 additions & 0 deletions
9
...s/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.SmarthomeEventCountMetric.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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.exposable.SmarthomeEventCountMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.SmarthomeEventCountMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
<provide interface="org.eclipse.smarthome.core.events.EventSubscriber"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.SmarthomeEventCountMetric"/> | ||
</scr:component> |
9 changes: 9 additions & 0 deletions
9
...eusmetrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.exposable.ThreadPoolMetric.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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.exposable.ThreadPoolMetric"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.exposable.ThreadPoolMetric"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.api.RESTExposable"/> | ||
</service> | ||
<reference cardinality="1..1" field="threadPoolManager" interface="com.kuguhome.openhab.prometheusmetrics.internal.KuguThreadPoolManager" name="threadPoolManager"/> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.exposable.ThreadPoolMetric"/> | ||
</scr:component> |
7 changes: 7 additions & 0 deletions
7
...ometheusmetrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.internal.KuguAppender.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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" name="com.kuguhome.openhab.prometheusmetrics.internal.KuguAppender"> | ||
<service> | ||
<provide interface="org.ops4j.pax.logging.spi.PaxAppender"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.internal.KuguAppender"/> | ||
</scr:component> |
8 changes: 8 additions & 0 deletions
8
...etrics/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.internal.KuguThreadPoolManager.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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.kuguhome.openhab.prometheusmetrics.internal.KuguThreadPoolManager"> | ||
<service> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.internal.KuguThreadPoolManager"/> | ||
<provide interface="org.eclipse.smarthome.core.common.ThreadPoolManager"/> | ||
</service> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.internal.KuguThreadPoolManager"/> | ||
</scr:component> |
8 changes: 0 additions & 8 deletions
8
...I-INF/com.kuguhome.openhab.prometheusmetrics.internal.PrometheusMetricsHandlerFactory.xml
This file was deleted.
Oops, something went wrong.
15 changes: 8 additions & 7 deletions
15
...cs/OSGI-INF/com.kuguhome.openhab.prometheusmetrics.rest.PrometheusMetricsRESTResource.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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.rest.PrometheusMetricsRESTResource"> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="activate" deactivate="deactivate" name="com.kuguhome.openhab.prometheusmetrics.rest.PrometheusMetricsRESTResource"> | ||
<service> | ||
<provide interface="org.eclipse.smarthome.core.events.EventSubscriber"/> | ||
<provide interface="org.osgi.service.event.EventHandler"/> | ||
<provide interface="org.eclipse.smarthome.io.rest.RESTResource"/> | ||
<provide interface="com.kuguhome.openhab.prometheusmetrics.rest.PrometheusMetricsRESTResource"/> | ||
</service> | ||
<reference bind="setEventSubscriber" interface="org.eclipse.smarthome.core.events.EventSubscriber" name="EventSubscriber"/> | ||
<reference bind="setHttpService" interface="org.osgi.service.http.HttpService" name="HttpService" unbind="unsetHttpService"/> | ||
<reference bind="setInbox" cardinality="0..1" interface="org.eclipse.smarthome.config.discovery.inbox.Inbox" name="Inbox" policy="dynamic" unbind="unsetInbox"/> | ||
<reference bind="setThingRegistry" interface="org.eclipse.smarthome.core.thing.ThingRegistry" name="ThingRegistry" unbind="unsetThingRegistry"/> | ||
<reference cardinality="1..1" field="httpService" interface="org.osgi.service.http.HttpService" name="httpService"/> | ||
<reference cardinality="1..1" field="inboxCountMetric" interface="com.kuguhome.openhab.prometheusmetrics.exposable.InboxCountMetric" name="inboxCountMetric" policy="dynamic"/> | ||
<reference cardinality="1..1" field="metricManager" interface="com.kuguhome.openhab.prometheusmetrics.api.DefaultMetricManager" name="metricManager"/> | ||
<reference cardinality="1..1" field="openHABBundleStateMetric" interface="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABBundleStateMetric" name="openHABBundleStateMetric" policy="dynamic"/> | ||
<reference cardinality="1..1" field="openHABThingStateMetric" interface="com.kuguhome.openhab.prometheusmetrics.exposable.OpenHABThingStateMetric" name="openHABThingStateMetric" policy="dynamic"/> | ||
<reference cardinality="1..1" field="smarthomeEventCountMetric" interface="com.kuguhome.openhab.prometheusmetrics.exposable.SmarthomeEventCountMetric" name="smarthomeEventCountMetric" policy="dynamic"/> | ||
<reference cardinality="1..1" field="threadPoolMetric" interface="com.kuguhome.openhab.prometheusmetrics.exposable.ThreadPoolMetric" name="threadPoolMetric" policy="dynamic"/> | ||
<implementation class="com.kuguhome.openhab.prometheusmetrics.rest.PrometheusMetricsRESTResource"/> | ||
</scr:component> |
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,17 @@ | ||
#!/bin/bash | ||
cd .. | ||
mvn clean | ||
cd com.kuguhome.openhab.prometheusmetrics.p2site/ | ||
mvn p2:site | ||
cd .. | ||
mvn install | ||
cd com.kuguhome.openhab.prometheusmetrics/ | ||
echo "Copying artifact to Raspberry Pi..." | ||
scp target/*.jar kugu-sz-roman:/usr/share/openhab2/addons | ||
echo "Deploying artifact to Raspberry Pi..." | ||
ssh kugu-sz-roman sudo systemctl restart openhab2 | ||
echo "Waiting till application being started..." | ||
sleep 30s | ||
sleep 60s | ||
echo "Fetching Rasberry Pi endpoint $1" | ||
curl $1 |
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
47 changes: 47 additions & 0 deletions
47
...etrics/src/main/java/com/kuguhome/openhab/prometheusmetrics/api/DefaultMetricManager.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 @@ | ||
package com.kuguhome.openhab.prometheusmetrics.api; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Deactivate; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This class describes the default implementation of MetricManager | ||
* | ||
* @author Roman Malyugin | ||
* | ||
*/ | ||
|
||
@Component(service = { DefaultMetricManager.class, MetricManager.class }) | ||
public class DefaultMetricManager implements MetricManager { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(DefaultMetricManager.class); | ||
|
||
private List<RESTExposable> exposables = new CopyOnWriteArrayList<>(); | ||
|
||
@Override | ||
public List<RESTExposable> getExposables() { | ||
return Collections.unmodifiableList(exposables); | ||
} | ||
|
||
@Activate | ||
protected void activate() { | ||
logger.info(DefaultMetricManager.class.getName() + " activated."); | ||
} | ||
|
||
@Deactivate | ||
protected void deactivate() { | ||
logger.info(DefaultMetricManager.class.getName() + " deactivated."); | ||
} | ||
|
||
@Override | ||
public void registerMetric(RESTExposable exposable) { | ||
exposables.add(exposable); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...etheusmetrics/src/main/java/com/kuguhome/openhab/prometheusmetrics/api/MetricManager.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,17 @@ | ||
package com.kuguhome.openhab.prometheusmetrics.api; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This interface describes the interaction between metrics and REST service | ||
* | ||
* @author Roman Malyugin | ||
* | ||
*/ | ||
|
||
public interface MetricManager { | ||
|
||
List<RESTExposable> getExposables(); | ||
|
||
void registerMetric(RESTExposable exposable); | ||
} |
9 changes: 9 additions & 0 deletions
9
...theusmetrics/src/main/java/com/kuguhome/openhab/prometheusmetrics/api/MetricSettable.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,9 @@ | ||
package com.kuguhome.openhab.prometheusmetrics.api; | ||
|
||
import java.util.Map; | ||
|
||
public interface MetricSettable extends RESTExposable { | ||
|
||
void set(String metricName, double metricValue, Map<String, Double> labelsValues); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...etheusmetrics/src/main/java/com/kuguhome/openhab/prometheusmetrics/api/RESTExposable.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,18 @@ | ||
package com.kuguhome.openhab.prometheusmetrics.api; | ||
|
||
import io.prometheus.client.CollectorRegistry; | ||
|
||
/** | ||
* This interface describes exposure of metric to REST service | ||
* | ||
* @author Roman Malyugin | ||
* | ||
*/ | ||
|
||
public interface RESTExposable { | ||
|
||
static final CollectorRegistry restRegistry = CollectorRegistry.defaultRegistry; | ||
|
||
void expose(); | ||
|
||
} |
Oops, something went wrong.