Commit 26ff18f2 authored by Yannick's avatar Yannick
Browse files

adding log for partition service

parent e208d1d4
Pipeline #44486 failed with stage
in 1 minute and 49 seconds
......@@ -4,6 +4,10 @@ from azure.keyvault.secrets import SecretClient
from osdu_az import conf
from osdu_az.identity.az_identity import AzureIdentity
import logging
from datetime import datetime
_LOGGER = logging.getLogger('')
class PartitionInfo():
......@@ -23,10 +27,14 @@ class PartitionInfo():
return secret.value
def _get_secret(self, key: str):
return self._get_secret_client().get_secret(key)
ts = datetime.utcnow()
secret = self._get_secret_client().get_secret(key)'PartitionInfo get secret took {(datetime.utcnow() - ts).total_seconds()} ms')
return secret
def _get_secret_client(self):
if not self._secret_client:
self._secret_client = SecretClient(conf.keyvault_url, AzureIdentity.get_default_credential())
return self._secret_client
......@@ -4,6 +4,9 @@ from osdu_az.opendes.fake_partition_client import FakePartitionClient
from osdu_az.opendes.partition_client import PartitionClient
from osdu_az.partition.partition_info import PartitionInfo
from osdu_az.partition.partitions_cache import PartitionsCache
import logging
_LOGGER = logging.getLogger('')
COSMOS_ENDPOINT = 'cosmos-endpoint'
......@@ -28,6 +31,7 @@ class PartitionService:
async def get_partition(data_partition_id: str) -> PartitionInfo:
partition_info = PartitionsCache.get(data_partition_id)
if not partition_info:'PartitionService fetching partition info for "{data_partition_id}"')
partition_info = await PartitionService._partition_client().get_partition(data_partition_id)
if partition_info:
PartitionsCache.set(data_partition_id, partition_info)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment