beamlit 0.0.34rc55__py3-none-any.whl → 0.0.34rc57__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.
@@ -26,6 +26,8 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor
26
26
  from opentelemetry.trace import NoOpTracerProvider
27
27
  from typing_extensions import Dict
28
28
 
29
+ from beamlit.authentication import get_authentication_headers
30
+
29
31
  from .settings import get_settings
30
32
 
31
33
  tracer: trace.Tracer | None = None
@@ -33,16 +35,13 @@ meter: metrics.Meter | None = None
33
35
  logger: LoggerProvider | None = None
34
36
 
35
37
 
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
38
+ def auth_headers() -> Dict[str, str]:
39
+ settings = get_settings()
40
+ headers = get_authentication_headers(settings)
41
+ return {
42
+ "x-beamlit-authorization": headers.get("X-Beamlit-Authorization", ""),
43
+ "x-beamlit-workspace": headers.get("X-Beamlit-Workspace", ""),
44
+ }
46
45
 
47
46
 
48
47
  def get_logger() -> LoggerProvider:
@@ -57,8 +56,6 @@ def get_resource_attributes() -> Dict[str, Any]:
57
56
  for key in resources.attributes:
58
57
  resources_dict[key] = resources.attributes[key]
59
58
  settings = get_settings()
60
- if settings is None:
61
- raise Exception("Settings are not initialized")
62
59
  resources_dict["workspace"] = settings.workspace
63
60
  resources_dict["service.name"] = settings.name
64
61
  return resources_dict
@@ -66,33 +63,29 @@ def get_resource_attributes() -> Dict[str, Any]:
66
63
 
67
64
  def get_metrics_exporter() -> OTLPMetricExporter | None:
68
65
  settings = get_settings()
69
- if settings is None:
70
- raise Exception("Settings are not initialized")
71
66
  if not settings.enable_opentelemetry:
72
- # Return None or a NoOpExporter equivalent
73
67
  return None
74
- return OTLPMetricExporter()
68
+ return OTLPMetricExporter(headers=auth_headers())
75
69
 
76
70
 
77
71
  def get_span_exporter() -> OTLPSpanExporter | None:
78
72
  settings = get_settings()
79
73
  if not settings.enable_opentelemetry:
80
74
  return None
81
- return OTLPSpanExporter()
75
+ return OTLPSpanExporter(headers=auth_headers())
82
76
 
83
77
 
84
78
  def get_log_exporter() -> OTLPLogExporter | None:
85
79
  settings = get_settings()
86
80
  if not settings.enable_opentelemetry:
87
81
  return None
88
- return OTLPLogExporter()
82
+ return OTLPLogExporter(headers=auth_headers())
89
83
 
90
84
 
91
85
  def instrument_app(app: FastAPI):
92
86
  global tracer
93
87
  global meter
94
88
  settings = get_settings()
95
-
96
89
  if not settings.enable_opentelemetry:
97
90
  # Use NoOp implementations to stub tracing and metrics
98
91
  trace.set_tracer_provider(NoOpTracerProvider())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beamlit
3
- Version: 0.0.34rc55
3
+ Version: 0.0.34rc57
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=GpM7dfAWXDD7h9X4WnI5k-pE2tBHSN08_KN9NHLRugo,5334
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.34rc57.dist-info/METADATA,sha256=ziM3rBAZv480v0PW4M8QVT72n8HcYwaa-OdOvuhc_3U,2412
260
+ beamlit-0.0.34rc57.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
261
+ beamlit-0.0.34rc57.dist-info/RECORD,,