-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgunicorn.conf.py
45 lines (31 loc) · 1.31 KB
/
gunicorn.conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from services.logging import logging_config_dict
# Where to log to (stdout and stderr)
accesslog = "-"
errorlog = "-"
# Configure log structure
# http://docs.gunicorn.org/en/stable/settings.html#logconfig-dict
logconfig_dict = logging_config_dict
# workers
workers = 9
# listen
port = 8000
bind = "0.0.0.0"
def post_fork(server, worker):
# opentelemetry initialisation needs these env vars to be set, so ensure they are
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jobserver.settings")
os.environ.setdefault("PYTHONPATH", "")
server.log.info("Worker spawned (pid: %s)", worker.pid)
resource = Resource.create(attributes={"service.name": "job-server"})
trace.set_tracer_provider(TracerProvider(resource=resource))
if "OTEL_EXPORTER_OTLP_ENDPOINT" in os.environ:
span_processor = BatchSpanProcessor(OTLPSpanExporter())
trace.get_tracer_provider().add_span_processor(span_processor)
from opentelemetry.instrumentation.auto_instrumentation import ( # noqa: F401
sitecustomize,
)