Skip to content

Commit

Permalink
fix helm chart changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tharindu1st committed Oct 26, 2023
1 parent 9edd8d6 commit 996e18d
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ message Analytics {
// Receiver grpc Service Configuration
Service service = 3;
// Analytics type
map<string, string> properties = 4;

}
4 changes: 3 additions & 1 deletion adapter/config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,15 @@ var defaultConfig = &Config{
DisableSslVerification: false,
},
Analytics: analytics{
Enabled: false,
Properties: map[string]string{},
Adapter: analyticsAdapter{
Enabled: false,
BufferFlushInterval: 1000000000,
BufferSizeBytes: 16384,
GRPCRequestTimeout: 20000000000,
},
Enforcer: analyticsEnforcer{
// todo(amali) Rename?
LogReceiver: authService{
Port: 18090,
MaxMessageSize: 1000000000,
Expand All @@ -235,6 +236,7 @@ var defaultConfig = &Config{
QueueSize: 1000,
},
},
Publisher: []analyticsPublisher{},
},
},
Tracing: tracing{
Expand Down
7 changes: 4 additions & 3 deletions adapter/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,10 @@ type cache struct {
}

type analytics struct {
Enabled bool
Adapter analyticsAdapter
Enforcer analyticsEnforcer
Enabled bool
Adapter analyticsAdapter
Enforcer analyticsEnforcer
Properties map[string]string
}

type tracing struct {
Expand Down
1 change: 1 addition & 0 deletions adapter/internal/discovery/xds/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config {
}
analytics := &enforcer.Analytics{
Enabled: config.Analytics.Enabled,
Properties: config.Analytics.Properties,
AnalyticsPublisher: marshalAnalyticsPublishers(*config),
Service: &enforcer.Service{
Port: config.Analytics.Enforcer.LogReceiver.Port,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package org.wso2.apk.enforcer.analytics.publisher.reporter.elk;

import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.apk.enforcer.analytics.publisher.exception.MetricReportingException;
import org.wso2.apk.enforcer.analytics.publisher.reporter.CounterMetric;
import org.wso2.apk.enforcer.analytics.publisher.reporter.GenericInputValidator;
Expand All @@ -33,7 +33,7 @@
* Log Counter Metrics class, This class can be used to log analytics event to a separate log file.
*/
public class ELKCounterMetric implements CounterMetric {
private static final Logger log = LoggerFactory.getLogger(ELKCounterMetric.class);
private static final Log log = LogFactory.getLog(ELKCounterMetric.class);
private final String name;
private final Gson gson;
private MetricSchema schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.wso2.apk.enforcer.commons.model.RequestContext;
import org.wso2.apk.enforcer.commons.model.ResourceConfig;
import org.wso2.apk.enforcer.config.ConfigHolder;
import org.wso2.apk.enforcer.config.dto.AnalyticsDTO;
import org.wso2.apk.enforcer.config.dto.AnalyticsPublisherConfigDTO;
import org.wso2.apk.enforcer.constants.APIConstants;
import org.wso2.apk.enforcer.constants.AnalyticsConstants;
Expand All @@ -45,6 +46,11 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static org.wso2.apk.enforcer.analytics.AnalyticsConstants.CHOREO_FAULT_SCHEMA;
import static org.wso2.apk.enforcer.analytics.AnalyticsConstants.CHOREO_RESPONSE_SCHEMA;
import static org.wso2.apk.enforcer.analytics.AnalyticsConstants.IS_CHOREO_DEPLOYMENT_CONFIG_KEY;

/**
* This is the filter is for Analytics.
Expand All @@ -62,7 +68,16 @@ public class AnalyticsFilter {

private AnalyticsFilter() {

AnalyticsDTO analyticsConfig = ConfigHolder.getInstance().getConfig().getAnalyticsConfig();
Map<String, Object> properties = analyticsConfig.getProperties();
publisher = new DefaultAnalyticsEventPublisher();
boolean choreoDeployment = false;
if (properties != null){
choreoDeployment = (boolean) properties.getOrDefault(IS_CHOREO_DEPLOYMENT_CONFIG_KEY,false);
}
if (choreoDeployment){
publisher = new DefaultAnalyticsEventPublisher(CHOREO_RESPONSE_SCHEMA, CHOREO_FAULT_SCHEMA);
}
List<AnalyticsPublisherConfigDTO> analyticsPublisherConfigDTOList =
ConfigHolder.getInstance().getConfig().getAnalyticsConfig().getAnalyticsPublisherConfigDTOList();
publisher.init(analyticsPublisherConfigDTOList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@ private void populateAnalyticsConfig(Analytics analyticsConfig) {
AnalyticsDTO analyticsDTO = new AnalyticsDTO();
analyticsDTO.setServerConfig(serverConfig);
analyticsDTO.setEnabled(analyticsConfig.getEnabled());
Map<String, String> propertiesMap = analyticsConfig.getPropertiesMap();
Map<String, Object> resolvedProperties = new HashMap<>();
for (Map.Entry<String, String> propertiesEntry : propertiesMap.entrySet()) {
resolvedProperties.put(propertiesEntry.getKey(), getEnvValue(propertiesEntry.getValue()));
}
analyticsDTO.setProperties(resolvedProperties);
for (AnalyticsPublisher analyticsPublisher : analyticsConfig.getAnalyticsPublisherList()) {
Map<String, String> resolvedConfigMap = new HashMap<>();
Map<String, String> configPropertiesMap = analyticsPublisher.getConfigPropertiesMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
package org.wso2.apk.enforcer.config.dto;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Holds the analytics data publishing related Configuration.
Expand All @@ -28,6 +30,7 @@ public class AnalyticsDTO {

private boolean enabled = false;

private Map<String,Object> properties = new HashMap<>();
private List<AnalyticsPublisherConfigDTO> analyticsPublisherConfigDTOList = new ArrayList<>();
private AnalyticsReceiverConfigDTO serverConfig;

Expand Down Expand Up @@ -60,4 +63,14 @@ public void setEnabled(boolean enabled) {

this.enabled = enabled;
}

public Map<String, Object> getProperties() {

return properties;
}

public void setProperties(Map<String, Object> properties) {

this.properties = properties;
}
}
Loading

0 comments on commit 996e18d

Please sign in to comment.