Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
35b50d2
adds subquery logging call to subquery
SpicyGarlicAlbacoreRoll Oct 21, 2023
4275633
removes Unit: Seconds from subquery log
SpicyGarlicAlbacoreRoll Oct 21, 2023
e7f4293
adds missing 'self' keyword param to subquery class log method
SpicyGarlicAlbacoreRoll Oct 21, 2023
373eff5
begins moving out subquery logging out from Subquery and into searchQ…
SpicyGarlicAlbacoreRoll Oct 21, 2023
f9b6e73
testing subquery logging
SpicyGarlicAlbacoreRoll Oct 23, 2023
c9dfc11
removes unit type from subquery logging
SpicyGarlicAlbacoreRoll Oct 23, 2023
f4399a5
moves aws subquery metric logging to subquery level, adds status code…
SpicyGarlicAlbacoreRoll Oct 27, 2023
c6caa27
Merge branch 'test' into devel
SpicyGarlicAlbacoreRoll Oct 27, 2023
9a4e431
Merge pull request #727 from asfadmin/devel
SpicyGarlicAlbacoreRoll Oct 27, 2023
e39bda5
adds dataset constants and 'datasets' searchable parameter, for use b…
SpicyGarlicAlbacoreRoll Nov 2, 2023
0844685
removes burst map products from S1 dataset entry
SpicyGarlicAlbacoreRoll Nov 2, 2023
732048b
adds RTC/CSLC-STATIC concept ids to opera dataset collections
SpicyGarlicAlbacoreRoll Nov 3, 2023
d00fb34
adds error handling when provided invalid dataset
SpicyGarlicAlbacoreRoll Nov 6, 2023
fde4e6a
comments out log_subquery_time for now, adds opera calval concept-ids…
SpicyGarlicAlbacoreRoll Nov 8, 2023
a63164b
adds missing dataset collections check for should_use_asf_frame() method
SpicyGarlicAlbacoreRoll Nov 8, 2023
e1ec96b
changes 'datasets' keyword to 'dataset'
SpicyGarlicAlbacoreRoll Nov 8, 2023
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
2 changes: 1 addition & 1 deletion SearchAPI/CMR/Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, req_fields, params=None, max_results=None):
)
for query in subquery_list_from(self.params)
]


logging.debug('New CMRQuery object ready to go')

Expand Down Expand Up @@ -95,7 +96,6 @@ def max_results_reached(self):
self.result_counter >= self.max_results
)


def subquery_list_from(params):
"""
Use the cartesian product of all the list parameters to
Expand Down
44 changes: 40 additions & 4 deletions SearchAPI/CMR/SubQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from flask import request

from SearchAPI.asf_env import get_config
from SearchAPI.CMR.Translate import parse_cmr_response
from SearchAPI.CMR.Translate import parse_cmr_response, platform_datasets
from SearchAPI.CMR.Exceptions import CMRError

import boto3

class CMRSubQuery:
def __init__(self, req_fields, params, extra_params):
Expand Down Expand Up @@ -57,9 +58,15 @@ def combine_params(self, params, extra_params):

def should_use_asf_frame(self):
asf_frame_platforms = ['SENTINEL-1A', 'SENTINEL-1B', 'ALOS']

asf_frame_datasets = ['SENTINEL-1', 'OPERA-S1', 'SLC-BURST', 'ALOS PALSAR', 'ALOS AVNIR-2']

asf_frame_collections = []
for dataset in asf_frame_datasets:
asf_frame_collections.extend(platform_datasets.get(dataset))

return any([
p[0] == 'platform[]' and p[1] in asf_frame_platforms
p[0] == 'platform[]' and p[1] in asf_frame_platforms
or p[0] == 'echo_collection_id[]' and p[1] in asf_frame_collections
for p in self.params
])

Expand Down Expand Up @@ -166,9 +173,10 @@ def get_page(self, session):
query_duration = perf_counter() - q_start
logging.debug(f'CMR query time: {query_duration}')

# self.log_subquery_time({'time': query_duration, 'status': response.status_code})

if query_duration > 10:
self.log_slow_cmr_response(session, response, query_duration)

if response.status_code != 200:
self.log_bad_cmr_response(
attempt, max_retry, response, session
Expand Down Expand Up @@ -222,3 +230,31 @@ def log_bad_cmr_response(self, attempt, max_retry, response, session):
logging.error('Headers sent to CMR:')
logging.error(session.headers)
logging.error(f'Error body: {response.text}')


def log_subquery_time(self, query_metric):
try:
if request.asf_config['cloudwatch_metrics']:
logging.debug('Logging subquery run time to cloudwatch metrics')
cloudwatch = boto3.client('cloudwatch')
cloudwatch.put_metric_data(
MetricData = [
{
'MetricName': 'SubqueryRuntime',
'Dimensions': [
{
'Name': 'maturity',
'Value': request.asf_base_maturity
}, {
'Name': 'status',
'Value': query_metric['status']
}
],
'Unit': 'None',
'Value': query_metric['time']
}
],
Namespace = 'SearchAPI'
)
except Exception as e:
logging.exception(f'Failure during subquery run time logging: {e}')
1 change: 1 addition & 0 deletions SearchAPI/CMR/Translate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from .translate_params import translate_params
from .input_fixer import input_fixer
from .fields import get_field_paths
from .datasets import platform_datasets
Loading