Skip to content

CloudTraceSpanExporter+SimpleSpanProcessor+RequestsInstrumentor Infinite Loop #230

Open
@davidn

Description

@davidn

If you enable RequestsInstrumentor while using CloudTraceSpanExporter with SimpleSpanProcessor, you get an infinite loop on the first span exported.

When running locally, I see the following lines repeated with log level debug:

I0206 10:03:10.286911 140694698043136 connectionpool.py:460] https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 200 None
I0206 10:03:10.290570 140694689650432 requests.py:192] Making request: POST https://oauth2.googleapis.com/token

When running in cloud run, I see the following log entry repeated:

http://metadata.google.internal:80 "GET /computeMetadata/v1/instance/service-accounts/default/?recursive=true HTTP/1.1" 200 615

Because of this I assume the issue is that a requests call is made during cloud trace export, which results in a span being recorded by the instrumentor and thus a new call to cloud trace export before the first one has complete auth set-up, resulting in new auth set-up and so on.

This blog post appears to document the same issue: https://minherz.medium.com/today-i-learned-why-using-opentelemetry-requestsinstrumentor-can-freeze-your-application-ae09410b016d

Because Cloud Run requires SimpleSpanProcessor, this essentially means RequestInstrumentor cannot be used in that environment.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions