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

can you attach a LogRecordProcessor to default logger provider? #4201

Open
ty-elastic opened this issue Sep 25, 2024 · 0 comments
Open

can you attach a LogRecordProcessor to default logger provider? #4201

ty-elastic opened this issue Sep 25, 2024 · 0 comments

Comments

@ty-elastic
Copy link

ty-elastic commented Sep 25, 2024

Is your feature request related to a problem?

Hi, I want to write a custom LogRecordProcessor that will attach baggage attributes (on the current context) to the log record. I've written it, and I'd like to attach it to the default logger provider OTel sets up when you set OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED="true".

I can do that like this:

log_provider = logs.get_logger_provider()
log_provider.add_log_record_processor(BaggageLogRecordProcessor())

and the emit() gets called as expected. I can set stuff, but then I realized that once I do that, log records are no longer being emitted to the OTLP exporter.

Can I hook the existing auto-instrumentation otel logging exporter like this, modify records, and still have them emit to the OTLP exporter without further config?

That seems possible with span processors... like:

tracer_provider = trace.get_tracer_provider()
tracer_provider.add_span_processor(...)

but with the log record processors, it seems the expectation is that they manually emit the record to something... in some examples, i've seen an exporter passed in, and then the processor manually exports to that exporter... to make that work, i would then have to basically construct my own logger_provider stack (adding my processor, then a manually configured otlp exporter). is there a way to create a "pass through" processor, like span processors?

Describe the solution you'd like

ideally a "pass through" processor for log records, like span processors

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

No

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

No branches or pull requests

2 participants