Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.4.0</version>
<version>4.9.3.2</version>
<executions>
<execution>
<id>test</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

private final software.amazon.cloudwatchlogs.emf.logger.MetricsLogger emfLogger;
private final EnvironmentProvider environmentProvider;
private boolean raiseOnEmptyMetrics = false;
private AtomicBoolean raiseOnEmptyMetrics = new AtomicBoolean(false);
private String namespace;
private Map<String, String> defaultDimensions = new HashMap<>();
private final AtomicBoolean hasMetrics = new AtomicBoolean(false);
Expand Down Expand Up @@ -81,9 +81,9 @@
emfDimensionSet.addDimension(key, val);
// Update our local copy of default dimensions
defaultDimensions.put(key, val);
} catch (Exception e) {
// Ignore dimension errors
}

Check failure on line 86 in powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/EmfMetricsLogger.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid empty catch blocks

Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported. EmptyCatchBlock (Priority: 1, Ruleset: Error Prone) https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#emptycatchblock
});

emfLogger.putDimensions(emfDimensionSet);
Expand All @@ -105,9 +105,9 @@
dimensions.forEach((key, value) -> {
try {
emfDimensionSet.addDimension(key, value);
} catch (Exception e) {
// Ignore dimension errors
}

Check failure on line 110 in powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/EmfMetricsLogger.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid empty catch blocks

Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported. EmptyCatchBlock (Priority: 1, Ruleset: Error Prone) https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#emptycatchblock
});
emfLogger.setDimensions(emfDimensionSet);
// Store a copy of the default dimensions
Expand All @@ -133,7 +133,7 @@

@Override
public void setRaiseOnEmptyMetrics(boolean raiseOnEmptyMetrics) {
this.raiseOnEmptyMetrics = raiseOnEmptyMetrics;
this.raiseOnEmptyMetrics.set(raiseOnEmptyMetrics);
}

@Override
Expand All @@ -159,7 +159,7 @@
Validator.validateNamespace(namespace);

if (!hasMetrics.get()) {
if (raiseOnEmptyMetrics) {
if (raiseOnEmptyMetrics.get()) {
throw new IllegalStateException("No metrics were emitted");
} else {
LOGGER.warn("No metrics were emitted");
Expand Down Expand Up @@ -196,9 +196,9 @@
dimensions.getDimensions().forEach((key, val) -> {
try {
emfDimensionSet.addDimension(key, val);
} catch (Exception e) {
// Ignore dimension errors
}

Check failure on line 201 in powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/EmfMetricsLogger.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid empty catch blocks

Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported. EmptyCatchBlock (Priority: 1, Ruleset: Error Prone) https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#emptycatchblock
});
coldStartLogger.setDimensions(emfDimensionSet);
}
Expand Down Expand Up @@ -249,9 +249,9 @@
dimensions.getDimensions().forEach((key, val) -> {
try {
emfDimensionSet.addDimension(key, val);
} catch (Exception e) {
// Ignore dimension errors
}

Check failure on line 254 in powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/internal/EmfMetricsLogger.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid empty catch blocks

Empty Catch Block finds instances where an exception is caught, but nothing is done. In most circumstances, this swallows an exception which should either be acted on or reported. EmptyCatchBlock (Priority: 1, Ruleset: Error Prone) https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#emptycatchblock
});
singleMetricLogger.setDimensions(emfDimensionSet);
}
Expand Down
Loading