mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-25 09:30:33 +00:00
Merge pull request #2744 from WesleyAC/opentelemetry-console-exporter
Add OpenTelemetry console exporter option
This commit is contained in:
commit
e9d08e7424
5 changed files with 19 additions and 9 deletions
|
@ -35,7 +35,7 @@ class BookwyrmConfig(AppConfig):
|
|||
# pylint: disable=no-self-use
|
||||
def ready(self):
|
||||
"""set up OTLP and preview image files, if desired"""
|
||||
if settings.OTEL_EXPORTER_OTLP_ENDPOINT:
|
||||
if settings.OTEL_EXPORTER_OTLP_ENDPOINT or settings.OTEL_EXPORTER_CONSOLE:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from bookwyrm.telemetry import open_telemetry
|
||||
|
||||
|
|
|
@ -402,6 +402,7 @@ CSP_INCLUDE_NONCE_IN = ["script-src"]
|
|||
OTEL_EXPORTER_OTLP_ENDPOINT = env("OTEL_EXPORTER_OTLP_ENDPOINT", None)
|
||||
OTEL_EXPORTER_OTLP_HEADERS = env("OTEL_EXPORTER_OTLP_HEADERS", None)
|
||||
OTEL_SERVICE_NAME = env("OTEL_SERVICE_NAME", None)
|
||||
OTEL_EXPORTER_CONSOLE = env.bool("OTEL_EXPORTER_CONSOLE", False)
|
||||
|
||||
TWO_FACTOR_LOGIN_MAX_SECONDS = env.int("TWO_FACTOR_LOGIN_MAX_SECONDS", 60)
|
||||
TWO_FACTOR_LOGIN_VALIDITY_WINDOW = env.int("TWO_FACTOR_LOGIN_VALIDITY_WINDOW", 2)
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
from opentelemetry import trace
|
||||
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
|
||||
from opentelemetry.sdk.trace import TracerProvider
|
||||
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
||||
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
|
||||
|
||||
from bookwyrm import settings
|
||||
|
||||
trace.set_tracer_provider(TracerProvider())
|
||||
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
|
||||
if settings.OTEL_EXPORTER_CONSOLE:
|
||||
trace.get_tracer_provider().add_span_processor(
|
||||
BatchSpanProcessor(ConsoleSpanExporter())
|
||||
)
|
||||
else:
|
||||
trace.get_tracer_provider().add_span_processor(
|
||||
BatchSpanProcessor(OTLPSpanExporter())
|
||||
)
|
||||
|
||||
|
||||
def instrumentDjango():
|
||||
|
|
|
@ -7,7 +7,7 @@ class CelerywyrmConfig(AppConfig):
|
|||
verbose_name = "BookWyrm Celery"
|
||||
|
||||
def ready(self):
|
||||
if settings.OTEL_EXPORTER_OTLP_ENDPOINT:
|
||||
if settings.OTEL_EXPORTER_OTLP_ENDPOINT or settings.OTEL_EXPORTER_CONSOLE:
|
||||
from bookwyrm.telemetry import open_telemetry
|
||||
|
||||
open_telemetry.instrumentCelery()
|
||||
|
|
|
@ -25,11 +25,11 @@ boto3==1.26.57
|
|||
django-storages==1.13.2
|
||||
django-storages[azure]
|
||||
django-redis==5.2.0
|
||||
opentelemetry-api==1.11.1
|
||||
opentelemetry-exporter-otlp-proto-grpc==1.11.1
|
||||
opentelemetry-instrumentation-celery==0.30b1
|
||||
opentelemetry-instrumentation-django==0.30b1
|
||||
opentelemetry-sdk==1.11.1
|
||||
opentelemetry-api==1.16.0
|
||||
opentelemetry-exporter-otlp-proto-grpc==1.16.0
|
||||
opentelemetry-instrumentation-celery==0.37b0
|
||||
opentelemetry-instrumentation-django==0.37b0
|
||||
opentelemetry-sdk==1.16.0
|
||||
protobuf==3.20.*
|
||||
pyotp==2.8.0
|
||||
qrcode==7.3.1
|
||||
|
|
Loading…
Reference in a new issue