mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-24 16:57:30 +00:00
* fix otel instrumentation
* fix name conflict
(cherry picked from commit b4e74791e6)
Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
1 parent
f5cf0ef6ba
commit
7507c45a45
2 files changed
+10
No files matched your search
@@ -34,6 +34,7 @@ from InvenTree.config import (
|
||||
)
|
||||
from InvenTree.ready import isInMainThread, isRunningBackup
|
||||
from InvenTree.sentry import default_sentry_dsn, init_sentry
|
||||
from InvenTree.tracing import ensure_otel_middleware
|
||||
from InvenTree.validators import invalid_site_url_hint
|
||||
from InvenTree.version import checkMinPythonVersion, inventreeCommitHash
|
||||
from users.oauth2_scopes import oauth2_scopes
|
||||
@@ -676,6 +677,7 @@ TRACING_ENABLED = (
|
||||
TRACING_DETAILS: Optional[dict] = tracing.configure_tracing(
|
||||
DB_ENGINE, TRACING_ENABLED, inventree_tags
|
||||
)
|
||||
MIDDLEWARE = ensure_otel_middleware(MIDDLEWARE)
|
||||
|
||||
# Cache configuration
|
||||
GLOBAL_CACHE_ENABLED = is_global_cache_enabled()
|
||||
|
||||
@@ -173,6 +173,14 @@ def setup_tracing(
|
||||
TRACE_PID = os.getpid()
|
||||
|
||||
|
||||
def ensure_otel_middleware(middleware):
|
||||
"""Ensure the OTELmiddleware is the first entry in MIDDLEWARE."""
|
||||
if not DjangoInstrumentor().is_instrumented_by_opentelemetry:
|
||||
return list(middleware)
|
||||
otel = DjangoInstrumentor._opentelemetry_middleware
|
||||
return [otel, *(m for m in middleware if m != otel)]
|
||||
|
||||
|
||||
def setup_instruments(db_engine: str): # pragma: no cover
|
||||
"""Run auto-instrumentation for OpenTelemetry tracing."""
|
||||
if not DjangoInstrumentor()._is_instrumented_by_opentelemetry:
|
||||
|
||||
Reference in new issue
Block a user