-
-
Notifications
You must be signed in to change notification settings - Fork 8
add sentry function #9
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
b56ac14
ebda748
e305b5b
0b26b0c
eb66781
ae745da
da46832
580142b
547b262
8b308fd
b7cce69
ba26410
6588b4f
7171873
fd8b9fe
99b9f64
abed0ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,11 @@ | |
""" | ||
|
||
import datetime as dt | ||
import os | ||
from importlib.metadata import PackageNotFoundError, version | ||
|
||
from dotenv import load_dotenv | ||
import sentry_sdk | ||
import eumdac.product | ||
from joblib import Parallel, delayed | ||
from loguru import logger as log | ||
|
@@ -23,11 +26,29 @@ | |
from satellite_consumer.storage import create_empty_zarr, create_latest_zip, get_fs, write_to_zarr | ||
from satellite_consumer.validate import validate | ||
|
||
# Load environment variables from .env file | ||
load_dotenv() | ||
|
||
# Get Sentry DSN from environment variables | ||
SENTRY_DSN = os.getenv("SENTRY_DSN") | ||
|
||
# Initialize Sentry if DSN is available | ||
if SENTRY_DSN: | ||
sentry_sdk.init( | ||
dsn=SENTRY_DSN, # Using .env variable | ||
traces_sample_rate=1.0, | ||
environment=os.getenv("ENVIRONMENT", "production") # Get from ENVIRONMENT variable | ||
lambaaryan011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) | ||
log.info("✅ Sentry initialized successfully!") | ||
else: | ||
log.warning("⚠️ SENTRY_DSN is not set. Sentry will not be initialized.") | ||
lambaaryan011 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
try: | ||
__version__ = version("satellite-consumer") | ||
except PackageNotFoundError: | ||
__version__ = "v?" | ||
|
||
|
||
def _consume_command(command_opts: ArchiveCommandOptions | ConsumeCommandOptions) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you reset all changes below this, if you want to do this, please put in a different PR and explain what they are for and why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is green lines below here, then it means new lines have been added |
||
"""Run the download and processing pipeline.""" | ||
fs = get_fs(path=command_opts.zarr_path) | ||
|
@@ -79,7 +100,8 @@ def _etl(product: eumdac.product.Product) -> str: | |
f"Deleting {len(nat_filepaths)} raw files in {command_opts.raw_folder}", | ||
num_files=len(nat_filepaths), dst=command_opts.raw_folder, | ||
) | ||
_ = [f.unlink() for f in nat_filepaths] # type:ignore | ||
for f in nat_filepaths: | ||
f.unlink() # type: ignore # Removed unnecessary list comprehension | ||
|
||
|
||
def run(config: SatelliteConsumerConfig) -> None: | ||
|
Uh oh!
There was an error while loading. Please reload this page.