Commit 2d9f55bc authored by Christophe Lallement's avatar Christophe Lallement
Browse files

adding log for partition service

parent 5dd899d0
Pipeline #44776 passed with stage
in 26 seconds
import logging
from typing import Optional
from azure.keyvault.secrets import SecretClient
from osdu_az import conf
from osdu_az.identity.az_identity import AzureIdentity
_LOGGER = logging.getLogger(__name__)
class PartitionInfo():
def __init__(self, partition_properties: dict = None):
self._partition_properties = partition_properties
......@@ -23,7 +27,10 @@ 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:
import logging
from os import environ
from osdu_az.opendes.fake_partition_client import FakePartitionClient
......@@ -5,6 +6,8 @@ from osdu_az.opendes.partition_client import PartitionClient
from osdu_az.partition.partition_info import PartitionInfo
from osdu_az.partition.partitions_cache import PartitionsCache
_LOGGER = logging.getLogger(__name__)
COSMOS_ENDPOINT = 'cosmos-endpoint'
COSMOS_CONNECTION = 'cosmos-connection'
......@@ -30,6 +33,7 @@ class PartitionService:
if not partition_info:
partition_info = await PartitionService._partition_client().get_partition(data_partition_id)
if partition_info:'PartitionService fetching partition info for "{data_partition_id}"')
PartitionsCache.set(data_partition_id, partition_info)
return 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