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
Possibility to specify custom header name for bounded request_id #324
Comments
can it be achieved using bind_extra_request_metadata signal? |
I am not sure if you mean a request header to bind to the logs or return a an ID in a header in the response. |
Talking about this part of code
if the x-request-id could be customized |
The idea is to use the traceId generated by the elb as request-id, which sometimes have a custom name, not always named x-request-id |
You can technically do this: from django.contrib.sites.shortcuts import get_current_site
from django.dispatch import receiver
from django_structlog import signals
import structlog
@receiver(signals.bind_extra_request_metadata)
def bind_custom_id(request, logger, **kwargs):
my_custom_id = "hey"
structlog.contextvars.bind_contextvars(request_id=my_custom_id) |
Yes I know, ok I will go with that, thank you. |
I am considering to add a section "How-To Guides" with these different use-cases I saw over time (#325). |
The application could be behind aws elb, that use a non customisable trace_id X-Amzn-Trace-Id, if we can specify request header name from settings, we can use same id generated by aws across all logs. What do you think?
The text was updated successfully, but these errors were encountered: