diff --git a/port_ocean/core/handlers/entity_processor/jq_entity_processor.py b/port_ocean/core/handlers/entity_processor/jq_entity_processor.py index b010ba0dfd..12f5a86834 100644 --- a/port_ocean/core/handlers/entity_processor/jq_entity_processor.py +++ b/port_ocean/core/handlers/entity_processor/jq_entity_processor.py @@ -4,6 +4,7 @@ from dataclasses import dataclass, field from functools import lru_cache from typing import Any, Optional +from uuid import uuid4 import pyjq as jq # type: ignore from loguru import logger @@ -47,19 +48,53 @@ def _compile(self, pattern: str) -> Any: return jq.compile(pattern) async def _search(self, data: dict[str, Any], pattern: str) -> Any: + identifier = str(uuid4()) try: loop = asyncio.get_event_loop() + logger.info( + f"__COMPILING__ jq execution with pattern: {pattern}. trace-id: {identifier}" + ) compiled_pattern = self._compile(pattern) first_value_callable = functools.partial(compiled_pattern.first, data) - return await loop.run_in_executor(None, first_value_callable) - except Exception: + logger.info( + f"__STARTING__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier}" + ) + result = await loop.run_in_executor(None, first_value_callable) + logger.info( + f"__FINISHED__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier} \n" + f"Result {result}" + ) + return result + except Exception as e: + logger.error( + f"__FAILED__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier} \n" + f"Error {e}" + ) return None async def _search_as_bool(self, data: dict[str, Any], pattern: str) -> bool: loop = asyncio.get_event_loop() - compiled_pattern = self._compile(pattern) - first_value_callable = functools.partial(compiled_pattern.first, data) - value = await loop.run_in_executor(None, first_value_callable) + identifier = str(uuid4()) + try: + logger.info( + f"__COMPILING_BOOL__ jq execution with pattern: {pattern}. trace-id: {identifier}" + ) + compiled_pattern = self._compile(pattern) + first_value_callable = functools.partial(compiled_pattern.first, data) + logger.info( + f"__STARTING_BOOL__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier}" + ) + value = await loop.run_in_executor(None, first_value_callable) + logger.info( + f"__FINISHED_BOOL__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier} \n" + f"Result {value}" + ) + except Exception as e: + logger.error( + f"__FAILED_BOOL__ jq execution with pattern: {pattern} and data: {data}. trace-id: {identifier} \n" + f"Error {e}" + ) + raise if isinstance(value, bool): return value diff --git a/pyproject.toml b/pyproject.toml index 1b471e6d48..d4f3498c37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "port-ocean" -version = "0.9.1" +version = "0.9.2-dev01" description = "Port Ocean is a CLI tool for managing your Port projects." readme = "README.md" homepage = "https://app.getport.io"