1
0
Fork 0

Added mypy to scripts and workflow, and some first annotations for celerywyrm

This commit is contained in:
Joeri de Ruiter 2023-07-22 13:27:43 +02:00
parent 9c5b5d0ac1
commit 75f37d7361
10 changed files with 90 additions and 7 deletions

View file

@ -1,6 +1,6 @@
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace import TracerProvider, Tracer
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from bookwyrm import settings
@ -16,19 +16,19 @@ elif settings.OTEL_EXPORTER_OTLP_ENDPOINT:
)
def instrumentDjango():
def instrumentDjango() -> None:
from opentelemetry.instrumentation.django import DjangoInstrumentor
DjangoInstrumentor().instrument()
def instrumentPostgres():
def instrumentPostgres() -> None:
from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor
Psycopg2Instrumentor().instrument()
def instrumentCelery():
def instrumentCelery() -> None:
from opentelemetry.instrumentation.celery import CeleryInstrumentor
from celery.signals import worker_process_init
@ -37,5 +37,5 @@ def instrumentCelery():
CeleryInstrumentor().instrument()
def tracer():
def tracer() -> Tracer:
return trace.get_tracer(__name__)