feat(enterprise): Add OTEL logs export with span_id correlation

- Add ENTERPRISE_OTEL_LOGS_ENABLED and ENTERPRISE_OTLP_LOGS_ENDPOINT config options
- Implement EnterpriseLoggingHandler for log record translation with trace/span ID parsing
- Add LoggerProvider and BatchLogRecordProcessor for OTLP log export
- Correlate telemetry logs with spans via span_id_source parameter
- Attach log handler during enterprise telemetry initialization
This commit is contained in:
GareArc
2026-02-02 18:16:58 -08:00
parent 182bd5b61e
commit fc2e9c20a6
5 changed files with 142 additions and 13 deletions

View File

@ -37,6 +37,7 @@ def init_app(app: DifyApp) -> None:
_exporter = EnterpriseExporter(dify_config)
atexit.register(_exporter.shutdown)
_exporter.attach_log_handler()
# Import to trigger @signal.connect decorator registration
import enterprise.telemetry.event_handlers # noqa: F401 # type: ignore[reportUnusedImport]