From 996e18df0b5be89dd7285b10a9d6dcb98bfcf711 Mon Sep 17 00:00:00 2001 From: tharindu1st Date: Thu, 26 Oct 2023 13:11:52 +0530 Subject: [PATCH] fix helm chart changes --- .../discovery/config/enforcer/analytics.proto | 2 + adapter/config/default_config.go | 4 +- adapter/config/types.go | 7 +- adapter/internal/discovery/xds/marshaller.go | 1 + .../discovery/config/enforcer/analytics.pb.go | 68 ++-- .../config/enforcer/analytics_publisher.pb.go | 2 +- .../reporter/elk/ELKCounterMetric.java | 6 +- .../enforcer/analytics/AnalyticsFilter.java | 15 + .../apk/enforcer/config/ConfigHolder.java | 6 + .../apk/enforcer/config/dto/AnalyticsDTO.java | 13 + .../discovery/config/enforcer/Analytics.java | 327 ++++++++++++++++++ .../config/enforcer/AnalyticsOrBuilder.java | 54 +++ .../config/enforcer/AnalyticsProto.java | 29 +- .../gateway-runtime-deployment.yaml | 3 +- .../gateway-components/log-conf.yaml | 27 +- 15 files changed, 518 insertions(+), 46 deletions(-) diff --git a/adapter/api/proto/wso2/discovery/config/enforcer/analytics.proto b/adapter/api/proto/wso2/discovery/config/enforcer/analytics.proto index 3120ccfd1..8e65d9e82 100644 --- a/adapter/api/proto/wso2/discovery/config/enforcer/analytics.proto +++ b/adapter/api/proto/wso2/discovery/config/enforcer/analytics.proto @@ -32,4 +32,6 @@ message Analytics { // Receiver grpc Service Configuration Service service = 3; // Analytics type + map properties = 4; + } diff --git a/adapter/config/default_config.go b/adapter/config/default_config.go index 14c381362..1089937d3 100644 --- a/adapter/config/default_config.go +++ b/adapter/config/default_config.go @@ -215,6 +215,8 @@ var defaultConfig = &Config{ DisableSslVerification: false, }, Analytics: analytics{ + Enabled: false, + Properties: map[string]string{}, Adapter: analyticsAdapter{ Enabled: false, BufferFlushInterval: 1000000000, @@ -222,7 +224,6 @@ var defaultConfig = &Config{ GRPCRequestTimeout: 20000000000, }, Enforcer: analyticsEnforcer{ - // todo(amali) Rename? LogReceiver: authService{ Port: 18090, MaxMessageSize: 1000000000, @@ -235,6 +236,7 @@ var defaultConfig = &Config{ QueueSize: 1000, }, }, + Publisher: []analyticsPublisher{}, }, }, Tracing: tracing{ diff --git a/adapter/config/types.go b/adapter/config/types.go index eb145d27b..c4fb85726 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -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 { diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index d291230b9..cd7c7f530 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -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, diff --git a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics.pb.go b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics.pb.go index 1a747233d..a67978ac1 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics.pb.go @@ -45,7 +45,9 @@ type Analytics struct { // Analytics Publishers AnalyticsPublisher []*AnalyticsPublisher `protobuf:"bytes,2,rep,name=analytics_publisher,json=analyticsPublisher,proto3" json:"analytics_publisher,omitempty"` // Receiver grpc Service Configuration - Service *Service `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` // Analytics type + Service *Service `protobuf:"bytes,3,opt,name=service,proto3" json:"service,omitempty"` + // Analytics type + Properties map[string]string `protobuf:"bytes,4,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *Analytics) Reset() { @@ -101,6 +103,13 @@ func (x *Analytics) GetService() *Service { return nil } +func (x *Analytics) GetProperties() map[string]string { + if x != nil { + return x.Properties + } + return nil +} + var File_wso2_discovery_config_enforcer_analytics_proto protoreflect.FileDescriptor var file_wso2_discovery_config_enforcer_analytics_proto_rawDesc = []byte{ @@ -115,7 +124,7 @@ var file_wso2_discovery_config_enforcer_analytics_proto_rawDesc = []byte{ 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, - 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x01, 0x0a, 0x09, 0x41, 0x6e, 0x61, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe7, 0x02, 0x0a, 0x09, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x63, 0x0a, 0x13, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x75, @@ -128,17 +137,26 @@ var file_wso2_discovery_config_enforcer_analytics_proto_rawDesc = []byte{ 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, - 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x93, 0x01, 0x0a, 0x2f, 0x6f, 0x72, 0x67, - 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, - 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0e, 0x41, 0x6e, - 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x59, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x77, + 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x41, 0x6e, + 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, + 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x69, 0x65, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x42, 0x93, 0x01, 0x0a, 0x2f, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, + 0x61, 0x70, 0x6b, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x64, 0x69, 0x73, + 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, + 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0e, 0x41, 0x6e, 0x61, 0x6c, 0x79, 0x74, 0x69, 0x63, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -153,20 +171,22 @@ func file_wso2_discovery_config_enforcer_analytics_proto_rawDescGZIP() []byte { return file_wso2_discovery_config_enforcer_analytics_proto_rawDescData } -var file_wso2_discovery_config_enforcer_analytics_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_config_enforcer_analytics_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_wso2_discovery_config_enforcer_analytics_proto_goTypes = []interface{}{ (*Analytics)(nil), // 0: wso2.discovery.config.enforcer.Analytics - (*AnalyticsPublisher)(nil), // 1: wso2.discovery.config.enforcer.AnalyticsPublisher - (*Service)(nil), // 2: wso2.discovery.config.enforcer.Service + nil, // 1: wso2.discovery.config.enforcer.Analytics.PropertiesEntry + (*AnalyticsPublisher)(nil), // 2: wso2.discovery.config.enforcer.AnalyticsPublisher + (*Service)(nil), // 3: wso2.discovery.config.enforcer.Service } var file_wso2_discovery_config_enforcer_analytics_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.config.enforcer.Analytics.analytics_publisher:type_name -> wso2.discovery.config.enforcer.AnalyticsPublisher - 2, // 1: wso2.discovery.config.enforcer.Analytics.service:type_name -> wso2.discovery.config.enforcer.Service - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 2, // 0: wso2.discovery.config.enforcer.Analytics.analytics_publisher:type_name -> wso2.discovery.config.enforcer.AnalyticsPublisher + 3, // 1: wso2.discovery.config.enforcer.Analytics.service:type_name -> wso2.discovery.config.enforcer.Service + 1, // 2: wso2.discovery.config.enforcer.Analytics.properties:type_name -> wso2.discovery.config.enforcer.Analytics.PropertiesEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_wso2_discovery_config_enforcer_analytics_proto_init() } @@ -196,7 +216,7 @@ func file_wso2_discovery_config_enforcer_analytics_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_wso2_discovery_config_enforcer_analytics_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics_publisher.pb.go b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics_publisher.pb.go index 9d57c2901..4da7aa15b 100644 --- a/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics_publisher.pb.go +++ b/adapter/pkg/discovery/api/wso2/discovery/config/enforcer/analytics_publisher.pb.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except diff --git a/gateway/enforcer/org.wso2.apk.enforcer.analytics.publishers/src/main/java/org/wso2/apk/enforcer/analytics/publisher/reporter/elk/ELKCounterMetric.java b/gateway/enforcer/org.wso2.apk.enforcer.analytics.publishers/src/main/java/org/wso2/apk/enforcer/analytics/publisher/reporter/elk/ELKCounterMetric.java index 5bc64731a..6c82328b3 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer.analytics.publishers/src/main/java/org/wso2/apk/enforcer/analytics/publisher/reporter/elk/ELKCounterMetric.java +++ b/gateway/enforcer/org.wso2.apk.enforcer.analytics.publishers/src/main/java/org/wso2/apk/enforcer/analytics/publisher/reporter/elk/ELKCounterMetric.java @@ -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; @@ -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; diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java index 1703d82a0..f208dd00f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/analytics/AnalyticsFilter.java @@ -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; @@ -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. @@ -62,7 +68,16 @@ public class AnalyticsFilter { private AnalyticsFilter() { + AnalyticsDTO analyticsConfig = ConfigHolder.getInstance().getConfig().getAnalyticsConfig(); + Map 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 analyticsPublisherConfigDTOList = ConfigHolder.getInstance().getConfig().getAnalyticsConfig().getAnalyticsPublisherConfigDTOList(); publisher.init(analyticsPublisherConfigDTOList); diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java index 109a0b29e..695c3994f 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/ConfigHolder.java @@ -378,6 +378,12 @@ private void populateAnalyticsConfig(Analytics analyticsConfig) { AnalyticsDTO analyticsDTO = new AnalyticsDTO(); analyticsDTO.setServerConfig(serverConfig); analyticsDTO.setEnabled(analyticsConfig.getEnabled()); + Map propertiesMap = analyticsConfig.getPropertiesMap(); + Map resolvedProperties = new HashMap<>(); + for (Map.Entry propertiesEntry : propertiesMap.entrySet()) { + resolvedProperties.put(propertiesEntry.getKey(), getEnvValue(propertiesEntry.getValue())); + } + analyticsDTO.setProperties(resolvedProperties); for (AnalyticsPublisher analyticsPublisher : analyticsConfig.getAnalyticsPublisherList()) { Map resolvedConfigMap = new HashMap<>(); Map configPropertiesMap = analyticsPublisher.getConfigPropertiesMap(); diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/dto/AnalyticsDTO.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/dto/AnalyticsDTO.java index 0dae483ca..6e9e7e11b 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/dto/AnalyticsDTO.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/config/dto/AnalyticsDTO.java @@ -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. @@ -28,6 +30,7 @@ public class AnalyticsDTO { private boolean enabled = false; + private Map properties = new HashMap<>(); private List analyticsPublisherConfigDTOList = new ArrayList<>(); private AnalyticsReceiverConfigDTO serverConfig; @@ -60,4 +63,14 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } + + public Map getProperties() { + + return properties; + } + + public void setProperties(Map properties) { + + this.properties = properties; + } } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Analytics.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Analytics.java index e5b2ae943..4ebb36cb4 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Analytics.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/Analytics.java @@ -77,6 +77,19 @@ private Analytics( break; } + case 34: { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000002; + } + com.google.protobuf.MapEntry + properties__ = input.readMessage( + PropertiesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + properties_.getMutableMap().put( + properties__.getKey(), properties__.getValue()); + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -104,6 +117,18 @@ private Analytics( return org.wso2.apk.enforcer.discovery.config.enforcer.AnalyticsProto.internal_static_wso2_discovery_config_enforcer_Analytics_descriptor; } + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 4: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { @@ -221,6 +246,103 @@ public org.wso2.apk.enforcer.discovery.config.enforcer.ServiceOrBuilder getServi return getService(); } + public static final int PROPERTIES_FIELD_NUMBER = 4; + private static final class PropertiesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.wso2.apk.enforcer.discovery.config.enforcer.AnalyticsProto.internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + + @java.lang.Override + public boolean containsProperties( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.lang.String getPropertiesOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.lang.String getPropertiesOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -244,6 +366,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (service_ != null) { output.writeMessage(3, getService()); } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetProperties(), + PropertiesDefaultEntryHolder.defaultEntry, + 4); unknownFields.writeTo(output); } @@ -265,6 +393,16 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, getService()); } + for (java.util.Map.Entry entry + : internalGetProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry + properties__ = PropertiesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, properties__); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -289,6 +427,8 @@ public boolean equals(final java.lang.Object obj) { if (!getService() .equals(other.getService())) return false; } + if (!internalGetProperties().equals( + other.internalGetProperties())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -311,6 +451,10 @@ public int hashCode() { hash = (37 * hash) + SERVICE_FIELD_NUMBER; hash = (53 * hash) + getService().hashCode(); } + if (!internalGetProperties().getMap().isEmpty()) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetProperties().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -418,6 +562,28 @@ public static final class Builder extends return org.wso2.apk.enforcer.discovery.config.enforcer.AnalyticsProto.internal_static_wso2_discovery_config_enforcer_Analytics_descriptor; } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 4: + return internalGetProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 4: + return internalGetMutableProperties(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { @@ -459,6 +625,7 @@ public Builder clear() { service_ = null; serviceBuilder_ = null; } + internalGetMutableProperties().clear(); return this; } @@ -501,6 +668,8 @@ public org.wso2.apk.enforcer.discovery.config.enforcer.Analytics buildPartial() } else { result.service_ = serviceBuilder_.build(); } + result.properties_ = internalGetProperties(); + result.properties_.makeImmutable(); onBuilt(); return result; } @@ -581,6 +750,8 @@ public Builder mergeFrom(org.wso2.apk.enforcer.discovery.config.enforcer.Analyti if (other.hasService()) { mergeService(other.getService()); } + internalGetMutableProperties().mergeFrom( + other.internalGetProperties()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -1108,6 +1279,162 @@ public org.wso2.apk.enforcer.discovery.config.enforcer.ServiceOrBuilder getServi } return serviceBuilder_; } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> properties_; + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + private com.google.protobuf.MapField + internalGetMutableProperties() { + onChanged();; + if (properties_ == null) { + properties_ = com.google.protobuf.MapField.newMapField( + PropertiesDefaultEntryHolder.defaultEntry); + } + if (!properties_.isMutable()) { + properties_ = properties_.copy(); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + + @java.lang.Override + public boolean containsProperties( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetProperties().getMap().containsKey(key); + } + /** + * Use {@link #getPropertiesMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.lang.String getPropertiesOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + @java.lang.Override + + public java.lang.String getPropertiesOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearProperties() { + internalGetMutableProperties().getMutableMap() + .clear(); + return this; + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + + public Builder removeProperties( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableProperties() { + return internalGetMutableProperties().getMutableMap(); + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + public Builder putProperties( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new java.lang.NullPointerException(); } + if (value == null) { throw new java.lang.NullPointerException(); } + internalGetMutableProperties().getMutableMap() + .put(key, value); + return this; + } + /** + *
+     * Analytics type
+     * 
+ * + * map<string, string> properties = 4; + */ + + public Builder putAllProperties( + java.util.Map values) { + internalGetMutableProperties().getMutableMap() + .putAll(values); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsOrBuilder.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsOrBuilder.java index 290a3e564..527016baa 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsOrBuilder.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsOrBuilder.java @@ -83,4 +83,58 @@ org.wso2.apk.enforcer.discovery.config.enforcer.AnalyticsPublisherOrBuilder getA * .wso2.discovery.config.enforcer.Service service = 3; */ org.wso2.apk.enforcer.discovery.config.enforcer.ServiceOrBuilder getServiceOrBuilder(); + + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + int getPropertiesCount(); + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + boolean containsProperties( + java.lang.String key); + /** + * Use {@link #getPropertiesMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getProperties(); + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + java.util.Map + getPropertiesMap(); + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + + java.lang.String getPropertiesOrDefault( + java.lang.String key, + java.lang.String defaultValue); + /** + *
+   * Analytics type
+   * 
+ * + * map<string, string> properties = 4; + */ + + java.lang.String getPropertiesOrThrow( + java.lang.String key); } diff --git a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsProto.java b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsProto.java index 0e090a5ab..a3bbbe4e3 100644 --- a/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsProto.java +++ b/gateway/enforcer/org.wso2.apk.enforcer/src/main/java/org/wso2/apk/enforcer/discovery/config/enforcer/AnalyticsProto.java @@ -19,6 +19,11 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_wso2_discovery_config_enforcer_Analytics_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -32,15 +37,19 @@ public static void registerAllExtensions( "cs.proto\022\036wso2.discovery.config.enforcer" + "\032,wso2/discovery/config/enforcer/service" + ".proto\0328wso2/discovery/config/enforcer/a" + - "nalytics_publisher.proto\"\247\001\n\tAnalytics\022\017" + + "nalytics_publisher.proto\"\251\002\n\tAnalytics\022\017" + "\n\007enabled\030\001 \001(\010\022O\n\023analytics_publisher\030\002" + " \003(\01322.wso2.discovery.config.enforcer.An" + "alyticsPublisher\0228\n\007service\030\003 \001(\0132\'.wso2" + - ".discovery.config.enforcer.ServiceB\223\001\n/o" + - "rg.wso2.apk.enforcer.discovery.config.en" + - "forcerB\016AnalyticsProtoP\001ZNgithub.com/env" + - "oyproxy/go-control-plane/wso2/discovery/" + - "config/enforcer;enforcerb\006proto3" + ".discovery.config.enforcer.Service\022M\n\npr" + + "operties\030\004 \003(\01329.wso2.discovery.config.e" + + "nforcer.Analytics.PropertiesEntry\0321\n\017Pro" + + "pertiesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t" + + ":\0028\001B\223\001\n/org.wso2.apk.enforcer.discovery" + + ".config.enforcerB\016AnalyticsProtoP\001ZNgith" + + "ub.com/envoyproxy/go-control-plane/wso2/" + + "discovery/config/enforcer;enforcerb\006prot" + + "o3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -53,7 +62,13 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_Analytics_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Analytics_descriptor, - new java.lang.String[] { "Enabled", "AnalyticsPublisher", "Service", }); + new java.lang.String[] { "Enabled", "AnalyticsPublisher", "Service", "Properties", }); + internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_descriptor = + internal_static_wso2_discovery_config_enforcer_Analytics_descriptor.getNestedTypes().get(0); + internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_wso2_discovery_config_enforcer_Analytics_PropertiesEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); org.wso2.apk.enforcer.discovery.config.enforcer.ServiceProto.getDescriptor(); org.wso2.apk.enforcer.discovery.config.enforcer.AnalyticsPublisherProto.getDescriptor(); } diff --git a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml index f3c2cef11..92185aa21 100644 --- a/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml +++ b/helm-charts/templates/data-plane/gateway-components/gateway-runtime/gateway-runtime-deployment.yaml @@ -90,7 +90,6 @@ spec: value: admin - name: JAVA_OPTS value: -Dhttpclient.hostnameVerifier=AllowAll -Xms512m -Xmx512m -XX:MaxRAMFraction=2 - {{- end }} volumeMounts: - name: tmp mountPath: /tmp @@ -358,6 +357,6 @@ spec: secret: secretName: {{ .Values.wso2.apk.idp.tls.secretName }} {{ end }} - {{end}} - name: tmp emptyDir: {} + {{end}} diff --git a/helm-charts/templates/data-plane/gateway-components/log-conf.yaml b/helm-charts/templates/data-plane/gateway-components/log-conf.yaml index 50130ba18..e9c4a5663 100644 --- a/helm-charts/templates/data-plane/gateway-components/log-conf.yaml +++ b/helm-charts/templates/data-plane/gateway-components/log-conf.yaml @@ -143,12 +143,29 @@ data: {{- if and .Values.wso2.apk.dp.gatewayRuntime.analytics .Values.wso2.apk.dp.gatewayRuntime.analytics.enabled}} [analytics] - enabled = true - {{- if .Values.wso2.apk.dp.gatewayRuntime.analytics.type }} - type = "{{ .Values.wso2.apk.dp.gatewayRuntime.analytics.type}}" - {{- end }} - + enabled = true + {{- if and .Values.wso2.apk.dp.gatewayRuntime.analytics.properties}} + [analytics.properties] + {{- range $key, $value := .Values.wso2.apk.dp.gatewayRuntime.analytics.properties}} + "{{$key}}" = "{{$value}}" + {{- end}} + {{- end }} + {{- if and .Values.wso2.apk.dp.gatewayRuntime.analytics.publisher}} + [analytics.enforcer] + {{- range .Values.wso2.apk.dp.gatewayRuntime.analytics.publisher}} + [[analytics.enforcer.publisher]] + enabled = {{ .enabled }} + type = "{{ .type }}" + {{- if and .properties}} + [analytics.enforcer.publisher.configProperties] + {{- range $key, $value := .properties}} + "{{$key}}" = "{{$value}}" + {{- end }} + {{- end}} + {{- end }} + {{- end }} [analytics.adapter] + enabled = true bufferFlushInterval = "1s" bufferSizeBytes = 16384 gRPCRequestTimeout = "20s"