Skip to content

Commit

Permalink
Fix Codahale Shading and ensure class not found errors are solved for…
Browse files Browse the repository at this point in the history
… 2.1.6. Relocate DripReporter

Signed-off-by: Narimm <[email protected]>
  • Loading branch information
Narimm committed Apr 28, 2020
1 parent 65b2a90 commit 44dde21
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
18 changes: 17 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@
<dependency>
<groupId>au.com.addstar.dripreporter</groupId>
<artifactId>DripReporterAPI</artifactId>
<version>1.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
Expand Down Expand Up @@ -211,6 +223,10 @@
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>com.botsko.prism.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>au.com.addstar.dripreporter</pattern>
<shadedPattern>com.botsko.prism.libs.dripreporter</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down
41 changes: 20 additions & 21 deletions src/main/java/me/botsko/prism/actions/ActionMeter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.botsko.prism.actions;

import au.com.addstar.dripreporter.DripMeter;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
import me.botsko.prism.Prism;

Expand All @@ -13,42 +12,42 @@
* Created by benjamincharlton on 25/02/2020.
*/
public class ActionMeter {
private static Map<String, DripMeter> meter = new HashMap<>();
private static boolean monitoring = false;
private static final Map<String, DripMeter> meter = new HashMap<>();
private static final boolean monitoring = Prism.getInstance().monitoring;

static {
meter.put(GenericAction.class.getSimpleName(), new DripMeter());
meter.put(EntityAction.class.getSimpleName(), new DripMeter());
meter.put(BlockAction.class.getSimpleName(), new DripMeter());
meter.put(BlockChangeAction.class.getSimpleName(), new DripMeter());
meter.put(ItemStackAction.class.getSimpleName(), new DripMeter());
meter.put(BlockShiftAction.class.getSimpleName(), new DripMeter());
meter.put(EntityTravelAction.class.getSimpleName(), new DripMeter());
meter.put(GrowAction.class.getSimpleName(), new DripMeter());
meter.put(HangingItemAction.class.getSimpleName(), new DripMeter());
meter.put(PlayerAction.class.getSimpleName(), new DripMeter());
meter.put(PlayerDeathAction.class.getSimpleName(), new DripMeter());
meter.put(PrismProcessAction.class.getSimpleName(), new DripMeter());
meter.put(PrismRollbackAction.class.getSimpleName(), new DripMeter());
meter.put(SignAction.class.getSimpleName(), new DripMeter());
meter.put(VehicleAction.class.getSimpleName(), new DripMeter());
if (monitoring) {
meter.put(GenericAction.class.getSimpleName(), new DripMeter());
meter.put(EntityAction.class.getSimpleName(), new DripMeter());
meter.put(BlockAction.class.getSimpleName(), new DripMeter());
meter.put(BlockChangeAction.class.getSimpleName(), new DripMeter());
meter.put(ItemStackAction.class.getSimpleName(), new DripMeter());
meter.put(BlockShiftAction.class.getSimpleName(), new DripMeter());
meter.put(EntityTravelAction.class.getSimpleName(), new DripMeter());
meter.put(GrowAction.class.getSimpleName(), new DripMeter());
meter.put(HangingItemAction.class.getSimpleName(), new DripMeter());
meter.put(PlayerAction.class.getSimpleName(), new DripMeter());
meter.put(PlayerDeathAction.class.getSimpleName(), new DripMeter());
meter.put(PrismProcessAction.class.getSimpleName(), new DripMeter());
meter.put(PrismRollbackAction.class.getSimpleName(), new DripMeter());
meter.put(SignAction.class.getSimpleName(), new DripMeter());
meter.put(VehicleAction.class.getSimpleName(), new DripMeter());
}
}

/**
* Setup the meter to record.
* @param registry metric registry
*/
public static void setupActionMeter(MetricRegistry registry) {
for (Map.Entry<String, DripMeter> e : meter.entrySet()) {
registry.register(e.getKey(), e.getValue());
}
monitoring = Prism.getInstance().monitoring;
}

@SuppressWarnings("rawtypes")
static void mark(Class clazz) {
if (monitoring) {
Meter m = meter.get(clazz.getSimpleName());
DripMeter m = meter.get(clazz.getSimpleName());
if (m == null) {
m = meter.get(GenericAction.class.getSimpleName());
}
Expand Down

0 comments on commit 44dde21

Please sign in to comment.