Skip to content

Commit

Permalink
fix: add correlation id
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurii Purdenko committed Feb 1, 2024
1 parent 52e5091 commit 0efe36f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bhtom2/bhtom_catalogs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import requests
from django.conf import settings
import json
from django_guid import get_guid

from .forms import CatalogQueryForm
from bhtom_base.bhtom_catalogs.harvester import MissingDataException
Expand Down Expand Up @@ -35,7 +36,10 @@ def form_valid(self, form):
'terms': term,
'harvester': service
}
response = requests.post(settings.HARVESTER_URL + '/findTargetWithHarvester/', data=post_data)
header = {
"Correlation-ID" : get_guid(),
}
response = requests.post(settings.HARVESTER_URL + '/findTargetWithHarvester/', data=post_data, headers=header)

if response.status_code == 200:
# Extract JSON from the response
Expand Down
8 changes: 6 additions & 2 deletions bhtom2/bhtom_targets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from django.conf import settings
import requests
import json
from django_guid import get_guid
from math import radians
from bhtom_base.bhtom_common.hooks import run_hook
from astropy.coordinates import Angle
Expand Down Expand Up @@ -114,9 +115,12 @@ def import_targets(targets):
post_data = {
'terms': gaia_alerts_name,
'harvester': "Gaia Alerts"
}
}
header = {
"Correlation-ID" : get_guid(),
}
try:
response = requests.post(settings.HARVESTER_URL + '/findTargetWithHarvester/', data=post_data)
response = requests.post(settings.HARVESTER_URL + '/findTargetWithHarvester/', data=post_data, headers=header)
if response.status_code == 200:
# Extract JSON from the response
catalog_data = json.loads(response.text)
Expand Down

0 comments on commit 0efe36f

Please sign in to comment.