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

Resource level filter logging feature added #12106

Closed
wants to merge 31 commits into from

Conversation

shnrndk
Copy link
Contributor

@shnrndk shnrndk commented Jul 31, 2023

Fix wso2/api-manager#1564
Test Case for this PR: wso2/product-apim#13260

shnrndk and others added 30 commits March 13, 2023 15:19
(cherry picked from commit db93dd8)
formatted logging related sql scripts
@@ -494,6 +494,7 @@ public enum ExceptionCodes implements ErrorHandler {
LOGGING_API_NOT_FOUND(901400, "Requested Resource Not Found", 404, "Request API Not Found for context: %s"),
LOGGING_API_INCORRECT_LOG_LEVEL(901401, "Bad Request", 400, "Log level should be either OFF, BASIC, STANDARD or FULL"),
LOGGING_API_MISSING_DATA(901402, "Missing data", 400, "API context or log level is missing"),
LOGGING_API_RESOURCE_NOT_FOUND(901403, "Requested Resource Not Found", 400, "Requested API Resource Not Found"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

404 for not found

resourcePath = apiLoggerObject.getString("resourcePath");
}
Map<String, String> properties = new HashMap<>();
properties.put("context", apiLoggerObject.getString("context"));
Copy link
Contributor

@chamilaadhi chamilaadhi Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use constants and refer. There are many places referring to string like context, resourcePath, etc

import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.wso2.carbon.apimgt.gateway.APIMgtGatewayConstants;
import org.wso2.carbon.apimgt.impl.APIConstants;

import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not to use wild card imports. Importing specific class improves readability

Map<String, String> key = entry.getKey();
//if resource path is empty, proceeding with API level logs
if (selectedApi.getContext().equals(key.get("context"))) {
if (key.get("resourcePath") == null && key.get("resourceMethod") == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use constants previously defined

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a dependency is added here?

@tharikaGitHub
Copy link
Member

Closing as the changes are added from PR [1].

[1] #12288

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.

Need to support per API Log Filtering based on API Resource
4 participants