-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[TT-11913] Implement OAS contract for analytics plugin #6861
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
API Changes --- prev.txt 2025-02-06 10:58:27.760336687 +0000
+++ current.txt 2025-02-06 10:58:22.886279372 +0000
@@ -323,10 +323,15 @@
enabled in OAS API definition.
type AnalyticsPluginConfig struct {
- Enabled bool `bson:"enable" json:"enable,omitempty"`
+ // Enabled activates the custom plugin
+ Enabled bool `bson:"enable" json:"enable,omitempty"`
+ // PluginPath is the path to the shared object file or path to js code.
PluginPath string `bson:"plugin_path" json:"plugin_path,omitempty"`
- FuncName string `bson:"func_name" json:"func_name,omitempty"`
+ // FunctionName is the name of the method.
+ FuncName string `bson:"func_name" json:"func_name,omitempty"`
}
+ AnalyticsPluginConfig holds the configuration for the analytics custom
+ function plugins
type AuthConfig struct {
Name string `mapstructure:"name" bson:"name" json:"name"`
@@ -888,7 +893,6 @@
PostKeyAuth []MiddlewareDefinition `bson:"post_key_auth" json:"post_key_auth"`
AuthCheck MiddlewareDefinition `bson:"auth_check" json:"auth_check"`
Response []MiddlewareDefinition `bson:"response" json:"response"`
- TrafficLogs []MiddlewareDefinition `bson:"traffic_logs" json:"traffic_logs"`
Driver MiddlewareDriver `bson:"driver" json:"driver"`
IdExtractor MiddlewareIdExtractor `bson:"id_extractor" json:"id_extractor"`
}
@@ -2444,6 +2448,16 @@
func (c *ContextVariables) Fill(api apidef.APIDefinition)
Fill fills *ContextVariables from apidef.APIDefinition.
+type CustomAnalyticsPlugins []CustomPlugin
+ CustomAnalyticsPlugins is a list of CustomPlugin objects for analytics.
+
+func (c *CustomAnalyticsPlugins) ExtractTo(api *apidef.APIDefinition)
+ ExtractTo extracts CustomAnalyticsPlugins into AnalyticsPlugin of supplied
+ api.
+
+func (c *CustomAnalyticsPlugins) Fill(api apidef.APIDefinition)
+ Fill fills CustomAnalyticsPlugins from AnalyticsPlugin in the supplied api.
+
type CustomKeyLifetime struct {
// Enabled enables custom maximum retention for keys for the API
//
@@ -4088,7 +4102,7 @@
CustomRetentionPeriod ReadableDuration `bson:"customRetentionPeriod,omitempty" json:"customRetentionPeriod,omitempty"`
// Plugins configures custom plugins to allow for extensive modifications to analytics records
// The plugins would be executed in the order of configuration in the list.
- Plugins CustomPlugins `bson:"plugins,omitempty" json:"plugins,omitempty"`
+ Plugins CustomAnalyticsPlugins `bson:"plugins,omitempty" json:"plugins,omitempty"`
}
TrafficLogs holds configuration about API log analytics.
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
30a2ad6
to
df933be
Compare
|
User description
TT-11913
Description
TT-11913
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Replaced
TrafficLogs
plugins withCustomAnalyticsPlugins
.Added
CustomAnalyticsPlugins
type withFill
andExtractTo
methods.Updated test cases to validate
CustomAnalyticsPlugins
functionality.Removed unused
TrafficLogs
middleware section fromMiddlewareSection
.Changes walkthrough 📝
api_definitions.go
Removed `TrafficLogs` middleware section.
apidef/api_definitions.go
TrafficLogs
middleware section fromMiddlewareSection
.middleware.go
Introduced `CustomAnalyticsPlugins` for analytics.
apidef/oas/middleware.go
Plugins
inTrafficLogs
withCustomAnalyticsPlugins
.CustomAnalyticsPlugins
type withFill
andExtractTo
methods.TrafficLogs
plugins.middleware_test.go
Updated tests for `CustomAnalyticsPlugins`.
apidef/oas/middleware_test.go
CustomAnalyticsPlugins
.CustomAnalyticsPlugins
properties.