I discovered Logger.metadata/1
can set metadata about FUTURE log messages and I was very excited because I could do somethings like this:
Logger.metadata(something: "xyz")
and then much later in some other function, if I called Logger.error
the log messages would still have that something
metadata available from before! Maybe I even cried, this was so much easier than other languages where I passed values around everywhere just so they would be available to the log.
I am wondering if telemetry also has something similar? As I replace Logger calls with telemetry calls, I find that I am back to the old problem of not having certain values that I would like to include in the messages. (Maybe this means my messages have bad structure?)
I think I could maybe store metadata in a GenServer or process dictionary or ETS (which is maybe how the Logger keeps state?), but this feels maybe not right?
Is there a way to set telemetry metadata ahead of time like Logger?
Also, I think I am not understanding the difference between “measurements” and “metadata”.
And maybe I also am not understanding the “span” function. Many new things!
Thank you for helping my understanding!