Producing logs
Following the pattern from previous signals, we should be ready to get an instance of a log producer and start logging, right? Well, not quite – let's find out why.
Using LogEmitter
Using the same method that we used for metrics and tracing, we can now obtain LogEmitter
, which will allow us to use the OpenTelemetry API to start producing logs. The following code shows us how to accomplish this using the get_log_emitter
method:
logs.py
from opentelemetry.sdk._logs import ( LogEmitterProvider, get_log_emitter_provider, set_log_emitter_provider, ) if __name__ == "__main__": configure_log_emitter_provider() log_emitter = get_log_emitter_provider().get_log_emitter( "shopper", "0.1.2", ...