bdd-trace 0.4.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bdd_trace/log.py CHANGED
@@ -17,6 +17,7 @@ def setup_logging(
17
17
  level: str | int = INFO,
18
18
  trace_id_format: str = "%(asctime)s|%(levelname)s|%(name)s|%(otelTraceID)s|%(message)s",
19
19
  no_trace_id_format: str = "%(asctime)s|%(levelname)s|%(name)s|%(message)s",
20
+ extra_handlers: list[Handler] | None = None,
20
21
  ) -> None:
21
22
  global _log_queue, _log_listener
22
23
  if _log_queue is not None or _log_listener is not None:
@@ -29,9 +30,10 @@ def setup_logging(
29
30
  for module in modules:
30
31
  _setup_module_logger(level, module)
31
32
 
33
+ log_process_handlers = extra_handlers or []
32
34
  format = trace_id_format if profile != Profile.NO_TRACE else no_trace_id_format
33
35
  console_handler = _create_console_handler(modules, format)
34
- log_process_handlers = [console_handler]
36
+ log_process_handlers.append(console_handler)
35
37
  if profile != Profile.NO_TRACE:
36
38
  otel_handler = LoggingHandler()
37
39
  log_process_handlers.append(otel_handler)
bdd_trace/trace.py CHANGED
@@ -20,6 +20,10 @@ _EXPORTER_OTLP_INSECURE_KEY = "exporter_otlp_insecure"
20
20
  _SERVICE_NAME_KEY = "service_name"
21
21
  _PYTHON_FASTAPI_EXCLUDE_URLS_KEY = "python_fastapi_excluded_urls"
22
22
  _INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST_KEY = "instrumentation_http_capture_headers_server_request"
23
+ _OTEL_PYTHON_LOG_CORRELATION_KEY = "otel_python_log_correlation"
24
+ _EXPORTER_OTLP_TRACES_PROTOCOL_KEY = "exporter_otlp_traces_protocol"
25
+ _EXPORTER_OTLP_METRICS_PROTOCOL_KEY = "exporter_otlp_metrics_protocol"
26
+ _EXPORTER_OTLP_LOGS_PROTOCOL_KEY = "exporter_otlp_logs_protocol"
23
27
 
24
28
  _default_envs = {
25
29
  _TRACES_EXPORTER_KEY: "otlp",
@@ -28,14 +32,18 @@ _default_envs = {
28
32
  _PYTHON_FASTAPI_EXCLUDE_URLS_KEY: "/healthCheck",
29
33
  _INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST_KEY: "X-User-Id,X-Conversation-From",
30
34
  _EXPORTER_OTLP_INSECURE_KEY: "true",
35
+ _OTEL_PYTHON_LOG_CORRELATION_KEY: "true",
31
36
  }
32
37
 
33
38
  _profile_config = {
34
39
  Profile.DEV: {
35
- _TRACES_EXPORTER_KEY: "console",
36
- _METRICS_EXPORTER_KEY: "console",
37
- _LOGS_EXPORTER_KEY: "console",
38
- _EXPORTER_OTLP_ENDPOINT_KEY: None,
40
+ _TRACES_EXPORTER_KEY: "otlp",
41
+ _METRICS_EXPORTER_KEY: "otlp",
42
+ _LOGS_EXPORTER_KEY: "otlp",
43
+ _EXPORTER_OTLP_ENDPOINT_KEY: "http://otel-sls-collector-test.life-science-platform.zhejianglab.com",
44
+ _EXPORTER_OTLP_TRACES_PROTOCOL_KEY: "http/protobuf",
45
+ _EXPORTER_OTLP_METRICS_PROTOCOL_KEY: "http/protobuf",
46
+ _EXPORTER_OTLP_LOGS_PROTOCOL_KEY: "http/protobuf",
39
47
  },
40
48
  Profile.TEST: {
41
49
  _TRACES_EXPORTER_KEY: "otlp",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bdd-trace
3
- Version: 0.4.1
3
+ Version: 0.5.2
4
4
  Summary: BDD项目日志和追踪SDK
5
5
  Author: 蔡涛
6
6
  Author-email: 蔡涛 <caitao@zhejianglab.cn>
@@ -0,0 +1,7 @@
1
+ bdd_trace/__init__.py,sha256=X4Nx6VppPfXXXEe5oC_foryalbOk5f9HLOi50Nat8mY,154
2
+ bdd_trace/log.py,sha256=Solf9XJTnfgEtvQidTQadoQ7MBHuPSrpPBCUt6X1Dro,2846
3
+ bdd_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ bdd_trace/trace.py,sha256=wmzwkcHtV7CslLFKzpIFjSv-55WsqX28uPfsgYDvumA,3784
5
+ bdd_trace-0.5.2.dist-info/WHEEL,sha256=Jb20R3Ili4n9P1fcwuLup21eQ5r9WXhs4_qy7VTrgPI,79
6
+ bdd_trace-0.5.2.dist-info/METADATA,sha256=aZ5MjyAKeUuB1aYKOrK242J8Sz7HHkz4ahpYQ-F-0cI,1585
7
+ bdd_trace-0.5.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- bdd_trace/__init__.py,sha256=X4Nx6VppPfXXXEe5oC_foryalbOk5f9HLOi50Nat8mY,154
2
- bdd_trace/log.py,sha256=dCxXu9qoPeInqgZw6ElumDmc4B_QX5KultLlZ5edfns,2745
3
- bdd_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- bdd_trace/trace.py,sha256=ovXyQkKQVzhMjScIxAMi55UG7lZUYn6ipwY6nN_W0AM,3229
5
- bdd_trace-0.4.1.dist-info/WHEEL,sha256=Jb20R3Ili4n9P1fcwuLup21eQ5r9WXhs4_qy7VTrgPI,79
6
- bdd_trace-0.4.1.dist-info/METADATA,sha256=0W8Yh05xaCMEOCtIp0FArslo_hDU7vvQuHFJ2W-1eLI,1585
7
- bdd_trace-0.4.1.dist-info/RECORD,,