Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(engine): Lower log level and catch http timeout #547

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tracecat/auth/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _set_secrets(self) -> None:
self._context[name][kv.key] = kv.value.get_secret_value()

def _unset_secrets(self) -> None:
logger.info("Cleaning up secrets")
logger.debug("Cleaning up secrets")
for secret in self._secret_objs:
if secret.name in self._context:
del self._context[secret.name]
Expand Down
4 changes: 4 additions & 0 deletions tracecat/registry/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ async def call_action(self, input: RunActionInput) -> Any:
raise RegistryActionError(
f"Unexpected registry error ({e.response.status_code}):\n\n{e}\n\n{detail}"
) from e
except httpx.ReadTimeout as e:
raise RegistryActionError(
f"Timeout calling action {key!r} in registry: {e}"
) from e
except orjson.JSONDecodeError as e:
raise RegistryActionError(
f"Error decoding JSON response for action {key!r}: {e}"
Expand Down
6 changes: 3 additions & 3 deletions tracecat/registry/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ async def _run_action_direct(
raise ValueError("Templates cannot be executed directly")
try:
if action.is_async:
logger.info("Running UDF async")
logger.trace("Running UDF async")
return await action.fn(**args)
logger.info("Running UDF sync")
logger.trace("Running UDF sync")
return await asyncio.to_thread(action.fn, **args)
except Exception as e:
logger.error(
Expand All @@ -78,7 +78,7 @@ async def run_single_action(
action = await service.load_action_impl(action_name=action_name)
validated_args = action.validate_args(**args)

logger.info("Running regular UDF async", action=action_name)
logger.trace("Running regular UDF async", action=action_name)
secret_names = [secret.name for secret in action.secrets or []]
optional_secrets = [
secret.name for secret in action.secrets or [] if secret.optional
Expand Down
4 changes: 2 additions & 2 deletions tracecat/registry/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_bound_action_impl(
if impl.type == "udf":
key = getattr(fn, "__tracecat_udf_key")
kwargs = getattr(fn, "__tracecat_udf_kwargs")
logger.info("Binding UDF", key=key, name=action.name)
logger.trace("Binding UDF", key=key, name=action.name)
# Add validators to the function
validated_kwargs = RegisterKwargs.model_validate(kwargs)
attach_validators(fn, TemplateValidator())
Expand All @@ -62,7 +62,7 @@ def get_bound_action_impl(
origin=action.origin,
)
else:
logger.info("Binding template action", name=action.name)
logger.trace("Binding template action", name=action.name)
defn = impl.template_action.definition
return BoundRegistryAction(
fn=fn,
Expand Down