Add new features
This commit is contained in:
parent
2d8e1c1758
commit
2c3f19e67c
1 changed files with 479 additions and 208 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import inspect
|
||||
from typing import Any
|
||||
|
||||
from great_ai.great_ai.context.get_context import get_context
|
||||
|
||||
from ..tracing import TracingContext
|
||||
|
||||
|
||||
def log_metric(argument_name: str, value: Any) -> None:
|
||||
context = TracingContext.get_current_context()
|
||||
tracing_context = TracingContext.get_current_context()
|
||||
caller = inspect.stack()[1].function
|
||||
actual_name = f"metric:{caller}:{argument_name}"
|
||||
if context:
|
||||
context.log_value(name=actual_name, value=value)
|
||||
if tracing_context:
|
||||
tracing_context.log_value(name=actual_name, value=value)
|
||||
|
||||
get_context().logger.info(f"{actual_name}={value}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue