mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-20 09:06:29 +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
41
llama_stack/providers/registry/instrumentation.py
Normal file
41
llama_stack/providers/registry/instrumentation.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# 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.
|
||||
|
||||
"""Registry for instrumentation providers (non-API providers).
|
||||
|
||||
This registry is string-based to avoid importing provider modules at import
|
||||
time (prevents circular imports). Classes are instantiated lazily by the
|
||||
StackRunConfig validator using `instantiate_class_type`.
|
||||
|
||||
Please implement your instrumentation provider as a subclass of `InstrumentationProvider` and register it in this registry.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
from llama_stack.core.instrumentation import InstrumentationProvider
|
||||
|
||||
class MyInstrumentationProvider(InstrumentationProvider):
|
||||
fastapi_middleware(self, app: FastAPI) -> None:
|
||||
pass
|
||||
```
|
||||
"""
|
||||
|
||||
from typing import NamedTuple
|
||||
|
||||
|
||||
class InstrumentationEntry(NamedTuple):
|
||||
provider_class: str # fully-qualified class path
|
||||
config_class: str # fully-qualified class path
|
||||
description: str
|
||||
|
||||
|
||||
instrumentation_registry: dict[str, InstrumentationEntry] = {
|
||||
"otel": InstrumentationEntry(
|
||||
provider_class="llama_stack.providers.inline.instrumentation.otel.otel.OTelInstrumentationProvider",
|
||||
config_class="llama_stack.providers.inline.instrumentation.otel.config.OTelConfig",
|
||||
description="OpenTelemetry instrumentation",
|
||||
),
|
||||
}
|
||||
|
|
@ -26,16 +26,4 @@ def available_providers() -> list[ProviderSpec]:
|
|||
config_class="llama_stack.providers.inline.telemetry.meta_reference.config.TelemetryConfig",
|
||||
description="Meta's reference implementation of telemetry and observability using OpenTelemetry.",
|
||||
),
|
||||
InlineProviderSpec(
|
||||
api=Api.telemetry,
|
||||
provider_type="inline::otel",
|
||||
pip_packages=[
|
||||
"opentelemetry-sdk",
|
||||
"opentelemetry-exporter-otlp-proto-http",
|
||||
"opentelemetry-instrumentation-fastapi",
|
||||
],
|
||||
module="llama_stack.providers.inline.telemetry.otel",
|
||||
config_class="llama_stack.providers.inline.telemetry.otel.config.OTelTelemetryConfig",
|
||||
description="Native OpenTelemetry provider with full access to OTel Tracer and Meter APIs for advanced instrumentation.",
|
||||
),
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue