Skip to content

Commit

Permalink
Revert "use a label to track the indexed file resource path instead o…
Browse files Browse the repository at this point in the history
…f the file id (guid) to avoid overloading prometheus"

This reverts commit db9af96.
  • Loading branch information
themarcelor committed May 17, 2021
1 parent 805d660 commit ad27a97
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion fence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def _setup_prometheus(app):
app.prometheus_counters["pre_signed_url_req"] = Counter(
"pre_signed_url_req",
"tracking presigned url requests",
["resource_path", "requested_protocol"],
["guid", "requested_protocol"],
)


Expand Down
10 changes: 5 additions & 5 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
give_service_account_billing_access_if_necessary,
)
from fence.utils import get_valid_expiration_from_request
from fence.utils import get_resource_paths
from . import multipart_upload


Expand Down Expand Up @@ -83,9 +82,7 @@ def get_signed_url_for_file(action, file_id, file_name=None):
# increment counter for gen3-metrics
counter = flask.current_app.prometheus_counters.get("pre_signed_url_req")
if counter:
# identify project associated with indexd record based on its authz/acl
resource_path = get_resource_paths(indexed_file)[0]
counter.labels(resource_path, requested_protocol).inc()
counter.labels(file_id, requested_protocol).inc()

if action == "download": # for now only record download requests
create_presigned_url_audit_log(
Expand All @@ -97,7 +94,10 @@ def get_signed_url_for_file(action, file_id, file_name=None):

def create_presigned_url_audit_log(indexed_file, action, protocol):
user_info = _get_user_info(sub_to_string=False)
resource_paths = get_resource_paths(indexed_file)
resource_paths = indexed_file.index_document.get("authz", [])
if not resource_paths:
# fall back on ACL
resource_paths = indexed_file.index_document.get("acl", [])
if not protocol and indexed_file.indexed_file_locations:
protocol = indexed_file.indexed_file_locations[0].protocol
flask.current_app.audit_service_client.create_presigned_url_log(
Expand Down
8 changes: 0 additions & 8 deletions fence/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,6 @@ def _is_status(code):
return False


def get_resource_paths(indexed_file):
resource_paths = indexed_file.index_document.get("authz", [])
if not resource_paths:
# fall back on ACL
resource_paths = indexed_file.index_document.get("acl", [])
return resource_paths


# Default settings to control usage of backoff library.
DEFAULT_BACKOFF_SETTINGS = {
"on_backoff": log_backoff_retry,
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_indexd_prometheus_presigned_url_counter(
app.prometheus_registry.get_sample_value(
"pre_signed_url_req_total",
{
"resource_path": indexd_client["resource_paths"][0],
"guid": "1",
"requested_protocol": indexd_client["indexed_file_location"],
},
)
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_indexd_prometheus_presigned_url_counter(
after = app.prometheus_registry.get_sample_value(
"pre_signed_url_req_total",
{
"resource_path": indexd_client["resource_paths"][0],
"guid": "1",
"requested_protocol": indexd_client["indexed_file_location"],
},
)
Expand Down

0 comments on commit ad27a97

Please sign in to comment.