-
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-11910]: added tag headers to traffic logs and tests #6818
base: master
Are you sure you want to change the base?
Conversation
9967353
to
230f56e
Compare
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
apidef/oas/middleware_test.go
Outdated
@@ -175,6 +175,55 @@ func TestGlobal(t *testing.T) { | |||
}) | |||
} | |||
|
|||
func TestTrafficLogs(t *testing.T) { | |||
t.Parallel() |
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.
t.Parallel is not necessary. We limit parallelization due to StartTest details, also it's only meant for slow tests. Data model conversions don't strike me as slow.
Please add some whitespace before assertions, consider readability; move var
declarations to start of test functions to not intermix with logic that's being tested.
@@ -266,7 +266,6 @@ func TestOAS_ExtractTo_ResetAPIDefinition(t *testing.T) { | |||
"APIDefinition.ExpireAnalyticsAfter", | |||
"APIDefinition.ResponseProcessors[0].Name", | |||
"APIDefinition.ResponseProcessors[0].Options", | |||
"APIDefinition.TagHeaders[0]", |
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.
Was looking for this explicitly, 🙌 👍
API Changes --- prev.txt 2025-01-07 13:51:15.332042747 +0000
+++ current.txt 2025-01-07 13:51:10.853017834 +0000
@@ -3929,6 +3929,9 @@
// Enabled enables traffic log analytics for the API.
// Tyk classic API definition: `do_not_track`.
Enabled bool `bson:"enabled" json:"enabled"`
+ // TagHeaders is a string array of HTTP headers that can be extracted
+ // and transformed into analytics tags (statistics aggregated by tag, per hour).
+ TagHeaders []string `bson:"tagHeaders" json:"tagHeaders,omitempty"`
}
TrafficLogs holds configuration about API log 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.
I've applied the godoc change as the CI didn't let it pass.
The remaining feedback is cosmetic, please take care if it before merging.
LGTM.
Co-authored-by: Jeffy Mathew <[email protected]>
c91180c
to
9128a1c
Compare
Quality Gate failedFailed conditions |
User description
Description
Implemented TagHeaders in Tyk OAS API Definition
Related Issue
TT-11910
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Added
TagHeaders
field toTrafficLogs
for analytic tags.Updated
TrafficLogs
methods to handleTagHeaders
.Introduced new tests for
TrafficLogs
functionality.Extended API schema to include
TagHeaders
inX-Tyk-TrafficLogs
.Changes walkthrough 📝
middleware.go
Add `TagHeaders` field and update methods
apidef/oas/middleware.go
TagHeaders
field toTrafficLogs
struct.Fill
andExtractTo
methods to handleTagHeaders
.x-tyk-api-gateway.json
Extend schema to include `tagHeaders`
apidef/oas/schema/x-tyk-api-gateway.json
tagHeaders
property toX-Tyk-TrafficLogs
schema.tagHeaders
as an array of strings.middleware_test.go
Add tests for `TrafficLogs` with `TagHeaders`
apidef/oas/middleware_test.go
TrafficLogs
withTagHeaders
.TagHeaders
.oas_test.go
Remove redundant `TagHeaders` test case
apidef/oas/oas_test.go
TagHeaders
.