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

40 add logging aggregation, LOGLEVEL env var, other logging tweaks #45

Merged
merged 7 commits into from
Jul 26, 2023

Conversation

alexdunnjpl
Copy link
Contributor

🗒️ Summary

Tweaks logging in a handful of ways (see commit messages)

Biggest one is that product-level errors/warns are now aggregated, while maintaining explanatory details for troubleshooting.

Log level can now be set in dockerized processes via the LOGLEVEL environment variable

⚙️ Test Data and/or Report

Unit tests pass

♻️ Related Issues

fixes #40

@sonatype-lift
Copy link

sonatype-lift bot commented Jul 26, 2023

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

@@ -92,6 +92,7 @@
logging.error(err)
raise ValueError(f'Failed to parse username/password from PROV_CREDENTIALS value "{provCredentialsStr}": {err}')

log_level = parse_log_level(os.environ.get('LOGLEVEL', 'INFO'))

def run_factory(sweeper_f: Callable) -> Callable:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7% of developers fix this issue

E302: expected 2 blank lines, found 1


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@@ -62,7 +62,7 @@
from typing import Callable, Iterable

from pds.registrysweepers import provenance, ancestry
from pds.registrysweepers.utils import configure_logging, get_human_readable_elapsed_since
from pds.registrysweepers.utils import configure_logging, get_human_readable_elapsed_since, parse_log_level
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9% of developers fix this issue

reportMissingImports: Import "pds.registrysweepers.utils" could not be resolved


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

Copy link
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Thanks @alexdunnjpl

@@ -143,14 +146,11 @@ def query_registry_db(
total_hits = data["hits"]["total"]["value"]
log.debug(f" paging query ({served_hits} to {min(served_hits + page_size, total_hits)} of {total_hits})")

last_info_log_at_percentage = 0
log.info("Query progress: 0%")

for hit in data["hits"]["hits"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a tqdm package which can help to track progress in a loop. I would prefer to use that rather than adding specific indicators which can make the code less readable regarding its primary focus.

@@ -92,6 +92,7 @@
logging.error(err)
raise ValueError(f'Failed to parse username/password from PROV_CREDENTIALS value "{provCredentialsStr}": {err}')

log_level = parse_log_level(os.environ.get('LOGLEVEL', 'INFO'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that Sean recommended to use a log configuration file to configure the python logs, I don't know how that would integrate in a AWS deployment. We would need to mount the log configuration file in the docker image from a configuration store (I don't know what that is in AWS?). Then we would have the log level in this file.

I don't wnat to overcomplicate the changes right now, so let say it is for comment/discussion, not for change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you serve config files or complex objects from the Parameter Store? Preferably whatever mechanism we use should be trivially-adjustable in AWS (as environment variables are) to allow us to switch into debug logging easily if an issue is found.

@alexdunnjpl
Copy link
Contributor Author

alexdunnjpl commented Jul 26, 2023

@tloubrieu-jpl could I trouble you to open tickets for your two comments? The issues raised relate to longstanding existing code and are out-of-scope for this PR (i.e. I've left it better than I found it and y'all need these fixes yesterday).

Happy to pick up these improvements once we're out of the woods on the immediate ops issues.

EDIT

I don't wnat to overcomplicate the changes right now, so let say it is for comment/discussion, not for change.

Helps if I read the whole thing before firing off a response 😅

Copy link
Member

@tloubrieu-jpl tloubrieu-jpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a ticket for my comments (#47) to be implemented when not in a hurry.

@alexdunnjpl alexdunnjpl changed the title 40 logging improvements 40 add logging aggregation, LOGLEVEL env var, other logging tweaks Jul 26, 2023
@alexdunnjpl alexdunnjpl merged commit 52c1529 into main Jul 26, 2023
1 check passed
@alexdunnjpl alexdunnjpl deleted the 40-logging-improvements branch July 26, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider suppress-data-warnings option
2 participants