fix(major::pr): re-architect instrumentation library

This commit is contained in:
Emilio Garcia 2025-10-06 17:54:05 -04:00
parent 7e3cf1fb20
commit 8fe3a25158
21 changed files with 422 additions and 462 deletions

View 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
"""
...