Skip to content

feat(metrics): New metrics module implementation with support for Metrics providers and usage without annotations #1863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2a79c02
Rewrite metrics module with interface abstraction and provider patter…
phipag Jun 2, 2025
4249766
Update default dimension and namespace logic to have the precedence: …
phipag Jun 3, 2025
9961072
Small cosmetic changes.
phipag Jun 3, 2025
f1e9acb
Add unit tests.
phipag Jun 4, 2025
6b81805
Update metrics documentation with new interface.
phipag Jun 4, 2025
86cb3ce
Make unit tests compatible with GraalVM. It is not supported to mock …
phipag Jun 4, 2025
483766c
Add GraalVM support bullet points to docs pages.
phipag Jun 4, 2025
a14c43c
Update GraalVM metadata files after re-implementing metrics module.
phipag Jun 4, 2025
17c865d
Fix spotbugs issue. This is expected for this factory class for Metri…
phipag Jun 4, 2025
4085b0d
Fix SonarCube findings.
phipag Jun 4, 2025
ead827b
Rename back namespace to ServerlessAirline example.
phipag Jun 4, 2025
ac56a5b
Fix DimensionSet validation to be inline with most recent specification.
phipag Jun 4, 2025
feeefdc
Overload void addDimension(DimensionSet dimensionSet) to be able to a…
phipag Jun 4, 2025
a178128
Update setDefaultDimensions to take a DimensionSet instead of a Map.
phipag Jun 4, 2025
4515ee4
Add warning if not emitting metrics and raiseOnEmptyMetrics is false.
phipag Jun 4, 2025
cc74f3f
Remove unused imports.
phipag Jun 4, 2025
37de57d
Add namespace validation. Refacator into own Validator class. Require…
phipag Jun 5, 2025
36dd713
Update docs with DimensionSet.of instead of Map.of. Fix naming consis…
phipag Jun 5, 2025
e0df19b
Add example for overwriting dimension of cold start metric.
phipag Jun 5, 2025
0a79cec
Add note that metadata needs to be added before flushing.
phipag Jun 5, 2025
7ef4e69
Remove test classes from GRM reflect-config.json.
phipag Jun 5, 2025
b05634d
Rename pushSingleMetric to flushSingleMetric.
phipag Jun 5, 2025
ba09a50
Add example for high cardinality dimensions using DimensionSet.
phipag Jun 5, 2025
05fe15e
Add support for POWERTOOLS_METRICS_DISABLED environment variable.
phipag Jun 5, 2025
eb167f1
Only add service name dimension if the service is actually defined.
phipag Jun 5, 2025
4637fef
Add support for POWERTOOLS_METRICS_FUNCTION_NAME.
phipag Jun 5, 2025
c7c9ed5
Add Testing your code section to docs.
phipag Jun 5, 2025
e4a3464
Rename @Metrics to @FlushMetrics.
phipag Jun 5, 2025
a635610
Rename MetricsLogger to Metrics, rename MetricsLoggerBuilder to Metri…
phipag Jun 5, 2025
ef3347a
Add support for setTimestamp.
phipag Jun 5, 2025
6b82ea5
Update regex for namespace validation.
phipag Jun 5, 2025
120b8d0
Fix namespace regex and fix metrics e2e tests.
phipag Jun 5, 2025
26a4b1d
Add comment in empty callAt method to satisfy pmd_analyse.
phipag Jun 6, 2025
0017e8b
Replace usages of standalone Powertools wording with alternative word…
phipag Jun 6, 2025
3d02853
Reduce cognitive complexity of around() method in LambdaMetricsAspect.
phipag Jun 6, 2025
53d054d
Re-generate GRM files after applying MetricsLogger renaming.
phipag Jun 6, 2025
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
1 change: 1 addition & 0 deletions docs/core/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Logging provides an opinionated logger with output structured as JSON.
* Optionally logs Lambda response
* Optionally supports log sampling by including a configurable percentage of DEBUG logs in logging output
* Allows additional keys to be appended to the structured log at any point in time
* GraalVM support


## Getting started
Expand Down
368 changes: 271 additions & 97 deletions docs/core/metrics.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/core/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ a provides functionality to reduce the overhead of performing common tracing tas
* Helper methods to improve the developer experience of creating new X-Ray subsegments.
* Better developer experience when developing with multiple threads.
* Auto patch supported modules by AWS X-Ray
* GraalVM support

## Install

Expand Down
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ Use the following [dependency matrix](https://github.com/eclipse-aspectj/aspectj
**Explicit parameters take precedence over environment variables.**

| Environment variable | Description | Utility |
|----------------------------------------|----------------------------------------------------------------------------------------|---------------------------|
| -------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------- |
| **POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All |
| **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics) |
| **POWERTOOLS_METRICS_FUNCTION_NAME** | Function name used as dimension for the cold start metric | [Metrics](./core/metrics) |
| **POWERTOOLS_METRICS_DISABLED** | Disables all flushing of metrics | [Metrics](./core/metrics) |
| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging) |
| **POWERTOOLS_LOG_LEVEL** | Sets logging level | [Logging](./core/logging) |
| **POWERTOOLS_LOGGER_LOG_EVENT** | Enables/Disables whether to log the incoming event when using the aspect | [Logging](./core/logging) |
| **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Enables/Disables tracing mode to capture method response | [Tracing](./core/tracing) |
| **POWERTOOLS_TRACER_CAPTURE_ERROR** | Enables/Disables tracing mode to capture method error | [Tracing](./core/tracing) |

1 change: 1 addition & 0 deletions docs/utilities/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ or [AWS AppConfig](https://aws.amazon.com/systems-manager/features/appconfig/).
* Retrieve one or multiple parameters from an underlying provider in a standard way
* Cache parameter values for a given amount of time (defaults to 5 seconds)
* Transform parameter values from JSON or base 64 encoded strings
* GraalVM support

## Install
In order to provide lightweight dependencies, each parameters module is available as its own
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

package helloworld;

import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;

import com.amazonaws.services.lambda.runtime.Context;
Expand All @@ -32,10 +30,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.Unit;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsLogger;
import software.amazon.lambda.powertools.metrics.MetricsLoggerFactory;
import software.amazon.lambda.powertools.metrics.model.DimensionSet;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
import software.amazon.lambda.powertools.tracing.CaptureMode;
import software.amazon.lambda.powertools.tracing.Tracing;
import software.amazon.lambda.powertools.tracing.TracingUtils;
Expand All @@ -45,6 +45,8 @@
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private static final Logger log = LoggerFactory.getLogger(App.class);
private static final MetricsLogger metricsLogger = MetricsLoggerFactory.getMetricsLogger();

@Logging(logEvent = true, samplingRate = 0.7)
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
@Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
Expand All @@ -54,13 +56,13 @@
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");

metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
metricsLogger.addMetric("CustomMetric1", 1, MetricUnit.COUNT);

withSingleMetric("CustomMetrics2", 1, Unit.COUNT, "Another", (metric) ->
{
metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"));
metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"));
});
DimensionSet dimensionSet = DimensionSet.of(
"AnotherService", "CustomService",
"AnotherService1", "CustomService1"
);
metricsLogger.flushSingleMetric("CustomMetric2", 1, MetricUnit.COUNT, "Another", dimensionSet);

MDC.put("test", "willBeLogged");

Expand Down Expand Up @@ -91,7 +93,7 @@
}

