mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-16 11:19:26 +00:00
fix(otel): instrumentation providers do not need a config
This commit is contained in:
parent
8fe3a25158
commit
deedb3fb46
5 changed files with 59 additions and 36 deletions
|
|
@ -542,8 +542,8 @@ If not specified, a default SQLite store will be used.""",
|
|||
|
||||
cfg_cls = instantiate_class_type(entry.config_class)
|
||||
prv_cls = instantiate_class_type(entry.provider_class)
|
||||
cfg_data = v.get("config") or {}
|
||||
cfg = TypeAdapter(cfg_cls).validate_python(cfg_data)
|
||||
cfg_data = v.get("config")
|
||||
cfg = TypeAdapter(cfg_cls).validate_python(cfg_data) if cfg_data is not None else None
|
||||
return prv_cls(provider=provider_type, config=cfg)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class InstrumentationProvider(BaseModel):
|
|||
"""
|
||||
|
||||
provider: str = Field(description="Provider identifier for discriminated unions")
|
||||
config: BaseModel
|
||||
config: BaseModel | None = Field(default=None, description="Optional configuration for the instrumentation provider. Most support configuration via environment variables.")
|
||||
|
||||
@abstractmethod
|
||||
def fastapi_middleware(self, app: FastAPI) -> None:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ class OTelInstrumentationProvider(InstrumentationProvider):
|
|||
|
||||
def model_post_init(self, __context):
|
||||
"""Initialize OpenTelemetry after Pydantic validation."""
|
||||
# Provide default config if missing and validate type
|
||||
if getattr(self, "config", None) is None:
|
||||
self.config = OTelConfig()
|
||||
assert isinstance(self.config, OTelConfig) # Type hint for IDE/linter
|
||||
|
||||
# Warn if OTLP endpoints not configured
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue