Commit aea5907c authored by Christophe Lallement's avatar Christophe Lallement
Browse files

Merge branch 'add_logger' of...

Merge branch 'add_logger' of community.opengroup.org:osdu/platform/domain-data-mgmt-services/wellbore/lib/wellbore-cloud/wellbore-azure-lib into add_logger
parents 706d6f53 26ff18f2
Pipeline #44507 passed with stage
in 53 seconds
...@@ -4,6 +4,10 @@ from azure.keyvault.secrets import SecretClient ...@@ -4,6 +4,10 @@ from azure.keyvault.secrets import SecretClient
from osdu_az import conf from osdu_az import conf
from osdu_az.identity.az_identity import AzureIdentity from osdu_az.identity.az_identity import AzureIdentity
import logging
from datetime import datetime
_LOGGER = logging.getLogger('osdu_az.storage.blob_storage_az')
class PartitionInfo(): class PartitionInfo():
...@@ -23,10 +27,14 @@ class PartitionInfo(): ...@@ -23,10 +27,14 @@ class PartitionInfo():
return secret.value return secret.value
def _get_secret(self, key: str): 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)
_LOGGER.info(f'PartitionInfo get secret took {(datetime.utcnow() - ts).total_seconds()} ms')
return secret
def _get_secret_client(self): def _get_secret_client(self):
if not self._secret_client: if not self._secret_client:
self._secret_client = SecretClient(conf.keyvault_url, AzureIdentity.get_default_credential()) self._secret_client = SecretClient(conf.keyvault_url, AzureIdentity.get_default_credential())
return self._secret_client return self._secret_client
...@@ -4,6 +4,9 @@ from osdu_az.opendes.fake_partition_client import FakePartitionClient ...@@ -4,6 +4,9 @@ from osdu_az.opendes.fake_partition_client import FakePartitionClient
from osdu_az.opendes.partition_client import PartitionClient from osdu_az.opendes.partition_client import PartitionClient
from osdu_az.partition.partition_info import PartitionInfo from osdu_az.partition.partition_info import PartitionInfo
from osdu_az.partition.partitions_cache import PartitionsCache from osdu_az.partition.partitions_cache import PartitionsCache
import logging
_LOGGER = logging.getLogger('osdu_az.storage.blob_storage_az')
# KNOWN CORE PARTITION PROPERTIES # KNOWN CORE PARTITION PROPERTIES
COSMOS_ENDPOINT = 'cosmos-endpoint' COSMOS_ENDPOINT = 'cosmos-endpoint'
...@@ -28,6 +31,7 @@ class PartitionService: ...@@ -28,6 +31,7 @@ class PartitionService:
async def get_partition(data_partition_id: str) -> PartitionInfo: async def get_partition(data_partition_id: str) -> PartitionInfo:
partition_info = PartitionsCache.get(data_partition_id) partition_info = PartitionsCache.get(data_partition_id)
if not partition_info: if not partition_info:
_LOGGER.info(f'PartitionService fetching partition info for "{data_partition_id}"')
partition_info = await PartitionService._partition_client().get_partition(data_partition_id) partition_info = await PartitionService._partition_client().get_partition(data_partition_id)
if partition_info: if partition_info:
PartitionsCache.set(data_partition_id, 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