Skip to content

Commit

Permalink
fix: add db calls
Browse files Browse the repository at this point in the history
  • Loading branch information
sennierer committed Oct 9, 2024
1 parent 218192b commit d4fab1e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gunicorn.config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.instrumentation.django import DjangoInstrumentor
from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor


def post_fork(server, worker):
server.log.info("Worker spawned (pid: %s)", worker.pid)

resource = Resource.create(attributes={"service.name": "apis-oebl-pfp"})

trace.set_tracer_provider(TracerProvider(resource=resource))
provider = TracerProvider(resource=resource)
trace.set_tracer_provider(provider)
span_processor = BatchSpanProcessor(
OTLPSpanExporter(endpoint=os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT"))
)
trace.get_tracer_provider().add_span_processor(span_processor)
DjangoInstrumentor().instrument(
tracer_provider=provider,
is_sql_commentor_enabled=True,
)
Psycopg2Instrumentor().instrument(
tracer_provider=provider, skip_dep_check=True, enable_commenter=True
)

0 comments on commit d4fab1e

Please sign in to comment.