-
Notifications
You must be signed in to change notification settings - Fork 11
Support set and get correlation_id #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
README.rst
Outdated
Setting and getting correlation ID | ||
"""""""""""""""""""""""""""""""""" | ||
|
||
When using cf_logging in a web application you don't need to care about setting and getting correlation ID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to care about setting and getting correlation ID-> you don't need to get or set the correction ID
README.rst
Outdated
"""""""""""""""""""""""""""""""""" | ||
|
||
When using cf_logging in a web application you don't need to care about setting and getting correlation ID, | ||
because the logging frameworks supported will fetch it from HTTP headers and will set it to the log output for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the logging frameworks supported will fetch it from HTTP headers and will set it to the log output for you. -> because the logging library will fetch it from the HTTP headers and set it.
README.rst
Outdated
|
||
When using cf_logging in a web application you don't need to care about setting and getting correlation ID, | ||
because the logging frameworks supported will fetch it from HTTP headers and will set it to the log output for you. | ||
But if you are developing an application triggered via cli or messaging or by schedule, you might want to set the correlation ID manually, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non-web applications you have to set the correlation ID manually, as it is used for filtering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not mandatory to set correlation ID, only if app developer would like to. If available it might be used by application admin to filter the logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For non-web applications you could to set the correlation ID manually, as it could be used for filtering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is obvious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I was typing the message I think we should have in the readme.
"For non-web applications you could to set the correlation ID manually, as it could be used for filtering."
instead of
"But if you are developing an application triggered via cli or messaging or by schedule, you might want to set the correlation ID manually, so all log entries can be filtered lately based on this correlation_id."
sorter.
README.rst
Outdated
But if you are developing an application triggered via cli or messaging or by schedule, you might want to set the correlation ID manually, | ||
so all log entries can be filtered lately based on this correlation_id. | ||
|
||
Setting and getting correlation_id can be done via: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*the correlation_id
README.rst
Outdated
cf_logging.FRAMEWORK.context.get_correlation_id() | ||
cf_logging.FRAMEWORK.context.set_correlation_id(value) | ||
The context created in cf_logging that have been initialized when no specific framework is used (like ``cf_logging.init()``) is global which means that setting correlation_id will result in same correlatino_id for the all logs from this point on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever a correlation id is set after initializing cf_logging without a specific framework (ex: cf_logging.init()
) - the correlation id set would be used for each log.
If you need a thread .... and provide your own thread safe context implementation.
README.rst
Outdated
The context created in cf_logging that have been initialized when no specific framework is used (like ``cf_logging.init()``) is global which means that setting correlation_id will result in same correlatino_id for the all logs from this point on. | ||
If you need thread safe correlation_id, you can reuse the ``cf_logging.job_loffing.framework.JobFramework`` and provide own context implementation that is thread safe. | ||
|
||
If you need to get the correlation_id in web application, take into account the framework you are using. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above we say that for web frameworks we don't have to worry about getting or setting the correction id.
Why would a user need to get the correlation id in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In use-cases when for example http request triggers new message in MQ, which in turn is used to trigger new job where correlation_id contained in the message (fetched from HTTP request) will be set to logging lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case from above: in a web application you don't need to care about setting and getting correlation ID
We should remove the 'getting' - as it a valid use case?
So a user doesn't have to set it, but could still have to get it.
README.rst
Outdated
The context created in cf_logging that have been initialized when no specific framework is used (like ``cf_logging.init()``) is global which means that setting correlation_id will result in same correlatino_id for the all logs from this point on. | ||
If you need thread safe correlation_id, you can reuse the ``cf_logging.job_loffing.framework.JobFramework`` and provide own context implementation that is thread safe. | ||
|
||
If you need to get the correlation_id in web application, take into account the framework you are using. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in *a web application
No description provided.