Skip to content

converting 'severity' field to an integer results in loss of granularity #22

@gorkem2020

Description

@gorkem2020

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions