Skip to content

Sporadic Connection Errors on Azure containers apps/jobs #4632

Open
@yovelcohen

Description

@yovelcohen

Describe your environment

OS: Various Linux distros (different base images used)
Python version: Python 3.11/3.12
SDK version: 1.32.1

What happened?

I'm using logfire as my logging library, which is a wrapper on top of the opentelemetry sdk.
We run microservices on azure container apps/jobs.

Sometimes, especially with jobs, the logging process fails with the following error:

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
ERROR:opentelemetry.sdk.metrics._internal.export:Exception while exporting metrics

This is very sporadic, one job can log everything successfully, one won't be able to log at all, and some would stop mid-way through the run, leading to partial spans.
I've discussed this issue with the logfire team here and they claim it's not an issue with their backend.
I'm still not sure that's 100% accurate but I thought maybe here I'll find an idea as to why it happens.

Steps to Reproduce

If it helps, here's how I setup my logfire configuration (it sets up otel behind the scenes):

logfire.configure(
	send_to_logfire="if-token-present",
	token=settings.LOGFIRE_TOKEN,
	service_name='SomeJob',
	environment=settings.ENV_TYPE,
	console=logfire.ConsoleOptions(min_log_level="trace", show_project_link=False),
	advanced=logfire.AdvancedOptions(base_url="https://logfire-api.pydantic.dev")
)

Expected Result

logging is consistent and the connection doesn't interrupt midway.

Actual Result

sporadic connection errors.

Additional context

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions