Giter Club home page Giter Club logo

Comments (2)

jamadden avatar jamadden commented on June 2, 2024
  • That's not a gevent version
  • You didn't say what you're doing. A traceback with no context is not a bug report.

from gevent.

juho-y avatar juho-y commented on June 2, 2024

I have this same issue with

  • gunicorn 20.10
  • gevent 24.2.1
  • opentelemetry-sdk 1.23.0
  • os: macos sonoma, linux
  • does not matter if containerized or not

I have yet to find a consistent repro for this but it goes roughly like this. The Flask app needs to perform a handful of requests, and sometimes, it freezes or throws errors, as mentioned earlier.

This is an issue with the opentelemetry instrumentation with gevent workers.

# gunicorn.config.py


from gevent import monkey

monkey.patch_all()

import multiprocessing
import os


from opentelemetry import metrics, trace  # noqa: E402 monkey patching must be done before importing Instrumentor
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    OTLPMetricExporter,
)
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    OTLPSpanExporter,
)
from opentelemetry.sdk.metrics import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    MeterProvider,
)
from opentelemetry.sdk.metrics.export import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    PeriodicExportingMetricReader,
)
from opentelemetry.sdk.resources import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    Resource,
)
from opentelemetry.sdk.trace import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    TracerProvider,
)
from opentelemetry.sdk.trace.export import (  # noqa: E402 monkey patching must be done before importing Instrumentor
    BatchSpanProcessor,
)

workers = 1
worker_class = "gevent"
worker_connections = int(os.getenv("GUNICORN_WORKER_CONNECTIONS", "1000"))
timeout = int(os.getenv("GUNICORN_WORKER_TIMEOUT", "600"))
keepalive = int(os.getenv("GUNICORN_WORKER_KEEPALIVE", "60"))
loglevel = "info"


accesslog = "-"
errorlog = "-"


def post_fork(server, worker):
      server.log.info("Worker spawned (pid: %s)", worker.pid)
      resource = Resource.create(attributes={"service.name": os.getenv("OTEL_SERVICE_NAME", "lih")})
      trace.set_tracer_provider(TracerProvider(resource=resource))
      span_processor = BatchSpanProcessor(OTLPSpanExporter(insecure=True))
      trace.get_tracer_provider().add_span_processor(span_processor)

      reader = PeriodicExportingMetricReader(OTLPMetricExporter())
      metrics.set_meter_provider(
          MeterProvider(
              resource=resource,
              metric_readers=[reader],
          )
      )
# app.py
from flask import Flask, request
from opentelemetry.instrumentation.flask import FlaskInstrumentor
import os


app = Flask(__name__)
FlaskInstrumentor().instrument_app(app)


@app.route("/", methods=["POST"])
def process_request():
    data = request.get_json()

    do_something_with_data(data)



if __name__ == "__main__":
    app.run(debug=os.getenv("FLASK_DEBUG", "False").lower() == "true")
FROM python:3.10

ENV PYTHONBUFFERED 1

COPY . .

RUN pip install -r requirements.txt

EXPOSE 5000

CMD ["gunicorn", "-c", "gunicorn.config.py", "--bind", "0.0.0.0:5000", "app:app"]

from gevent.

ayush-raj8 avatar ayush-raj8 commented on June 2, 2024

Facing the same issue. These signatures appear in the log.

from gevent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.