@Tracing
private void log() {

Check failure on line 96 in examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid unused private methods such as 'log()'.

Unused Private Method detects when a private method is declared but is unused. UnusedPrivateMethod (Priority: 1, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.14.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
log.info("inside threaded logging for function");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package helloworld;

import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;

import com.amazonaws.services.lambda.runtime.Context;
Expand All @@ -33,10 +31,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.Unit;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsLogger;
import software.amazon.lambda.powertools.metrics.MetricsLoggerFactory;
import software.amazon.lambda.powertools.metrics.model.DimensionSet;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
import software.amazon.lambda.powertools.tracing.CaptureMode;
import software.amazon.lambda.powertools.tracing.Tracing;
import software.amazon.lambda.powertools.tracing.TracingUtils;
Expand All @@ -46,6 +46,7 @@
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private static final Logger log = LoggerFactory.getLogger(App.class);
private static final MetricsLogger metricsLogger = MetricsLoggerFactory.getMetricsLogger();

@Logging(logEvent = true, samplingRate = 0.7)
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
Expand All @@ -56,13 +57,13 @@
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");

metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
metricsLogger.addMetric("CustomMetric1", 1, MetricUnit.COUNT);

withSingleMetric("CustomMetrics2", 1, Unit.COUNT, "Another", (metric) ->
{
metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"));
metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"));
});
DimensionSet dimensionSet = DimensionSet.of(
"AnotherService", "CustomService",
"AnotherService1", "CustomService1"
);
metricsLogger.flushSingleMetric("CustomMetric2", 1, MetricUnit.COUNT, "Another", dimensionSet);

MDC.put("test", "willBeLogged");

Expand Down Expand Up @@ -93,7 +94,7 @@
}

@Tracing
private void log() {

Check failure on line 97 in examples/powertools-examples-core-utilities/gradle/src/main/java/helloworld/App.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid unused private methods such as 'log()'.

Unused Private Method detects when a private method is declared but is unused. UnusedPrivateMethod (Priority: 1, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.14.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
log.info("inside threaded logging for function");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent
import com.amazonaws.xray.entities.Subsegment
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import software.amazon.cloudwatchlogs.emf.logger.MetricsLogger
import software.amazon.cloudwatchlogs.emf.model.DimensionSet
import software.amazon.cloudwatchlogs.emf.model.Unit
import software.amazon.lambda.powertools.logging.Logging
import software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry
import software.amazon.lambda.powertools.metrics.Metrics
import software.amazon.lambda.powertools.metrics.MetricsUtils
import software.amazon.lambda.powertools.metrics.MetricsLogger
import software.amazon.lambda.powertools.metrics.MetricsLoggerFactory
import software.amazon.lambda.powertools.metrics.model.DimensionSet
import software.amazon.lambda.powertools.metrics.model.MetricUnit
import software.amazon.lambda.powertools.tracing.CaptureMode
import software.amazon.lambda.powertools.tracing.Tracing
import software.amazon.lambda.powertools.tracing.TracingUtils
Expand All @@ -39,16 +39,23 @@ import java.net.URL
*/

class App : RequestHandler<APIGatewayProxyRequestEvent?, APIGatewayProxyResponseEvent> {
private val log = LoggerFactory.getLogger(this::class.java)
private val metricsLogger: MetricsLogger = MetricsLoggerFactory.getMetricsLogger()

@Logging(logEvent = true, samplingRate = 0.7)
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
@Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
override fun handleRequest(input: APIGatewayProxyRequestEvent?, context: Context?): APIGatewayProxyResponseEvent {
val headers = mapOf("Content-Type" to "application/json", "X-Custom-Header" to "application/json")
MetricsUtils.metricsLogger().putMetric("CustomMetric1", 1.0, Unit.COUNT)
MetricsUtils.withSingleMetric("CustomMetrics2", 1.0, Unit.COUNT, "Another") { metric: MetricsLogger ->
metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"))
metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"))
}

metricsLogger.addMetric("CustomMetric1", 1.0, MetricUnit.COUNT)

val dimensionSet = DimensionSet.of(
"AnotherService", "CustomService",
"AnotherService1", "CustomService1"
)
metricsLogger.flushSingleMetric("CustomMetric2", 1.0, MetricUnit.COUNT, "Another", dimensionSet)

MDC.put("test", "willBeLogged")
val response = APIGatewayProxyResponseEvent().withHeaders(headers)
return try {
Expand Down Expand Up @@ -89,6 +96,4 @@ class App : RequestHandler<APIGatewayProxyRequestEvent?, APIGatewayProxyResponse
reader.readText().trim()
}
}

private val log = LoggerFactory.getLogger(this::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package helloworld;

import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;

import com.amazonaws.services.lambda.runtime.Context;
Expand All @@ -33,11 +31,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.StorageResolution;
import software.amazon.cloudwatchlogs.emf.model.Unit;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsLogger;
import software.amazon.lambda.powertools.metrics.MetricsLoggerFactory;
import software.amazon.lambda.powertools.metrics.model.DimensionSet;
import software.amazon.lambda.powertools.metrics.model.MetricResolution;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
import software.amazon.lambda.powertools.tracing.CaptureMode;
import software.amazon.lambda.powertools.tracing.Tracing;
import software.amazon.lambda.powertools.tracing.TracingUtils;
Expand All @@ -47,6 +47,7 @@
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private static final Logger log = LoggerFactory.getLogger(App.class);
private static final MetricsLogger metricsLogger = MetricsLoggerFactory.getMetricsLogger();

@Logging(logEvent = true, samplingRate = 0.7)
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
Expand All @@ -57,15 +58,15 @@
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");

metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
metricsLogger.addMetric("CustomMetric1", 1, MetricUnit.COUNT);

withSingleMetric("CustomMetrics2", 1, Unit.COUNT, "Another", (metric) ->
{
metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"));
metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"));
});
DimensionSet dimensionSet = DimensionSet.of(
"AnotherService", "CustomService",
"AnotherService1", "CustomService1"
);
metricsLogger.flushSingleMetric("CustomMetric2", 1, MetricUnit.COUNT, "Another", dimensionSet);

metricsLogger().putMetric("CustomMetric3", 1, Unit.COUNT, StorageResolution.HIGH);
metricsLogger.addMetric("CustomMetric3", 1, MetricUnit.COUNT, MetricResolution.HIGH);

MDC.put("test", "willBeLogged");

Expand Down Expand Up @@ -96,7 +97,7 @@
}

@Tracing
private void log() {

Check failure on line 100 in examples/powertools-examples-core-utilities/sam-graalvm/src/main/java/helloworld/App.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid unused private methods such as 'log()'.

Unused Private Method detects when a private method is declared but is unused. UnusedPrivateMethod (Priority: 1, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.14.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
log.info("inside threaded logging for function");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@
package helloworld;

import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.metricsLogger;
import static software.amazon.lambda.powertools.metrics.MetricsUtils.withSingleMetric;
import static software.amazon.lambda.powertools.tracing.TracingUtils.putMetadata;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.StorageResolution;
import software.amazon.cloudwatchlogs.emf.model.Unit;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;

import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsLogger;
import software.amazon.lambda.powertools.metrics.MetricsLoggerFactory;
import software.amazon.lambda.powertools.metrics.model.DimensionSet;
import software.amazon.lambda.powertools.metrics.model.MetricResolution;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
import software.amazon.lambda.powertools.tracing.CaptureMode;
import software.amazon.lambda.powertools.tracing.Tracing;
import software.amazon.lambda.powertools.tracing.TracingUtils;
Expand All @@ -47,6 +50,7 @@
*/
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private static final Logger log = LoggerFactory.getLogger(App.class);
private static final MetricsLogger metricsLogger = MetricsLoggerFactory.getMetricsLogger();

@Logging(logEvent = true, samplingRate = 0.7)
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
Expand All @@ -57,15 +61,14 @@
headers.put("Content-Type", "application/json");
headers.put("X-Custom-Header", "application/json");

metricsLogger().putMetric("CustomMetric1", 1, Unit.COUNT);
metricsLogger.addMetric("CustomMetric1", 1, MetricUnit.COUNT);

withSingleMetric("CustomMetrics2", 1, Unit.COUNT, "Another", (metric) ->
{
metric.setDimensions(DimensionSet.of("AnotherService", "CustomService"));
metric.setDimensions(DimensionSet.of("AnotherService1", "CustomService1"));
});
DimensionSet dimensionSet = new DimensionSet();
dimensionSet.addDimension("AnotherService", "CustomService");
dimensionSet.addDimension("AnotherService1", "CustomService1");
metricsLogger.flushSingleMetric("CustomMetric2", 1, MetricUnit.COUNT, "Another", dimensionSet);

metricsLogger().putMetric("CustomMetric3", 1, Unit.COUNT, StorageResolution.HIGH);
metricsLogger.addMetric("CustomMetric3", 1, MetricUnit.COUNT, MetricResolution.HIGH);

MDC.put("test", "willBeLogged");

Expand All @@ -77,8 +80,7 @@
TracingUtils.putAnnotation("Test", "New");
String output = String.format("{ \"message\": \"hello world\", \"location\": \"%s\" }", pageContents);

TracingUtils.withSubsegment("loggingResponse", subsegment ->
{
TracingUtils.withSubsegment("loggingResponse", subsegment -> {
String sampled = "log something out";
log.info(sampled);
log.info(output);
Expand All @@ -96,7 +98,7 @@
}

@Tracing
private void log() {

Check failure on line 101 in examples/powertools-examples-core-utilities/sam/src/main/java/helloworld/App.java

View workflow job for this annotation

GitHub Actions / pmd_analyse

Avoid unused private methods such as 'log()'.

Unused Private Method detects when a private method is declared but is unused. UnusedPrivateMethod (Priority: 1, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.14.0/pmd_rules_java_bestpractices.html#unusedprivatemethod
log.info("inside threaded logging for function");
}

Expand Down
Loading
Loading