[TT-14991] Fixed decode settings to fallback to global settings #901
✅ Check Passed
overview check completed successfully with no issues found.
Details
📊 Summary
- Total Issues: 1
🐛 Issues by Category
📚 Documentation (1)
- ℹ️ AI_RESPONSE:1 - ### Pull Request Analysis: [TT-14991] Fixed decode settings to fallback to global settings
This pull request addresses a bug in how decoding settings for raw requests and responses are handled, ensuring that pump-specific settings correctly fall back to global configurations.
1. Change Impact Analysis
What this PR accomplishes
The primary goal of this PR is to fix the configuration inheritance logic for raw_request_decoded and raw_response_decoded settings. Previously, if these settings were disabled or not present at the individual pump level, the global settings were ignored. This change ensures that if a pump-level setting is false, the system falls back to the corresponding global setting. This makes the configuration more intuitive and flexible, allowing a global default to be overridden only when explicitly configured at the pump level.
Key Technical Changes
The changes are concentrated in main.go with corresponding tests in main_test.go.
-
Refactored Logic into Helper Functions: The data processing logic within the
filterDatafunction has been modularized and extracted into smaller, single-responsibility functions:getDecodingSettings(pump pumps.Pump): This new function encapsulates the core logic of the fix. It determines the effective decoding settings by combining the pump-specific and global configurations using a logicalOR. The effective setting istrueif either the pump-level or the global-level setting istrue.decodeBase64Data(...): The logic for Base64 decoding the raw request and response has been moved into this dedicated function, improving code clarity.trimRawData(...): The logic for trimming analytics records to a maximum size has also been extracted.
-
Updated
filterDataFunction: The mainfilterDatafunction is now cleaner and more readable. It calls the new helper functions to determine settings, trim data, and perform decoding, rather than containing all the logic inline. -
Comprehensive Unit Tests: A new test suite,
TestGetDecodingSettings, has been added inmain_test.go. It exhaustively tests all possible combinations of pump-level and global-level decoding settings, verifying that the new fallback logic works as expected in every scenario.
Affected System Components
- Configuration Handling: The change directly impacts how configurations are interpreted, specifically for analytics data decoding.
- Data Processing Pipeline: The
filterDatafunction, a key part of the analytics processing pipeline, is modified. This function is responsible for preparing analytics records before they are sent to the configured pumps (e.g., CSV, Elasticsearch, Splunk).
2. Architecture Visualization
The following flowchart visualizes the updated logic within the filterData function, highlighting the new decision-making process for applying decoding settings.
flowchart TD
subgraph "filterData Function"
A[Analytics Record Received] --> B{Get Decoding Settings};
B --> C{Should Trim Data?};
C -- Yes --> D[trimRawData];
C -- No --> E;
D --> E{Apply Filters};
E --> F{Remove Ignored Fields};
F --> G{Perform Base64 Decoding?};
G -- Yes --> H[decodeBase64Data];
G -- No --> I[Send to Pump];
H --> I;
end
subgraph "getDecodingSettings Logic"
B1[Start] --> B2{Pump raw_request_decoded is true?};
B2 -- Yes --> B3[Use true for Request Decoding];
B2 -- No --> B4{Global DecodeRawRequest is true?};
B4 -- Yes --> B3;
B4 -- No --> B5[Use false for Request Decoding];
B6[Start] --> B7{Pump raw_response_decoded is true?};
B7 -- Yes --> B8[Use true for Response Decoding];
B7 -- No --> B9{Global DecodeRawResponse is true?};
B9 -- Yes --> B8;
B9 -- No --> B10[Use false for Response Decoding];
end
style getDecodingSettings Logic fill:#f9f,stroke:#333,stroke-width:2px
This diagram illustrates how an analytics record is processed. The key change is in the "Get Decoding Settings" step, which now correctly combines pump and global settings to decide whether the decodeBase64Data step should be executed. The refactoring also clarifies the data trimming, filtering, and field removal steps in the pipeline.
Generated by Visor - AI-powered code review
Annotations
Check notice on line 1 in AI_RESPONSE
probelabs / Visor: overview
documentation Issue
### **Pull Request Analysis: [TT-14991] Fixed decode settings to fallback to global settings**
This pull request addresses a bug in how decoding settings for raw requests and responses are handled, ensuring that pump-specific settings correctly fall back to global configurations.
---
### **1. Change Impact Analysis**
#### **What this PR accomplishes**
The primary goal of this PR is to fix the configuration inheritance logic for `raw_request_decoded` and `raw_response_decoded` settings. Previously, if these settings were disabled or not present at the individual pump level, the global settings were ignored. This change ensures that if a pump-level setting is `false`, the system falls back to the corresponding global setting. This makes the configuration more intuitive and flexible, allowing a global default to be overridden only when explicitly configured at the pump level.
#### **Key Technical Changes**
The changes are concentrated in `main.go` with corresponding tests in `main_test.go`.
1. **Refactored Logic into Helper Functions:** The data processing logic within the `filterData` function has been modularized and extracted into smaller, single-responsibility functions:
* `getDecodingSettings(pump pumps.Pump)`: This new function encapsulates the core logic of the fix. It determines the effective decoding settings by combining the pump-specific and global configurations using a logical `OR`. The effective setting is `true` if either the pump-level or the global-level setting is `true`.
* `decodeBase64Data(...)`: The logic for Base64 decoding the raw request and response has been moved into this dedicated function, improving code clarity.
* `trimRawData(...)`: The logic for trimming analytics records to a maximum size has also been extracted.
2. **Updated `filterData` Function:** The main `filterData` function is now cleaner and more readable. It calls the new helper functions to determine settings, trim data, and perform decoding, rather than containing all the logic inline.
3. **Comprehensive Unit Tests:** A new test suite, `TestGetDecodingSettings`, has been added in `main_test.go`. It exhaustively tests all possible combinations of pump-level and global-level decoding settings, verifying that the new fallback logic works as expected in every scenario.
#### **Affected System Components**
* **Configuration Handling:** The change directly impacts how configurations are interpreted, specifically for analytics data decoding.
* **Data Processing Pipeline:** The `filterData` function, a key part of the analytics processing pipeline, is modified. This function is responsible for preparing analytics records before they are sent to the configured pumps (e.g., CSV, Elasticsearch, Splunk).
---
### **2. Architecture Visualization**
The following flowchart visualizes the updated logic within the `filterData` function, highlighting the new decision-making process for applying decoding settings.
```mermaid
flowchart TD
subgraph "filterData Function"
A[Analytics Record Received] --> B{Get Decoding Settings};
B --> C{Should Trim Data?};
C -- Yes --> D[trimRawData];
C -- No --> E;
D --> E{Apply Filters};
E --> F{Remove Ignored Fields};
F --> G{Perform Base64 Decoding?};
G -- Yes --> H[decodeBase64Data];
G -- No --> I[Send to Pump];
H --> I;
end
subgraph "getDecodingSettings Logic"
B1[Start] --> B2{Pump raw_request_decoded is true?};
B2 -- Yes --> B3[Use true for Request Decoding];
B2 -- No --> B4{Global DecodeRawRequest is true?};
B4 -- Yes --> B3;
B4 -- No --> B5[Use false for Request Decoding];
B6[Start] --> B7{Pump raw_response_decoded is true?};
B7 -- Yes --> B8[Use true for Response Decoding];
B7 -- No --> B9{Global DecodeRawResponse is true?};
B9 -- Yes --> B8;
B9 -- No --> B10[Use false for Response Decoding];
end
style getDecodingSettings Logic fill:#f9f,stroke:#333,stroke-width:2px
```
This diagram illustrates how an analytics record is processed. The key change is in the "Get Decoding Settings" step, which now correctly combines pump and global settings to decide whether the `decodeBase64Data` step should be executed. The refactoring also clarifies the data trimming, filtering, and field removal steps in the pipeline.