-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat(v2): Add GraalVM reachability metadata for core utilities #1753
base: v2
Are you sure you want to change the base?
Conversation
|
Hi @rr-on-gh, I tested the For reference, this is my test Lambda handler: @Named("test")
public class TestLambda implements RequestHandler<InputObject, OutputObject> {
@Inject
ProcessingService service;
private final static Logger logger = Logger.getLogger(TestLambda.class);
private final static MetricsLogger metricsLogger = MetricsUtils.metricsLogger();
@Override
@Metrics(namespace = "QuarkusApp", service = "powertools")
public OutputObject handleRequest(InputObject input, Context context) {
logger.info("Quarkus Jboss Log."); // Logging with Jboss is not yet supported by Powertools
long startTime = System.currentTimeMillis();
final OutputObject output = service.process(input).setRequestId(context.getAwsRequestId());
metricsLogger.putMetric("ExecutionTime", System.currentTimeMillis() - startTime, Unit.MILLISECONDS);
metricsLogger.putMetric("Invocation", 1, Unit.COUNT);
return output;
}
} When I compile this using
The CloudWatch EMF dependency seems to think we are running in an agent-based environment and tries to connect to a CloudWatch agent endpoint on localhost. If I instruct the --- a/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
+++ b/powertools-metrics/src/main/java/software/amazon/lambda/powertools/metrics/MetricsUtils.java
@@ -22,8 +22,10 @@ import static software.amazon.lambda.powertools.metrics.internal.LambdaMetricsAs
import java.util.Arrays;
import java.util.Optional;
import java.util.function.Consumer;
+
import software.amazon.cloudwatchlogs.emf.config.SystemWrapper;
import software.amazon.cloudwatchlogs.emf.environment.EnvironmentProvider;
+import software.amazon.cloudwatchlogs.emf.environment.LambdaEnvironment;
import software.amazon.cloudwatchlogs.emf.logger.MetricsLogger;
import software.amazon.cloudwatchlogs.emf.model.DimensionSet;
import software.amazon.cloudwatchlogs.emf.model.MetricsContext;
@@ -37,7 +39,7 @@ import software.amazon.cloudwatchlogs.emf.model.Unit;
* {@see Metrics}
*/
public final class MetricsUtils {
- private static final MetricsLogger metricsLogger = new MetricsLogger();
+ private static final MetricsLogger metricsLogger = new MetricsLogger(new LambdaEnvironment());
private static DimensionSet[] defaultDimensions;
private MetricsUtils() { Output:
Note: This behavior does not occur when using JVM. |
Issue #, if available: #764
Description of changes:
Adding GraalVM reachability metadata files for
logging
,metrics
andtracing
modules. Also added a SAM based sample application to demonstrate the usage.Checklist
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.