Skip to content
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

Improved diagnostic logs for httpGet and httpPost adaptive functions #161

Merged

Conversation

Sachin-Mamoru
Copy link
Contributor

@Sachin-Mamoru Sachin-Mamoru commented May 17, 2024

Purpose

$subject

image image
**API Call**

2024-05-17 15:03:55,259|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"ebfaf6ff-e9a5-47f6-a893-bf87793a227d","recordedAt":{"seconds":1715938435,"nanos":259354000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"SUCCESS","resultMessage":"Received access token from the token endpoint.","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"token endpoint":"https://api.asgardeo.io/t/suborg4/oauth2/token"},"logDetailLevel":"APPLICATION"}
2024-05-17 15:04:01,092|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"fcd71634-df1b-445d-be5f-a9c8bbf2cb64","recordedAt":{"seconds":1715938441,"nanos":91919000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"FAILED","resultMessage":"Request for the external API timed out.","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"external api":"https://token3.free.beeceptor.com/token3"},"logDetailLevel":"APPLICATION"}
2024-05-17 15:04:01,118|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"72ff0f4d-9c51-40c4-919d-cacd8b451ad1","recordedAt":{"seconds":1715938441,"nanos":118610000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"FAILED","resultMessage":"Retrying the request for external api. Attempt: 1","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"external api":"https://token3.free.beeceptor.com/token3"},"configurations":{"max request attempts":2},"logDetailLevel":"APPLICATION"}


2024-05-17 15:04:07,008|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"3ae395bc-07bb-46eb-811b-a9607c0c6a61","recordedAt":{"seconds":1715938447,"nanos":8112000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"FAILED","resultMessage":"Request for the external API timed out.","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"external api":"https://token3.free.beeceptor.com/token3"},"logDetailLevel":"APPLICATION"}
2024-05-17 15:04:07,016|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"017b49c6-321a-4451-950e-3a5a9943b244","recordedAt":{"seconds":1715938447,"nanos":16264000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"FAILED","resultMessage":"Retrying the request for external api. Attempt: 2","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"external api":"https://token3.free.beeceptor.com/token3"},"configurations":{"max request attempts":2},"logDetailLevel":"APPLICATION"}
2024-05-17 15:04:12,795|b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5|Tenant:carbon.super|pool-35-thread-1|{"logId":"563e9cab-d75d-4a41-8177-27d0a452db1d","recordedAt":{"seconds":1715938452,"nanos":795518000},"requestId":"b5c8d1d0-0365-4b8a-9a6e-2af4839a0de5","resultStatus":"FAILED","resultMessage":"Request for the external API timed out.","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"external api":"https://token3.free.beeceptor.com/token3"},"logDetailLevel":"APPLICATION"}

**Token Call**

2024-05-17 15:05:30,608|928ec7e7-1387-4213-bc8a-cdc1b2e15ca6|Tenant:carbon.super|pool-35-thread-3|{"logId":"90ade137-55d2-4246-937b-5c1fb5b7d08b","recordedAt":{"seconds":1715938530,"nanos":608062000},"requestId":"928ec7e7-1387-4213-bc8a-cdc1b2e15ca6","resultStatus":"FAILED","resultMessage":"Token endpoint returned a client error. Status code: 401","actionId":"receive-api-response-http-post","componentId":"adaptive-auth-service-http-post","input":{"token endpoint":"https://api.asgardeo.io/t/suborg4/oauth2/token"},"logDetailLevel":"APPLICATION"}
2024-05-17 15:05:30,664|928ec7e7-1387-4213-bc8a-cdc1b2e15ca6|Tenant:carbon.super|pool-35-thread-3|{"logId":"25668b61-4cda-439f-a8ae-b42797266427","recordedAt":{"seconds":1715938530,"nanos":664500000},"requestId":"928ec7e7-1387-4213-bc8a-cdc1b2e15ca6","resultStatus":"FAILED","resultMessage":"Failed to retrieve access token for the provided token endpoint.","actionId":"receive-token-http-post","componentId":"adaptive-auth-service-http-post","input":{"token endpoint":"https://api.asgardeo.io/t/suborg4/oauth2/token","grant type":"client_credentials"},"configurations":{"max request attempts":2},"logDetailLevel":"APPLICATION"}

@malithie
Copy link
Contributor

Are above screen shots related to improved one or existing one ?

@malithie
Copy link
Contributor

Can you please check following.

  1. Does 'componentId' is shown in the UI ? I haven't seen this for any logs so far. Does it mean we haven't been using this property at all ?
  2. Does 'configurations' gets shown in UI ?

@Sachin-Mamoru
Copy link
Contributor Author

Are above screen shots related to improved one or existing one ?

Existing one

@Sachin-Mamoru
Copy link
Contributor Author

Sachin-Mamoru commented May 17, 2024

Can you please check following.

  1. Does 'componentId' is shown in the UI ? I haven't seen this for any logs so far. Does it mean we haven't been using this property at all ?

ComponentId is not shown in the UI. But you can filter the logs through the componentId.

  1. Does 'configurations' gets shown in UI ?

yes

if (LoggerUtils.isDiagnosticLogsEnabled()) {
                LoggerUtils.triggerDiagnosticLogEvent(new DiagnosticLog.DiagnosticLogBuilder(
                        OAUTH_INBOUND_SERVICE, VALIDATE_INPUT_PARAMS)
                        .inputParam(LogConstants.InputKeys.CLIENT_ID, clientId)
                        .inputParam(OAuthConstants.LogConstants.InputKeys.REDIRECT_URI, callbackURI)
                        .configParam(OAuthConstants.LogConstants.ConfigKeys.CALLBACK_URI, appDO.getCallbackUrl())
                        .resultMessage("redirect_uri in request does not match with the registered one.")
                        .logDetailLevel(DiagnosticLog.LogDetailLevel.APPLICATION)
                        .resultStatus(DiagnosticLog.ResultStatus.FAILED));
            }
image

@malithie
Copy link
Contributor

If above is the case below is my suggestion

  1. Let's update the action ids similar to following
    invoke-api-http-post
    invoke-api-http-get
    invoke-token-request-http-post or request-token-http-post

This is because action is not exactly receive. we are rather invoking an api or getting an AT
2. We can keep the component id same.

As you update, can you list down the action ids against the respective function that gets performed so that it's easy to review

@Sachin-Mamoru
Copy link
Contributor Author

If above is the case below is my suggestion

  1. Let's update the action ids similar to following
    invoke-api-http-post
    invoke-api-http-get
    invoke-token-request-http-post or request-token-http-post

This is because action is not exactly receive. we are rather invoking an api or getting an AT 2. We can keep the component id same.

As you update, can you list down the action ids against the respective function that gets performed so that it's easy to review

Resolved with 6e8e560

# Conflicts:
#	components/org.wso2.carbon.identity.conditional.auth.functions.common/src/main/java/org/wso2/carbon/identity/conditional/auth/functions/common/utils/Constants.java
malithie
malithie previously approved these changes May 21, 2024
@Sachin-Mamoru Sachin-Mamoru merged commit 0eb37ca into wso2-extensions:master May 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants