bobbui / json-logging-python

Cloud-native distributed Python logging library to emit JSON log that can be easily indexed by logging infrastructure
Apache License 2.0
303 stars 62 forks source link

Method for settings CORRELATION_ID_HEADERS and others not best practice #58

Closed zeroaltitude closed 3 years ago

zeroaltitude commented 4 years ago

In the code, to set variables such as CORRELATION_ID_HEADERS, you manually overwrite them with global values using the namespace itself. This is not a best practice in python. Instead, have DEFAULT_CORRELATION_ID_HEADERS and let that be overridden by CORRELATION_ID_HEADERS as an environment variable.

bobbui commented 4 years ago

ok not sure if I understand what you mean. Right now, the only way to specify headers is by setting json_logging.CORRELATION_ID_HEADERS. So u think it makes more sense to have a DEFAULT_CORRELATION_ID_HEADERS and let that overridden by an env var called CORRELATION_ID_HEADERS ?

From a practical standpoint, I would say that the request-id headers config will most likely be the same across environments. So it convenient to have it hardcoded in the application source code

zeroaltitude commented 4 years ago

I can fork it and show you what I mean in a pull request. Also, as these variables are ones I absolutely need to modify in an AWS lambda environment, I can guarantee that having flexibility to modify these is useful.

bobbui commented 4 years ago

ok cool, now I understand more. looking forward to your PR though

bobbui commented 3 years ago

closed as no response from owner, can be opened again if still interested