Skip to content

Commit a678397

Browse files
committed
exclude uids from latency metrics
1 parent a0a400e commit a678397

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

watcher/watcher.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,30 @@ def __call__(self, environ, start_response):
174174
environ['WATCHER.ACTION'] = cadf_action
175175
environ['WATCHER.SERVICE_TYPE'] = self.service_type
176176

177+
# labels applied to all metrics emitted by this middleware
177178
labels = [
178179
"service_name:{0}".format(self.strategy.get_cadf_service_name()),
179180
"service:{0}".format(self.service_type),
180181
"action:{0}".format(cadf_action),
182+
"target_type_uri:{0}".format(target_type_uri),
183+
]
184+
185+
# additional labels not needed in all metrics
186+
detail_labels = [
181187
"initiator_project_id:{0}".format(initiator_project_id),
182188
"initiator_domain_id:{0}".format(initiator_domain_id),
183-
"target_type_uri:{0}".format(target_type_uri),
184189
]
190+
detail_labels = labels + detail_labels
185191

186192
# include the target project id in metric
187193
if self.is_include_target_project_id_in_metric:
188-
labels.append(
194+
detail_labels.append(
189195
"target_project_id:{0}".format(target_project_id)
190196
)
191197

192198
# include initiator user id
193199
if self.is_include_initiator_user_id_in_metric:
194-
labels.append(
200+
detail_labels.append(
195201
"initiator_user_id:{0}".format(initiator_user_id)
196202
)
197203

@@ -230,7 +236,7 @@ def _start_response_wrapper(status, headers, exc_info=None):
230236
labels.append("status:{0}".format(status_code))
231237

232238
self.metric_client.timing('api_requests_duration_seconds', time.time() - start, tags=labels)
233-
self.metric_client.increment('api_requests_total', tags=labels)
239+
self.metric_client.increment('api_requests_total', tags=detail_labels)
234240
except Exception as e:
235241
self.logger.debug("failed to submit metrics for %s: %s" % (str(labels), str(e)))
236242
finally:

0 commit comments

Comments
 (0)