You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the create_frame function, we are converting 'levelno' field to 'severity' by dividing by 10 and then converting to integer, as in below;
frame['severity'] = int(r['levelno'] / 10)
in doing so we are losing custom log levels created by the user. For example I have additional 2 log levels that have levelno of 25 and 35. These are converted to 2 and 3 respectively. This makes it impossible to query using something like severity>25 when I want to get the events that have levelno greater than 25.
I guess we cannot do something like below, which will break compatibailty who are using severity as is
frame['severity'] = r['levelno']
so maybe we can add a field?
frame['level_no'] = r['levelno']
this will enable to query with finer granularity.
I did not want to create a PR because I thought there must be a reason why this has not been already added.
Or even better idea; why not pass a dict which has the python-to-logtail mappings to the handler and frame can be created using this mapping? something like below;
# frame.py
def create_frame(record, message, context, include_extra_attributes=False, mapping: dict = None):
... # omitted code
if mapping:
for k, v in mapping.items():
frame[v] = getattr(record, k)
... # omitted code
return frame
The text was updated successfully, but these errors were encountered:
Thank you for reaching out! I appreciate your patience here.
The severity is divided by 10 for historical reasons. We don't want to break backward compatibility by changing the meaning of severity.
Allowing customizing how the frame is created is a good idea.
I wouldn't go as far as passing entirely new mapping for all fields.
I would instead solve the issue with levels and severity specifically.
What do you think about allowing to pass a dict that maps "levelno" to "levels"?
This way, the "severity" field would stay unchanged, but you could map 25 and 35 to any level you want.
Would that work for you? 🙏
Passing a mapping dict to customize fields was meant to be seperate idea not related to severity. In general, it would be very useful to control precisely what is being sent and how it is constructed.
Under the create_frame function, we are converting 'levelno' field to 'severity' by dividing by 10 and then converting to integer, as in below;
frame['severity'] = int(r['levelno'] / 10)
in doing so we are losing custom log levels created by the user. For example I have additional 2 log levels that have levelno of 25 and 35. These are converted to 2 and 3 respectively. This makes it impossible to query using something like severity>25 when I want to get the events that have levelno greater than 25.
I guess we cannot do something like below, which will break compatibailty who are using severity as is
frame['severity'] = r['levelno']
so maybe we can add a field?
frame['level_no'] = r['levelno']
this will enable to query with finer granularity.
I did not want to create a PR because I thought there must be a reason why this has not been already added.
Or even better idea; why not pass a dict which has the python-to-logtail mappings to the handler and frame can be created using this mapping? something like below;
The text was updated successfully, but these errors were encountered: