in ecs_logging/_structlog.py [0:0]
def format_to_ecs(self, event_dict: Dict[str, Any]) -> Dict[str, Any]:
if "@timestamp" not in event_dict:
event_dict["@timestamp"] = (
datetime.datetime.fromtimestamp(
time.time(), tz=datetime.timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
+ "Z"
)
if "exception" in event_dict:
stack_trace = event_dict.pop("exception")
if "error" in event_dict:
event_dict["error"]["stack_trace"] = stack_trace
else:
event_dict["error"] = {"stack_trace": stack_trace}
event_dict.setdefault("ecs.version", ECS_VERSION)
return event_dict