Skip to content

Commit

Permalink
PYIC-7746: Create cold start metric in all lambdas
Browse files Browse the repository at this point in the history
The powertools metric lib will record a metric for us for a cold start.
This enables that on all our lambdas.

As the lambdas all now have the same configuration for the aspect
configuration, I've moved it up to the lambda sub-project and applied it
to all sub-projects.
  • Loading branch information
Wynndow committed Dec 17, 2024
1 parent 62cd930 commit badf4e0
Show file tree
Hide file tree
Showing 41 changed files with 47 additions and 92 deletions.
4 changes: 0 additions & 4 deletions lambdas/build-client-oauth-response/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ dependencies {
project(":libs:common-services"),
project(":libs:audit-service")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.junitJupiter,
libs.mockitoJunit,
libs.hamcrest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.buildclientoauthresponse.domain.ClientDetails;
import uk.gov.di.ipv.core.buildclientoauthresponse.domain.ClientResponse;
Expand Down Expand Up @@ -96,6 +97,7 @@ public BuildClientOauthResponseHandler(
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(JourneyRequest input, Context context) {

LogHelper.attachComponentId(configService);
Expand Down
5 changes: 0 additions & 5 deletions lambdas/build-cri-oauth-request/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:oauth-key-service")

aspect libs.powertoolsLogging,
libs.powertoolsMetrics,
libs.powertoolsTracing,
libs.aspectj

compileOnly libs.lombok
annotationProcessor libs.lombok

Expand Down
4 changes: 0 additions & 4 deletions lambdas/build-proven-user-identity-details/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ dependencies {
project(":libs:verifiable-credentials"),
project(":libs:user-identity-service")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

compileOnly libs.lombok
annotationProcessor libs.lombok

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.buildprovenuseridentitydetails.domain.ProvenUserIdentityDetails;
import uk.gov.di.ipv.core.buildprovenuseridentitydetails.exceptions.ProvenUserIdentityDetailsException;
Expand Down Expand Up @@ -74,6 +75,7 @@ public BuildProvenUserIdentityDetailsHandler() {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(
APIGatewayProxyRequestEvent input, Context context) {
LogHelper.attachComponentId(configService);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/build-user-identity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.nimbusds.oauth2.sdk.http.HTTPResponse;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
import uk.gov.di.ipv.core.library.auditing.AuditEvent;
Expand Down Expand Up @@ -98,6 +99,7 @@ public BuildUserIdentityHandler() {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(
APIGatewayProxyRequestEvent input, Context context) {

Expand Down
13 changes: 8 additions & 5 deletions lambdas/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ allprojects {

subprojects {
afterEvaluate { subproject ->
if (subproject.plugins.hasPlugin('java')) {
dependencies {
runtimeOnly platform(libs.openTelemetryBom),
libs.openTelemetryAwsSdkAutoConfigure
}
dependencies {
runtimeOnly platform(libs.openTelemetryBom),
libs.openTelemetryAwsSdkAutoConfigure

aspect libs.powertoolsLogging,
libs.powertoolsMetrics,
libs.powertoolsTracing,
libs.aspectj
}
}
}
4 changes: 0 additions & 4 deletions lambdas/call-dcmaw-async-cri/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.calldcmawasynccri.exception.DcmawAsyncCriHttpResponseException;
import uk.gov.di.ipv.core.calldcmawasynccri.service.DcmawAsyncCriService;
Expand Down Expand Up @@ -94,6 +95,7 @@ public CallDcmawAsyncCriHandler(
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(ProcessRequest request, Context context) {
LogHelper.attachComponentId(configService);
LogHelper.attachCriIdToLogs(DCMAW_ASYNC);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/call-ticf-cri/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.callticfcri.exception.TicfCriServiceException;
import uk.gov.di.ipv.core.callticfcri.service.TicfCriService;
Expand Down Expand Up @@ -107,6 +108,7 @@ public CallTicfCriHandler(
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(ProcessRequest request, Context context) {
LogHelper.attachComponentId(configService);
LogHelper.attachCriIdToLogs(TICF);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/check-coi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
import uk.gov.di.ipv.core.library.auditing.AuditEvent;
Expand Down Expand Up @@ -109,6 +110,7 @@ public CheckCoiHandler(ConfigService configService) {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(ProcessRequest request, Context context) {
configService.setFeatureSet(RequestHelper.getFeatureSet(request));
LogHelper.attachComponentId(configService);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/check-existing-identity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:evcs-service")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.jacksonDatabind,
libs.junitJupiter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.checkexistingidentity.exceptions.MitigationRouteException;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
Expand Down Expand Up @@ -194,6 +195,7 @@ private boolean isF2fIdentity() {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(JourneyRequest event, Context context) {
LogHelper.attachComponentId(configService);

Expand Down
4 changes: 0 additions & 4 deletions lambdas/check-gpg45-score/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.jacksonDatabind,
libs.junitJupiter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
import uk.gov.di.ipv.core.library.domain.ErrorResponse;
Expand Down Expand Up @@ -85,6 +86,7 @@ public CheckGpg45ScoreHandler(ConfigService configService) {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(ProcessRequest event, Context context) {
LogHelper.attachComponentId(configService);

Expand Down
4 changes: 0 additions & 4 deletions lambdas/check-mobile-app-vc-receipt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":lambdas:process-cri-callback")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

compileOnly libs.lombok
annotationProcessor libs.lombok

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.checkmobileappvcreceipt.dto.CheckMobileAppVcReceiptRequest;
import uk.gov.di.ipv.core.checkmobileappvcreceipt.exception.InvalidCheckMobileAppVcReceiptRequestException;
Expand Down Expand Up @@ -98,6 +99,7 @@ public CheckMobileAppVcReceiptHandler() {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(
APIGatewayProxyRequestEvent input, Context context) {
try {
Expand Down
4 changes: 0 additions & 4 deletions lambdas/check-reverification-identity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:verifiable-credentials")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.junitJupiter,
libs.mockitoJunit,
project(path: ":libs:test-helpers"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
import uk.gov.di.ipv.core.library.domain.JourneyErrorResponse;
Expand Down Expand Up @@ -88,9 +89,10 @@ public CheckReverificationIdentityHandler(ConfigService configService) {
this.votMatcher = new VotMatcher(userIdentityService, new Gpg45ProfileEvaluator());
}

@Override
@Tracing
@Logging(clearState = true)
@Override
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(JourneyRequest request, Context context) {
LogHelper.attachComponentId(configService);
configService.setFeatureSet(RequestHelper.getFeatureSet(request));
Expand Down
4 changes: 0 additions & 4 deletions lambdas/evaluate-gpg45-scores/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ dependencies {
project(":libs:user-identity-service"),
project(":libs:cimit-service")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.library.annotations.ExcludeFromGeneratedCoverageReport;
import uk.gov.di.ipv.core.library.auditing.AuditEvent;
Expand Down Expand Up @@ -124,6 +125,7 @@ public EvaluateGpg45ScoresHandler(ConfigService configService) {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public Map<String, Object> handleRequest(JourneyRequest event, Context context) {
LogHelper.attachComponentId(configService);

Expand Down
4 changes: 0 additions & 4 deletions lambdas/initialise-ipv-session/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ dependencies {
compileOnly libs.lombok
annotationProcessor libs.lombok

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.jacksonDatabind,
libs.junitJupiter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.initialiseipvsession.domain.JarClaims;
import uk.gov.di.ipv.core.initialiseipvsession.domain.JarUserInfo;
Expand Down Expand Up @@ -142,6 +143,7 @@ public InitialiseIpvSessionHandler(
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(
APIGatewayProxyRequestEvent input, Context context) {
LogHelper.attachComponentId(configService);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/issue-client-access-token/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ dependencies {
project(":libs:common-services"),
project(":libs:oauth-key-service")

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

compileOnly libs.lombok
annotationProcessor libs.lombok

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.StringMapMessage;
import software.amazon.lambda.powertools.logging.Logging;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.tracing.Tracing;
import uk.gov.di.ipv.core.issueclientaccesstoken.exception.ClientAuthenticationException;
import uk.gov.di.ipv.core.issueclientaccesstoken.service.AccessTokenService;
Expand Down Expand Up @@ -85,6 +86,7 @@ public IssueClientAccessTokenHandler() {
@Override
@Tracing
@Logging(clearState = true)
@Metrics(captureColdStart = true)
public APIGatewayProxyResponseEvent handleRequest(
APIGatewayProxyRequestEvent input, Context context) {
LogHelper.attachComponentId(configService);
Expand Down
4 changes: 0 additions & 4 deletions lambdas/process-async-cri-credential/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ dependencies {
compileOnly libs.lombok
annotationProcessor libs.lombok

aspect libs.powertoolsLogging,
libs.powertoolsTracing,
libs.aspectj

testImplementation libs.hamcrest,
libs.junitJupiter,
libs.mockitoJunit,
Expand Down
Loading

0 comments on commit badf4e0

Please sign in to comment.