We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We have a scenario where we dont need all logs to go to logfire, for example debug logs, but we do want debug logs to be on the console.
Currently if sampling is implemented it impacts both the console and logfire logs without a workaround that im aware of.
The text was updated successfully, but these errors were encountered:
Here's a workaround:
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace.export import BatchSpanProcessor import logfire from logfire._internal.exporters.wrapper import WrapperSpanExporter class DontSendDebugLogs(WrapperSpanExporter): def export(self, spans): spans = [span for span in spans if span.attributes.get('logfire.level_num', 9) >= 9] return super().export(spans) logfire.configure( send_to_logfire=False, console=logfire.ConsoleOptions(min_log_level='debug'), additional_span_processors=[ BatchSpanProcessor( DontSendDebugLogs( OTLPSpanExporter( endpoint='https://logfire-api.pydantic.dev/v1/traces', headers={'Authorization': 'your-write-token'}, ) ) ) ], ) logfire.debug('debug') with logfire.span('my-span'): logfire.error('error')
However this misses some of the features of the exporter that logfire.configure(send_to_logfire=True) creates, namely pending spans and retrying.
logfire.configure(send_to_logfire=True)
Sorry, something went wrong.
No branches or pull requests
Description
We have a scenario where we dont need all logs to go to logfire, for example debug logs, but we do want debug logs to be on the console.
Currently if sampling is implemented it impacts both the console and logfire logs without a workaround that im aware of.
The text was updated successfully, but these errors were encountered: