beamlit 0.0.34rc55__py3-none-any.whl → 0.0.34rc56__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.
@@ -15,6 +15,9 @@ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
15
15
  )
16
16
  from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
17
17
  from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
18
+ from opentelemetry.instrumentation.system_metrics import (
19
+ SystemMetricsInstrumentor,
20
+ )
18
21
  from opentelemetry.metrics import NoOpMeterProvider
19
22
  from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
20
23
  from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
@@ -26,6 +29,8 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor
26
29
  from opentelemetry.trace import NoOpTracerProvider
27
30
  from typing_extensions import Dict
28
31
 
32
+ from beamlit.authentication import get_authentication_headers
33
+
29
34
  from .settings import get_settings
30
35
 
31
36
  tracer: trace.Tracer | None = None
@@ -33,16 +38,13 @@ meter: metrics.Meter | None = None
33
38
  logger: LoggerProvider | None = None
34
39
 
35
40
 
36
- def get_tracer() -> trace.Tracer:
37
- if tracer is None:
38
- raise Exception("Tracer is not initialized")
39
- return tracer
40
-
41
-
42
- def get_meter() -> metrics.Meter:
43
- if meter is None:
44
- raise Exception("Meter is not initialized")
45
- return meter
41
+ def auth_headers() -> Dict[str, str]:
42
+ settings = get_settings()
43
+ headers = get_authentication_headers(settings)
44
+ return {
45
+ "x-beamlit-authorization": headers.get("X-Beamlit-Authorization", ""),
46
+ "x-beamlit-workspace": headers.get("X-Beamlit-Workspace", ""),
47
+ }
46
48
 
47
49
 
48
50
  def get_logger() -> LoggerProvider:
@@ -57,8 +59,6 @@ def get_resource_attributes() -> Dict[str, Any]:
57
59
  for key in resources.attributes:
58
60
  resources_dict[key] = resources.attributes[key]
59
61
  settings = get_settings()
60
- if settings is None:
61
- raise Exception("Settings are not initialized")
62
62
  resources_dict["workspace"] = settings.workspace
63
63
  resources_dict["service.name"] = settings.name
64
64
  return resources_dict
@@ -66,33 +66,29 @@ def get_resource_attributes() -> Dict[str, Any]:
66
66
 
67
67
  def get_metrics_exporter() -> OTLPMetricExporter | None:
68
68
  settings = get_settings()
69
- if settings is None:
70
- raise Exception("Settings are not initialized")
71
69
  if not settings.enable_opentelemetry:
72
- # Return None or a NoOpExporter equivalent
73
70
  return None
74
- return OTLPMetricExporter()
71
+ return OTLPMetricExporter(headers=auth_headers())
75
72
 
76
73
 
77
74
  def get_span_exporter() -> OTLPSpanExporter | None:
78
75
  settings = get_settings()
79
76
  if not settings.enable_opentelemetry:
80
77
  return None
81
- return OTLPSpanExporter()
78
+ return OTLPSpanExporter(headers=auth_headers())
82
79
 
83
80
 
84
81
  def get_log_exporter() -> OTLPLogExporter | None:
85
82
  settings = get_settings()
86
83
  if not settings.enable_opentelemetry:
87
84
  return None
88
- return OTLPLogExporter()
85
+ return OTLPLogExporter(headers=auth_headers())
89
86
 
90
87
 
91
88
  def instrument_app(app: FastAPI):
92
89
  global tracer
93
90
  global meter
94
91
  settings = get_settings()
95
-
96
92
  if not settings.enable_opentelemetry:
97
93
  # Use NoOp implementations to stub tracing and metrics
98
94
  trace.set_tracer_provider(NoOpTracerProvider())
@@ -147,6 +143,7 @@ def instrument_app(app: FastAPI):
147
143
  # Only instrument the app when OpenTelemetry is enabled
148
144
  FastAPIInstrumentor.instrument_app(app)
149
145
  HTTPXClientInstrumentor().instrument()
146
+ SystemMetricsInstrumentor().instrument()
150
147
 
151
148
 
152
149
  def shutdown_instrumentation():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beamlit
3
- Version: 0.0.34rc55
3
+ Version: 0.0.34rc56
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <ch.ploujoux@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -17,6 +17,7 @@ Requires-Dist: opentelemetry-api>=1.28.2
17
17
  Requires-Dist: opentelemetry-exporter-otlp>=1.28.2
18
18
  Requires-Dist: opentelemetry-instrumentation-fastapi>=0.49b2
19
19
  Requires-Dist: opentelemetry-instrumentation-httpx>=0.49b2
20
+ Requires-Dist: opentelemetry-instrumentation-system-metrics>=0.50b0
20
21
  Requires-Dist: opentelemetry-sdk>=1.28.2
21
22
  Requires-Dist: pydantic-settings<2.7.0,>=2.6.1
22
23
  Requires-Dist: pydantic<2.11.0,>=2.10.3
@@ -130,7 +130,7 @@ beamlit/authentication/credentials.py,sha256=p_1xenabCbQuRz7BiFk7oTK4uCxAt_zoyku
130
130
  beamlit/authentication/device_mode.py,sha256=tmr22gllKOZwBRub_QjF5pYa425x-nE8tQNpZ_EGR6g,3644
131
131
  beamlit/common/__init__.py,sha256=saX5X3hRCJ9erSlXuSkZ2VGgquvpgdcofAU_9sM4bCE,354
132
132
  beamlit/common/error.py,sha256=f9oJDFxhoHK-vpjxBgEp0NwWIk0N_THPemUI7uQxVzU,270
133
- beamlit/common/instrumentation.py,sha256=bW3UN0Ca24zPFZSYjqWkrFfBVDp_yL10T3jVD403KvI,5386
133
+ beamlit/common/instrumentation.py,sha256=8aR5XLLq22_vScJlDqQVxvqFG-0K4ymqJ98DUp7Lb74,5471
134
134
  beamlit/common/logger.py,sha256=nN_dSOl4bs13QU3Rod-w3e3jYOnlSrHx3_bs-ACY6Aw,1115
135
135
  beamlit/common/secrets.py,sha256=sid81bOe3LflkMKDHwBsBs9nIju8bp5-v9qU9gkyNMc,212
136
136
  beamlit/common/settings.py,sha256=b2rvby-ufG3M0AB1ReoWFM-1EzF1LaE-gbokO9HvQDI,3810
@@ -256,6 +256,6 @@ beamlit/serve/app.py,sha256=gYQvUK_S7g0Em-idND8HrVDqgg5LlIemheSGlX2Jj8U,3638
256
256
  beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
257
257
  beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
258
258
  beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
259
- beamlit-0.0.34rc55.dist-info/METADATA,sha256=4yvNNr_yX2lRYsd14PFw8dB6ykRdp1BIBe0lKOeckM4,2344
260
- beamlit-0.0.34rc55.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
261
- beamlit-0.0.34rc55.dist-info/RECORD,,
259
+ beamlit-0.0.34rc56.dist-info/METADATA,sha256=b7oOq6dqYesq2q5ivAj5ckFcfIZ_KLdOW_HUokE0Lpc,2412
260
+ beamlit-0.0.34rc56.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
261
+ beamlit-0.0.34rc56.dist-info/RECORD,,