Skip to content
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

Add support to pass headers sent with each POST request #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fridex
Copy link

@fridex fridex commented Jan 20, 2021

FIrst, thanks for implementing python-logging-loki!

We want to adopt this library but our Loki instance requires X-Scope-OrgID header to be sent with each request. This pull request adds the capability to do so when configuring the handler.

@fridex
Copy link
Author

fridex commented Feb 10, 2021

@GreyZmeem friendly ping, is this something to consider in the implementation

@4n4nd
Copy link

4n4nd commented May 20, 2021

@GreyZmeem hey! any luck reviewing this PR?

@jcdauchy-moodys
Copy link

That would be nice !

@eliasericsson
Copy link

I'd also like to see this implemented!

@armandomiani
Copy link

armandomiani commented May 3, 2023

Although this PR is the best solution, you can bypass patching the emitter session_class. (meanwhile PR is not merged)

class FakeSessionCreator():
    session = requests.Session()

    def post(self, url, json):
        return self.session.post(url=url, json=json, headers={
            'X-Scope-OrgID': 'tenant_id'
        })
    
    def close(self):
        self.session.close()
        
emitter.LokiEmitterV1.session_class = FakeSessionCreator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants