Commit 25983cd
committed
out_stackdriver: fix metric accounting for dropped records and decouple logic
This patch refactors the response handling in the stackdriver output plugin to resolve incorrect metric accounting and inconsistent behavior between builds with and without Prometheus metrics enabled.
1. Defer Metric Accounting to Core Engine: Removed manual increment of cmt_dropped_records on standard 4xx errors. The core engine automatically increments drop counters when the plugin returns FLB_ERROR. Manual increments caused double counting. This aligns with how other plugins (like out_cloudwatch_logs) defer core accounting to the engine.
2. Enable Partial Success Handling for All Builds: Moved parse_partial_success_response outside of #ifdef FLB_HAVE_METRICS. Previously, partial success was only checked if metrics were enabled. Now, all builds will correctly identify partial successes and return FLB_OK to clear the chunk, preventing unnecessary retries and ensuring consistent behavior across different build configurations.
3. Added Visibility Logging: Added a warning log for partial successes that reports the exact number of failed records, providing operator visibility into silent drops.
4. Style Guide Compliance: Ensured all variables are declared at the beginning of the function scope as required by Fluent Bit style guidelines. Moved ts outside of ifdef to support its use on all builds.
5. Fixed Double Counting on Partial Success: Guarded the batch success metrics update in if (ret_code == FLB_OK) to ensure we don't double count successful records that were already accounted for in the partial success block.
Signed-off-by: pdewilde <pdewilde@google.com>1 parent 6adf68b commit 25983cd
1 file changed
+42
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2937 | 2937 | | |
2938 | 2938 | | |
2939 | 2939 | | |
2940 | | - | |
| 2940 | + | |
| 2941 | + | |
2941 | 2942 | | |
2942 | 2943 | | |
2943 | 2944 | | |
| |||
2953 | 2954 | | |
2954 | 2955 | | |
2955 | 2956 | | |
| 2957 | + | |
2956 | 2958 | | |
2957 | 2959 | | |
2958 | | - | |
2959 | 2960 | | |
2960 | 2961 | | |
2961 | 2962 | | |
| |||
3069 | 3070 | | |
3070 | 3071 | | |
3071 | 3072 | | |
3072 | | - | |
3073 | 3073 | | |
3074 | 3074 | | |
3075 | 3075 | | |
3076 | 3076 | | |
3077 | 3077 | | |
3078 | 3078 | | |
3079 | 3079 | | |
3080 | | - | |
3081 | | - | |
3082 | | - | |
3083 | | - | |
3084 | | - | |
3085 | | - | |
3086 | | - | |
3087 | | - | |
3088 | | - | |
3089 | | - | |
3090 | | - | |
3091 | | - | |
3092 | | - | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
3093 | 3086 | | |
3094 | 3087 | | |
3095 | | - | |
3096 | | - | |
3097 | | - | |
3098 | | - | |
3099 | | - | |
3100 | | - | |
3101 | | - | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
3102 | 3092 | | |
3103 | 3093 | | |
3104 | | - | |
3105 | | - | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
3106 | 3100 | | |
3107 | | - | |
3108 | | - | |
3109 | 3101 | | |
| 3102 | + | |
3110 | 3103 | | |
3111 | | - | |
3112 | | - | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
3113 | 3112 | | |
3114 | 3113 | | |
3115 | 3114 | | |
3116 | 3115 | | |
3117 | | - | |
3118 | | - | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
3119 | 3126 | | |
3120 | | - | |
3121 | 3127 | | |
3122 | 3128 | | |
3123 | 3129 | | |
| |||
3129 | 3135 | | |
3130 | 3136 | | |
3131 | 3137 | | |
3132 | | - | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
3133 | 3142 | | |
3134 | 3143 | | |
3135 | 3144 | | |
| |||
0 commit comments