mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-15 11:12:43 +00:00
fix(major::pr): re-architect instrumentation library
This commit is contained in:
parent
7e3cf1fb20
commit
8fe3a25158
21 changed files with 422 additions and 462 deletions
33
llama_stack/core/instrumentation.py
Normal file
33
llama_stack/core/instrumentation.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the terms described in the LICENSE file in
|
||||
# the root directory of this source tree.
|
||||
|
||||
"""Protocol for instrumentation providers."""
|
||||
|
||||
from abc import abstractmethod
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class InstrumentationProvider(BaseModel):
|
||||
"""
|
||||
Base class for instrumentation providers.
|
||||
|
||||
Instrumentation providers add observability (tracing, metrics, logs) to the
|
||||
application but don't expose API endpoints.
|
||||
"""
|
||||
|
||||
provider: str = Field(description="Provider identifier for discriminated unions")
|
||||
config: BaseModel
|
||||
|
||||
@abstractmethod
|
||||
def fastapi_middleware(self, app: FastAPI) -> None:
|
||||
"""
|
||||
Inject middleware into the FastAPI application.
|
||||
|
||||
:param app: The FastAPI application to instrument
|
||||
"""
|
||||
...
|
||||
Loading…
Add table
Add a link
Reference in a new issue