-
Notifications
You must be signed in to change notification settings - Fork 626
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
Analytics improvement #12176
Analytics improvement #12176
Conversation
587c32b
to
7524f90
Compare
@@ -0,0 +1,70 @@ | |||
/* | |||
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the license header
@@ -0,0 +1,65 @@ | |||
package org.wso2.carbon.apimgt.common.analytics.publishers.dto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include the license header for this file.
@@ -151,6 +158,41 @@ public API getApi() throws DataNotFoundException { | |||
api.setApiVersion(apiObj.getApiVersion()); | |||
api.setApiCreator(apiObj.getApiProvider()); | |||
api.setApiCreatorTenantDomain(MultitenantUtils.getTenantDomain(api.getApiCreator())); | |||
List<URITemplate> uriTemplates = new ArrayList<>(); | |||
for (URLMapping uriTemplate : apiObj.getUrlMappings()) { | |||
org.wso2.carbon.apimgt.common.analytics.publishers.dto.URITemplate uriTemplateObj = new org.wso2.carbon.apimgt.common.analytics.publishers.dto.URITemplate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting has gone beyond 120 limit.
uriTemplateObj.setAuthScheme(uriTemplate.getAuthScheme()); | ||
List<org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy> operationPolicies = new ArrayList<>(); | ||
for (OperationPolicy operationPolicy : uriTemplate.getOperationPolicies()) { | ||
org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy operationPolicyObj = new org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's format the code.
} | ||
List<org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy> apiPolicyList = new ArrayList<>(); | ||
for(OperationPolicy apiPolicy: apiObj.getApiPolicies()){ | ||
org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy operationPolicyObj = new org.wso2.carbon.apimgt.common.analytics.publishers.dto.OperationPolicy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's format the code.
|
||
} | ||
|
||
private void attachPolicies(Connection connection, String revisionId, API api) throws SQLException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the rest of the formatting issues in this file.
@@ -570,7 +570,26 @@ public class SubscriptionValidationSQLConstants { | |||
"AM_API_RESOURCE_SCOPE_MAPPING.SCOPE_NAME FROM AM_API_URL_MAPPING LEFT JOIN AM_API_RESOURCE_SCOPE_MAPPING" + | |||
" ON AM_API_URL_MAPPING.URL_MAPPING_ID=AM_API_RESOURCE_SCOPE_MAPPING.URL_MAPPING_ID WHERE " + | |||
"AM_API_URL_MAPPING.API_ID = ? AND AM_API_URL_MAPPING.REVISION_UUID = ?"; | |||
|
|||
// public static final String GET_OPERATION_POLICIES_PER_URI_BY_API_SQL = "SELECT AUM.HTTP_METHOD, AUM.URL_PATTERN, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the commented out code if not required.
@@ -0,0 +1,157 @@ | |||
package org.wso2.carbon.apimgt.internal.service.dto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the license header and remove wildcard imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a swagger generated file. Should we modify this class as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's right, no need to add the header here as it is an auto generated file.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #12176 +/- ##
===========================================
- Coverage 39.36% 20.83% -18.53%
===========================================
Files 1789 1193 -596
Lines 131570 101689 -29881
Branches 19008 14280 -4728
===========================================
- Hits 51797 21191 -30606
- Misses 73195 77710 +4515
+ Partials 6578 2788 -3790
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
3c9071a
to
e5e052f
Compare
org.wso2.carbon.apimgt.common.analytics.publishers.dto.URITemplate uriTemplateObj | ||
= new org.wso2.carbon.apimgt.common.analytics.publishers.dto.URITemplate(); | ||
if (uriTemplate.getHttpMethod() != null && uriTemplate.getHttpMethod() | ||
.equals(messageContext.getProperty("api.ut.HTTP_METHOD")) && uriTemplate.getUrlPattern() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -100,8 +102,32 @@ private static APIDTO fromAPItoDTO(API model) { | |||
urlMappingDTO.setThrottlingPolicy(urlMapping.getThrottlingPolicy()); | |||
urlMappingDTO.setUrlPattern(urlMapping.getUrlPattern()); | |||
urlMappingDTO.setScopes(urlMapping.getScopes()); | |||
List<OperationPolicyDTO> operationPolicyDTOList = new ArrayList<>(); | |||
for(OperationPolicy operationPolicy: urlMapping.getOperationPolicies()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
urlMappingsDTO.add(urlMappingDTO); | ||
} | ||
List<OperationPolicyDTO> apiPolicies = new ArrayList<>(); | ||
for(OperationPolicy apiPolicy: model.getApiPolicies()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
@@ -132,8 +158,32 @@ public static APIListDTO fromAPIToAPIListDTO(API model) { | |||
urlMappingDTO.setThrottlingPolicy(urlMapping.getThrottlingPolicy()); | |||
urlMappingDTO.setUrlPattern(urlMapping.getUrlPattern()); | |||
urlMappingDTO.setScopes(urlMapping.getScopes()); | |||
List<OperationPolicyDTO> operationPolicyDTOList = new ArrayList<>(); | |||
for(OperationPolicy operationPolicy: urlMapping.getOperationPolicies()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
urlMappingsDTO.add(urlMappingDTO); | ||
} | ||
List<OperationPolicyDTO> apiPolicies = new ArrayList<>(); | ||
for(OperationPolicy apiPolicy: model.getApiPolicies()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting issue. You can use https://tharika.medium.com/how-to-setup-code-formatting-in-my-ide-86374ec8fbd2 to fix the formatting using a template instead of requiring to manually do it.
cf9ace4
to
2a61dfa
Compare
@@ -1170,10 +1177,16 @@ private void attachURlMappingDetailsOfApiProduct(Connection connection, API api) | |||
} | |||
} | |||
} | |||
|
|||
if(configs.containsKey(POLICY_ENABLED_FOR_ANALYTICS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
@@ -1260,6 +1273,112 @@ private void attachURLMappingDetails(Connection connection, String revisionId, A | |||
} | |||
} | |||
} | |||
|
|||
if(configs.containsKey(POLICY_ENABLED_FOR_ANALYTICS)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
Replication of #12207 |
Purpose
Goals
Load API and Operation Policies of the APIs/API Products to the gateway and send the corresponding policies in the analytics event.
Approach
enablePolicy
is introduced underanalytics
configuration indeployment.toml
file. If this is enabled then operation and API policies will get loaded to the analytics event