@@ -105,86 +105,89 @@ impl Metrics {
105
105
if let PromValue :: Gauge ( val) = sample. value {
106
106
prom_dress. parseable_events_ingested += val;
107
107
}
108
- } else if & sample. metric == "parseable_events_ingested_size" {
108
+ }
109
+ if & sample. metric == "parseable_events_ingested_size" {
109
110
if let PromValue :: Gauge ( val) = sample. value {
110
111
prom_dress. parseable_events_ingested_size += val;
111
112
}
112
- } else if & sample. metric == "parseable_lifetime_events_ingested" {
113
+ }
114
+ if & sample. metric == "parseable_lifetime_events_ingested" {
113
115
if let PromValue :: Gauge ( val) = sample. value {
114
116
prom_dress. parseable_lifetime_events_ingested += val;
115
117
}
116
- } else if & sample. metric == "parseable_lifetime_events_ingested_size" {
118
+ }
119
+ if & sample. metric == "parseable_lifetime_events_ingested_size" {
117
120
if let PromValue :: Gauge ( val) = sample. value {
118
121
prom_dress. parseable_lifetime_events_ingested_size += val;
119
122
}
120
- } else if & sample. metric == "parseable_deleted_events_ingested" {
123
+ }
124
+ if & sample. metric == "parseable_deleted_events_ingested" {
121
125
if let PromValue :: Gauge ( val) = sample. value {
122
126
prom_dress. parseable_deleted_events_ingested += val;
123
127
}
124
- } else if & sample. metric == "parseable_deleted_events_ingested_size" {
128
+ }
129
+ if & sample. metric == "parseable_deleted_events_ingested_size" {
125
130
if let PromValue :: Gauge ( val) = sample. value {
126
131
prom_dress. parseable_deleted_events_ingested_size += val;
127
132
}
128
- } else if sample. metric == "parseable_staging_files" {
133
+ }
134
+ if sample. metric == "parseable_staging_files" {
129
135
if let PromValue :: Gauge ( val) = sample. value {
130
136
prom_dress. parseable_staging_files += val;
131
137
}
132
- } else if sample. metric == "process_resident_memory_bytes" {
138
+ }
139
+ if sample. metric == "process_resident_memory_bytes" {
133
140
if let PromValue :: Gauge ( val) = sample. value {
134
141
prom_dress. process_resident_memory_bytes += val;
135
142
}
136
- } else if sample. metric == "parseable_storage_size" {
137
- if sample. labels . get ( "type" ) . expect ( "type is present" ) == "data" {
138
- if let PromValue :: Gauge ( val) = sample. value {
139
- prom_dress. parseable_storage_size . data += val;
140
- }
141
- } else if sample. labels . get ( "type" ) . expect ( "type is present" ) == "staging" {
142
- if let PromValue :: Gauge ( val) = sample. value {
143
- prom_dress. parseable_storage_size . staging += val;
144
- }
143
+ }
144
+ if sample. metric == "parseable_storage_size"
145
+ && sample. labels . get ( "type" ) . expect ( "type is present" ) == "data"
146
+ {
147
+ if let PromValue :: Gauge ( val) = sample. value {
148
+ prom_dress. parseable_storage_size . data += val;
149
+ }
150
+ }
151
+ if sample. metric == "parseable_storage_size"
152
+ && sample. labels . get ( "type" ) . expect ( "type is present" ) == "staging"
153
+ {
154
+ if let PromValue :: Gauge ( val) = sample. value {
155
+ prom_dress. parseable_storage_size . staging += val;
145
156
}
146
- } else if sample. metric == "parseable_lifetime_events_storage_size" {
147
- if sample. labels . get ( "type" ) . expect ( "type is present" ) == "data" {
148
- if let PromValue :: Gauge ( val) = sample. value {
149
- prom_dress. parseable_lifetime_storage_size . data += val;
150
- }
157
+ }
158
+
159
+ if sample. metric == "parseable_lifetime_events_storage_size"
160
+ && sample. labels . get ( "type" ) . expect ( "type is present" ) == "data"
161
+ {
162
+ if let PromValue :: Gauge ( val) = sample. value {
163
+ prom_dress. parseable_lifetime_storage_size . data += val;
151
164
}
152
- } else if sample. metric == "parseable_deleted_events_storage_size"
165
+ }
166
+ if sample. metric == "parseable_deleted_events_storage_size"
153
167
&& sample. labels . get ( "type" ) . expect ( "type is present" ) == "data"
154
168
{
155
169
if let PromValue :: Gauge ( val) = sample. value {
156
170
prom_dress. parseable_deleted_storage_size . data += val;
157
171
}
158
172
}
159
173
}
160
- let about_api_json = Self :: from_about_api_response ( ingestor_metadata. clone ( ) )
174
+ let ( commit_id , staging , cache ) = Self :: from_about_api_response ( ingestor_metadata. clone ( ) )
161
175
. await
162
176
. map_err ( |err| {
163
177
log:: error!( "Fatal: failed to get ingestor info: {:?}" , err) ;
164
178
PostError :: Invalid ( err. into ( ) )
165
179
} ) ?;
166
- let commit_id = about_api_json
167
- . get ( "commit" )
168
- . and_then ( |x| x. as_str ( ) )
169
- . unwrap_or_default ( ) ;
170
- let staging = about_api_json
171
- . get ( "staging" )
172
- . and_then ( |x| x. as_str ( ) )
173
- . unwrap_or_default ( ) ;
174
- let cache = about_api_json
175
- . get ( "cache" )
176
- . and_then ( |x| x. as_str ( ) )
177
- . unwrap_or_default ( ) ;
178
- prom_dress. commit = commit_id. to_string ( ) ;
179
- prom_dress. staging = staging. to_string ( ) ;
180
- prom_dress. cache = cache. to_string ( ) ;
180
+
181
+ prom_dress. commit = commit_id;
182
+ prom_dress. staging = staging;
183
+ prom_dress. cache = cache;
181
184
182
185
Ok ( prom_dress)
183
186
}
184
187
185
188
pub async fn from_about_api_response (
186
189
ingestor_metadata : IngestorMetadata ,
187
- ) -> Result < serde_json :: Value , PostError > {
190
+ ) -> Result < ( String , String , String ) , PostError > {
188
191
let uri = Url :: parse ( & format ! (
189
192
"{}{}/about" ,
190
193
& ingestor_metadata. domain_name,
@@ -203,7 +206,23 @@ impl Metrics {
203
206
let about_api_json = res. text ( ) . await . map_err ( PostError :: NetworkError ) ?;
204
207
let about_api_json: serde_json:: Value =
205
208
serde_json:: from_str ( & about_api_json) . map_err ( PostError :: SerdeError ) ?;
206
- Ok ( about_api_json)
209
+ let commit_id = about_api_json
210
+ . get ( "commit" )
211
+ . and_then ( |x| x. as_str ( ) )
212
+ . unwrap_or_default ( ) ;
213
+ let staging = about_api_json
214
+ . get ( "staging" )
215
+ . and_then ( |x| x. as_str ( ) )
216
+ . unwrap_or_default ( ) ;
217
+ let cache = about_api_json
218
+ . get ( "cache" )
219
+ . and_then ( |x| x. as_str ( ) )
220
+ . unwrap_or_default ( ) ;
221
+ Ok ( (
222
+ commit_id. to_string ( ) ,
223
+ staging. to_string ( ) ,
224
+ cache. to_string ( ) ,
225
+ ) )
207
226
} else {
208
227
log:: warn!(
209
228
"Failed to fetch about API response from ingestor: {}\n " ,
0 commit comments