from fluent import sender
from fluent import event
sender.setup("tag")
event.Event("label", data)
There were many articles doing like this. I felt uncomfortable, so when I actually looked at the implementation, I used global variables! (Use a global variable called _global_sender in the setup method-> in init of Event, call global_sender.emit_with_name and pass the current time to timestamp)
so
from fluent import sender
import time
send = sender.FluentSender("tag", host="localhost", port=24224)
send.emit_with_time("label", int(time.time()), data)
It's safe
Recommended Posts