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

logging - data ingress v1 #109

Open
1 task
mikeAdamss opened this issue Apr 17, 2024 · 0 comments
Open
1 task

logging - data ingress v1 #109

mikeAdamss opened this issue Apr 17, 2024 · 0 comments

Comments

@mikeAdamss
Copy link
Contributor

mikeAdamss commented Apr 17, 2024

What is this

Add logging statments to data_ingress_v1.

What to do

These are the docs for the logger:
https://github.com/ONSdigital/dp-python-tools/tree/develop/dpytools/logging

And I've added some quick examples of using it here:
https://github.com/ONSdigital/dp-data-pipelines/blob/logging-trial/dpypelines/s3_tar_received.py

There's no "bad" place to add logs but its hekpful to have a consistent pattern, so for this task you're looking to log out:

  • when we've successfully done a thing (with appropriate variables)
  • when we've tried to do a thing and got an error (with appropriate variables)

This does change the approach in the try catches, so this:

try:
    decompress_s3_tar(s3_object_name, "input")
    except Exception as err:
        de_notifier.failure()
        raise Exception(
            message.unexpected_error(
                f"Failed to decompress tar file {s3_object_name}", err
            )
        ) from err

becaomes something like this

try:
    decompress_s3_tar(s3_object_name, "input")
    logger.info("S3 tar recieved successfully decompressed to ./input", data={"s3_object_name": s3_object_name})
except Exception as err:
    logger.error("Failed to decompress tar file", err, data={"s3_object_name": s3_object_name})
    de_notifier.failure()
    raise err

the overarching point being we dont need the verbose expression of what went wrong as the logger will capture
and format that information for us.

note: no tests needed for this, the logger has tests already.

Acceptance criteria

  • s3 tar recieved has logging
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

No branches or pull requests

1 participant