use of software.amazon.lambda.powertools.metrics.Metrics in project di-ipv-cri-address-api by alphagov.
the class SessionHandler method handleRequest.
@Override
@Logging(correlationIdPath = CorrelationIdPathConstants.API_GATEWAY_REST)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
try {
SessionRequest sessionRequest = addressSessionService.validateSessionRequest(input.getBody());
eventProbe.addDimensions(Map.of("issuer", sessionRequest.getClientId()));
UUID sessionId = addressSessionService.createAndSaveAddressSession(sessionRequest);
eventProbe.counterMetric(EVENT_SESSION_CREATED).auditEvent(sessionRequest);
return ApiGatewayResponseGenerator.proxyJsonResponse(HttpStatus.SC_CREATED, Map.of(SESSION_ID, sessionId.toString()));
} catch (SessionValidationException e) {
eventProbe.log(INFO, e).counterMetric(EVENT_SESSION_CREATED, 0d);
return ApiGatewayResponseGenerator.proxyJsonResponse(HttpStatus.SC_BAD_REQUEST, ErrorResponse.SESSION_VALIDATION_ERROR);
} catch (ClientConfigurationException e) {
eventProbe.log(ERROR, e).counterMetric(EVENT_SESSION_CREATED, 0d);
return ApiGatewayResponseGenerator.proxyJsonResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorResponse.SERVER_CONFIG_ERROR);
}
}
use of software.amazon.lambda.powertools.metrics.Metrics in project aws-lambda-powertools-java by awslabs.
the class PowertoolsMetricsEnabledStreamHandler method handleRequest.
@Override
@Metrics(namespace = "ExampleApplication", service = "booking")
public void handleRequest(InputStream input, OutputStream output, Context context) {
MetricsLogger metricsLogger = metricsLogger();
metricsLogger.putMetric("Metric1", 1, Unit.BYTES);
}
use of software.amazon.lambda.powertools.metrics.Metrics in project aws-lambda-powertools-java by awslabs.
the class PowertoolsMetricsExceptionWhenNoMetricsHandler method handleRequest.
@Override
@Metrics(namespace = "ExampleApplication", service = "booking", raiseOnEmptyMetrics = true)
public Object handleRequest(Object input, Context context) {
MetricsLogger metricsLogger = metricsLogger();
metricsLogger.putMetadata("MetaData", "MetaDataValue");
return null;
}
use of software.amazon.lambda.powertools.metrics.Metrics in project aws-lambda-powertools-java by awslabs.
the class PowertoolsMetricsNoDimensionsHandler method handleRequest.
@Override
@Metrics(namespace = "ExampleApplication", service = "booking")
public Object handleRequest(Object input, Context context) {
MetricsLogger metricsLogger = metricsLogger();
metricsLogger.putMetric("CoolMetric", 1);
metricsLogger.setDimensions(new DimensionSet());
return null;
}
use of software.amazon.lambda.powertools.metrics.Metrics in project aws-lambda-powertools-examples by aws-samples.
the class AppStream method handleRequest.
@Override
@Logging(logEvent = true)
@Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
Map map = mapper.readValue(input, Map.class);
System.out.println(map.size());
}
Aggregations