Feature Request: Allow relativeCreated to be formatted as seconds instead of milliseconds

Open
#195 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by reading FluentRecordFormatter and Python's LogRecord relativeCreated attribute to understand how formatter fields are resolved. The feature is complete when a relativeCreatedInSeconds field can be used in the shown configuration and produces the relative creation time in seconds.

Written by the indexing model from the issue text.

Description

Python LogRecord has the attribute relativeCreated

Time in milliseconds when the LogRecord was created, relative to the time the logging module was loaded.

It's currently possible to use FluentRecordFormatter to include that in the fluent events

version: 1
formatters:
  fluent_fmt:
    '()': fluent.handler.FluentRecordFormatter
    format:
      "host.hostname": '%(hostname)s'
      "host.id": '%(hostname)s'
      "host.uptime": '%(relativeCreated)d'
      "log.logger": '%(name)s'
      "log.level": '%(levelname)s'
      "log.origin.file.name": '%(pathname)s'
      "log.origin.file.line": '%(lineno)d'
      "log.origin.function": '%(funcName)s'

but relativeCreated is in milliseconds, it would be very convenient to be able to convert that to seconds right in FluentRecordFormatter hence this feature request, please considering allowing something like

  "host.uptime": '%(relativeCreatedInSeconds)d'

were the relativeCreatedInSeconds would be something added by FluentRecordFormatter.

Dominant language
Python
Stars
457
Forks
138
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fluent/fluent-logger-python

All issues in fluent/fluent-logger-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.