[TT-11125] Add trace_id to traffic logs #899
Closed
probelabs / Visor: quality
succeeded
Oct 2, 2025 in 4m 47s
✅ Check Passed (Warnings Found)
quality check passed. Found 1 warning, but fail_if condition was not met.
Details
📊 Summary
- Total Issues: 3
- Warning Issues: 1
🐛 Issues by Category
⚡ Performance (3)
⚠️ analytics/analytics.go:78 - The newTraceIDfield is mapped to atraceiddatabase column. Trace IDs are commonly used for lookups, and querying this column without an index will lead to slow, full-table-scan queries, severely degrading performance on large datasets.- ℹ️ analytics/analytics.go:78 - The addition of the
TraceIDstring field increases the memory footprint of eachAnalyticsRecord. In a high-throughput environment like Tyk Pump, this small increase per record can lead to a significant rise in overall memory consumption. - ℹ️ analytics/analytics_test.go:173 - The new test for
RemoveIgnoredFieldscovers a function that uses an inefficient, reflection-based nested loop to remove fields from records. This function runs on a hot path for every record when field exclusion is configured, which can create significant CPU overhead.
Generated by Visor - AI-powered code review
Annotations
Check warning on line 78 in analytics/analytics.go
probelabs / Visor: quality
performance Issue
The new `TraceID` field is mapped to a `traceid` database column. Trace IDs are commonly used for lookups, and querying this column without an index will lead to slow, full-table-scan queries, severely degrading performance on large datasets.
Raw output
Ensure that a database index is created for the `traceid` column in all supported SQL databases. This should be documented as a requirement for this feature, and migration scripts should be provided if applicable.
Check notice on line 78 in analytics/analytics.go
probelabs / Visor: quality
performance Issue
The addition of the `TraceID` string field increases the memory footprint of each `AnalyticsRecord`. In a high-throughput environment like Tyk Pump, this small increase per record can lead to a significant rise in overall memory consumption.
Raw output
This is an acceptable trade-off for the added functionality. However, the impact on memory should be documented and considered for capacity planning in production environments.
Check notice on line 185 in analytics/analytics_test.go
probelabs / Visor: quality
performance Issue
The new test for `RemoveIgnoredFields` covers a function that uses an inefficient, reflection-based nested loop to remove fields from records. This function runs on a hot path for every record when field exclusion is configured, which can create significant CPU overhead.
Raw output
While this is a pre-existing issue, it's worth noting. To optimize, consider caching a map of JSON tags to struct fields upon pump initialization. This would change the lookup from a slow O(N) iteration to a fast O(1) map lookup per field, significantly improving performance for users of this feature.
Loading