Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update how metrics are collected #17

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def process_import_function(event, context):
key = message.get("file_path")
jurisdiction_id = message.get("jurisdiction_id")
jurisdiction_name = message.get("jurisdiction_name")

# Archiving processed realtime bills defaults to False, except it was
# explicitly set on cli or on task-definitions Repo as <--archive>
# or added on AWS admin console for os-realtime lambda function
Expand Down Expand Up @@ -116,12 +117,14 @@ def process_import_function(event, context):
logger.info(f"importing {jur_id}...")
try:
do_import(jur_id, f"{datadir}{abbreviation}")
stats.send_last_run(
"last_collection_run_time",
{
"jurisdiction": juris["name"],
"scrape_type": "import",
},
stats.write_stats(
[
{
"metric": "objects",
"fields": {"realtime_import": 1},
"tags": {"jurisdiction": juris["name"]},
}
]
)

if file_archiving_enabled:
Expand All @@ -131,7 +134,9 @@ def process_import_function(event, context):
s3_client.delete_object(Bucket=bucket, Key=file_path)
logger.info(f"Deleted file :: {file_path}")
except Exception as e:
logger.error(f"Error importing jurisdiction {jur_id}: {e}") # noqa: E501
logger.error(
f"Error importing jurisdiction {jur_id}: {e}"
) # noqa: E501
continue

logger.info(f"{len(all_files)} files processed")
Expand All @@ -148,7 +153,8 @@ def remove_duplicate_message(items):

# Use another list comprehension to create a list of unique dictionaries
filtered_items = [
dict(i) for i in set(tuple(i.items()) for i in parsed_items) # noqa: E501
dict(i)
for i in set(tuple(i.items()) for i in parsed_items) # noqa: E501
]

return filtered_items
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ black = "^24.4.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[flake8]
max-line-length = 79

[tool.black]
line-length = 79

Loading