Skip to content

Commit

Permalink
counter dict
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed May 14, 2021
1 parent 4289eef commit 4e8c737
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions fence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,14 @@ def app_config(

_setup_arborist_client(app)
_setup_audit_service_client(app)
_setup_prometheus(app)
_setup_data_endpoint_and_boto(app)
_load_keys(app, root_dir)
_set_authlib_cfgs(app)

app.prometheus_counters = {}
# TODO: if prometheus is disabled in config, do not setup
_setup_prometheus(app)

app.storage_manager = StorageManager(config["STORAGE_CREDENTIALS"], logger=logger)

app.debug = config["DEBUG"]
Expand Down Expand Up @@ -436,7 +439,7 @@ def _setup_prometheus(app):
)

# set up counters
app.pre_signed_url_req = Counter(
app.prometheus_counters["pre_signed_url_req"] = Counter(
"pre_signed_url_req",
"tracking presigned url requests",
["guid", "requested_protocol"],
Expand Down
4 changes: 3 additions & 1 deletion fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def get_signed_url_for_file(action, file_id, file_name=None):
)

# increment counter for gen3-metrics
flask.current_app.pre_signed_url_req.labels(file_id, requested_protocol).inc()
counter = flask.current_app.prometheus_counters.get("pre_signed_url_req")
if counter:
counter.labels(file_id, requested_protocol).inc()

if action == "download": # for now only record download requests
create_presigned_url_audit_log(
Expand Down

0 comments on commit 4e8c737

Please sign in to comment.