logfire-api 4.32.0__tar.gz → 4.33.0__tar.gz
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.
- {logfire_api-4.32.0 → logfire_api-4.33.0}/PKG-INFO +1 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/__init__.py +1 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/auto_trace/__init__.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/auto_trace/import_hook.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/auto_trace/rewrite_ast.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/baggage.pyi +2 -2
- logfire_api-4.33.0/logfire_api/_internal/cli/ai_tools.pyi +32 -0
- logfire_api-4.33.0/logfire_api/_internal/cli/gateway.pyi +48 -0
- logfire_api-4.33.0/logfire_api/_internal/cli/gateway_auth.pyi +61 -0
- logfire_api-4.33.0/logfire_api/_internal/cli/prompt.pyi +14 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/client.pyi +7 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/config.pyi +15 -6
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/config_params.pyi +3 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/constants.pyi +3 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/otlp.pyi +7 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/instrument.pyi +5 -5
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/aiohttp_client.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/asgi.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/aws_lambda.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/django.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/executors.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/fastapi.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/httpx.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/pymongo.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/requests.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/surrealdb.pyi +1 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/json_formatter.pyi +1 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/main.pyi +13 -4
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/scrubbing.pyi +3 -3
- logfire_api-4.33.0/logfire_api/_internal/server_response.pyi +11 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/tracer.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/ulid.pyi +1 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/utils.pyi +2 -2
- logfire_api-4.33.0/logfire_api/exceptions.pyi +4 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/api_client.pyi +24 -17
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/query_client.pyi +1 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/httpx.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/loguru.pyi +1 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/propagate.pyi +2 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/sampling/_tail_sampling.pyi +2 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/types.pyi +22 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/remote.pyi +4 -1
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/variable.pyi +3 -3
- {logfire_api-4.32.0 → logfire_api-4.33.0}/pyproject.toml +1 -1
- logfire_api-4.32.0/logfire_api/_internal/cli/prompt.pyi +0 -18
- logfire_api-4.32.0/logfire_api/exceptions.pyi +0 -2
- {logfire_api-4.32.0 → logfire_api-4.33.0}/.gitignore +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/README.md +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/ast_utils.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/async_.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/auth.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/auto_trace/types.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/cli/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/cli/auth.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/cli/run.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/cli.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/collect_system_info.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/db_statement_summary.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/console.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/dynamic_batch.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/logs.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/processor_wrapper.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/quiet_metrics.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/remove_pending.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/tail_sampling.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/exporters/wrapper.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/formatter.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/aiohttp_server.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/asyncpg.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/celery.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/dspy.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/flask.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/google_genai.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/litellm.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/mcp.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/mysql.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/openai_agents.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/print.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/psycopg.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/pydantic_ai.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/pytest.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/redis.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/sqlite3.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/starlette.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/system_metrics.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/wsgi.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/json_encoder.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/json_schema.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/json_types.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/logs.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/metrics.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/stack_info.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/cli.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/db_api.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/annotations.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/datasets/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/experimental/forwarding.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/flask.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/logging.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/psycopg.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/pydantic.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/redis.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/structlog.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/integrations/wsgi.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/py.typed +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/query_client.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/sampling/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/__init__.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/abstract.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/config.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/variables/local.pyi +0 -0
- {logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/version.pyi +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: logfire-api
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.33.0
|
|
4
4
|
Summary: Shim for the Logfire SDK which does nothing unless Logfire is installed
|
|
5
5
|
Author-email: Pydantic Team <engineering@pydantic.dev>, Samuel Colvin <samuel@pydantic.dev>, Hasan Ramezani <hasan@pydantic.dev>, Adrian Garcia Badaracco <adrian@pydantic.dev>, David Montague <david@pydantic.dev>, Marcelo Trylesinski <marcelo@pydantic.dev>, David Hewitt <david.hewitt@pydantic.dev>, Alex Hall <alex@pydantic.dev>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -2,8 +2,8 @@ from ..constants import ONE_SECOND_IN_NANOSECONDS as ONE_SECOND_IN_NANOSECONDS
|
|
|
2
2
|
from ..main import Logfire as Logfire
|
|
3
3
|
from .import_hook import LogfireFinder as LogfireFinder
|
|
4
4
|
from .types import AutoTraceModule as AutoTraceModule
|
|
5
|
-
from collections.abc import Sequence
|
|
6
|
-
from typing import
|
|
5
|
+
from collections.abc import Callable, Sequence
|
|
6
|
+
from typing import Literal
|
|
7
7
|
|
|
8
8
|
def install_auto_tracing(logfire: Logfire, modules: Sequence[str] | Callable[[AutoTraceModule], bool], *, min_duration: float, check_imported_modules: Literal['error', 'warn', 'ignore'] = 'error') -> None:
|
|
9
9
|
"""Install automatic tracing.
|
|
@@ -2,12 +2,12 @@ from ..main import Logfire as Logfire
|
|
|
2
2
|
from ..utils import log_internal_error as log_internal_error
|
|
3
3
|
from .rewrite_ast import compile_source as compile_source
|
|
4
4
|
from .types import AutoTraceModule as AutoTraceModule
|
|
5
|
-
from collections.abc import Sequence
|
|
5
|
+
from collections.abc import Callable, Sequence
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from importlib.abc import Loader, MetaPathFinder
|
|
8
8
|
from importlib.machinery import ModuleSpec
|
|
9
9
|
from types import ModuleType
|
|
10
|
-
from typing import Any
|
|
10
|
+
from typing import Any
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
13
|
class LogfireFinder(MetaPathFinder):
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import ast
|
|
2
2
|
from ..ast_utils import BaseTransformer as BaseTransformer, LogfireArgs as LogfireArgs
|
|
3
3
|
from ..main import Logfire as Logfire
|
|
4
|
+
from collections.abc import Callable
|
|
4
5
|
from contextlib import AbstractContextManager as AbstractContextManager
|
|
5
6
|
from dataclasses import dataclass
|
|
6
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, TypeVar
|
|
7
8
|
|
|
8
9
|
def compile_source(tree: ast.AST, filename: str, module_name: str, logfire_instance: Logfire, min_duration: int) -> Callable[[dict[str, Any]], None]:
|
|
9
10
|
"""Compile a modified AST of the module's source code in the module's namespace.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
|
-
from collections.abc import
|
|
2
|
+
from collections.abc import Generator
|
|
3
3
|
from contextlib import contextmanager
|
|
4
4
|
from opentelemetry import context
|
|
5
5
|
from opentelemetry.sdk.trace import Span, SpanProcessor
|
|
@@ -9,7 +9,7 @@ __all__ = ['get_baggage', 'set_baggage']
|
|
|
9
9
|
get_baggage: Incomplete
|
|
10
10
|
|
|
11
11
|
@contextmanager
|
|
12
|
-
def set_baggage(**values: str) ->
|
|
12
|
+
def set_baggage(**values: str) -> Generator[None]:
|
|
13
13
|
'''Context manager that attaches key/value pairs as OpenTelemetry baggage to the current context.
|
|
14
14
|
|
|
15
15
|
See the [Baggage documentation](https://logfire.pydantic.dev/docs/reference/advanced/baggage/) for more details.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from logfire._internal.utils import read_toml_file as read_toml_file
|
|
4
|
+
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
LOCAL_TOKEN_PLACEHOLDER: str
|
|
10
|
+
LOGFIRE_MCP_TOML: str
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class AiToolIntegration:
|
|
14
|
+
name: str
|
|
15
|
+
display_name: str
|
|
16
|
+
binary: str
|
|
17
|
+
env: dict[str, str]
|
|
18
|
+
model_env: dict[str, str] = field(default_factory=dict[str, str])
|
|
19
|
+
setup: Callable[[str, str | None, Path, str], dict[str, str]] | None = ...
|
|
20
|
+
configure_mcp: Callable[[str, Console, bool], None] | None = ...
|
|
21
|
+
description: str = ...
|
|
22
|
+
notice: str = ...
|
|
23
|
+
def binary_path(self) -> str | None: ...
|
|
24
|
+
def build_gateway_env(self, *, proxy_base: str, model: str | None, workdir: Path, local_token: str) -> dict[str, str]: ...
|
|
25
|
+
def configure_mcp_server(self, *, mcp_url: str, console: Console, update: bool) -> None: ...
|
|
26
|
+
|
|
27
|
+
def gateway_template_values(proxy_base: str, local_token: str) -> dict[str, str]: ...
|
|
28
|
+
def resolve_ai_tool(name: str) -> AiToolIntegration: ...
|
|
29
|
+
def ai_tool_names() -> tuple[str, ...]: ...
|
|
30
|
+
def opencode_mcp_json(url: str) -> dict[str, Any]: ...
|
|
31
|
+
|
|
32
|
+
AI_TOOL_INTEGRATIONS: dict[str, AiToolIntegration]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import httpx
|
|
3
|
+
from .ai_tools import AiToolIntegration as AiToolIntegration, LOCAL_TOKEN_PLACEHOLDER as LOCAL_TOKEN_PLACEHOLDER, ai_tool_names as ai_tool_names, gateway_template_values as gateway_template_values, resolve_ai_tool as resolve_ai_tool
|
|
4
|
+
from .gateway_auth import CimdOAuthClient as CimdOAuthClient, GATEWAY_CIMD_PATH as GATEWAY_CIMD_PATH, GatewayAuth as GatewayAuth, GatewayError as GatewayError, OAuthSession as OAuthSession, discover_oauth_metadata as discover_oauth_metadata
|
|
5
|
+
from _typeshed import Incomplete
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
DEFAULT_PORT: int
|
|
11
|
+
DEFAULT_SCOPE: str
|
|
12
|
+
OAUTH_CALLBACK_PATH: str
|
|
13
|
+
console: Incomplete
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class GatewayRegion:
|
|
17
|
+
backend: str
|
|
18
|
+
gateway: str
|
|
19
|
+
client_id: str
|
|
20
|
+
|
|
21
|
+
GATEWAY_REGIONS: dict[str, GatewayRegion]
|
|
22
|
+
|
|
23
|
+
@dataclass(frozen=True)
|
|
24
|
+
class GatewayCommandContext:
|
|
25
|
+
raw_args: list[str]
|
|
26
|
+
region: str | None
|
|
27
|
+
logfire_url: str | None
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class GatewayCommand:
|
|
31
|
+
name: Literal['usage', 'launch', 'serve']
|
|
32
|
+
args: tuple[str, ...]
|
|
33
|
+
|
|
34
|
+
def filter_headers(headers: dict[str, str], *, direction: str) -> list[tuple[str, str]]: ...
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class ProxyState:
|
|
38
|
+
auth: GatewayAuth
|
|
39
|
+
client: httpx.AsyncClient
|
|
40
|
+
gateway: str
|
|
41
|
+
region: str
|
|
42
|
+
local_token: str
|
|
43
|
+
|
|
44
|
+
def build_app(state: ProxyState) -> Any: ...
|
|
45
|
+
def parse_gateway_command(context: GatewayCommandContext) -> GatewayCommand: ...
|
|
46
|
+
def execute_gateway_command(command: GatewayCommand, context: GatewayCommandContext) -> int: ...
|
|
47
|
+
def parse_gateway(args: argparse.Namespace) -> None:
|
|
48
|
+
"""Run a local OAuth proxy for the Logfire AI Gateway."""
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
REFRESH_MARGIN_SECONDS: float
|
|
7
|
+
console: Incomplete
|
|
8
|
+
|
|
9
|
+
class GatewayError(Exception):
|
|
10
|
+
"""Expected gateway failure rendered to the user without a traceback."""
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class OAuthMetadata:
|
|
14
|
+
authorization_endpoint: str
|
|
15
|
+
token_endpoint: str
|
|
16
|
+
device_authorization_endpoint: str
|
|
17
|
+
|
|
18
|
+
async def discover_oauth_metadata(http: Any, backend: str) -> OAuthMetadata:
|
|
19
|
+
"""Fetch the backend's OAuth authorization server metadata."""
|
|
20
|
+
|
|
21
|
+
GATEWAY_CIMD_PATH: str
|
|
22
|
+
|
|
23
|
+
class CimdOAuthClient:
|
|
24
|
+
"""Public OAuth client identified by a CIMD URL."""
|
|
25
|
+
client_id: Incomplete
|
|
26
|
+
def __init__(self, http: Any, metadata: OAuthMetadata, *, client_id: str) -> None: ...
|
|
27
|
+
async def start_device_authorization(self, data: dict[str, str]) -> Any: ...
|
|
28
|
+
async def post_token(self, data: dict[str, str]) -> Any: ...
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class AuthBootstrap:
|
|
32
|
+
redirect_uri: str
|
|
33
|
+
expected_state: str = ...
|
|
34
|
+
code_verifier: str = ...
|
|
35
|
+
received_code: str | None = ...
|
|
36
|
+
error: str | None = ...
|
|
37
|
+
event: asyncio.Event = field(default_factory=asyncio.Event)
|
|
38
|
+
|
|
39
|
+
@dataclass(frozen=True)
|
|
40
|
+
class OAuthCallbackResult:
|
|
41
|
+
title: str
|
|
42
|
+
body: str
|
|
43
|
+
status_code: int = ...
|
|
44
|
+
|
|
45
|
+
class OAuthSession:
|
|
46
|
+
"""In-memory OAuth token state for the local gateway proxy."""
|
|
47
|
+
def __init__(self, client: CimdOAuthClient, metadata: OAuthMetadata, *, resource: str, scope: str) -> None: ...
|
|
48
|
+
async def auth_code_flow(self, bootstrap: AuthBootstrap) -> None: ...
|
|
49
|
+
async def device_flow(self) -> None: ...
|
|
50
|
+
async def refresh(self) -> None: ...
|
|
51
|
+
async def current_access_token(self) -> str: ...
|
|
52
|
+
async def force_refresh(self) -> str: ...
|
|
53
|
+
|
|
54
|
+
class GatewayAuth:
|
|
55
|
+
"""OAuth control-plane for an authorized local gateway proxy session."""
|
|
56
|
+
def __init__(self, session: OAuthSession, *, redirect_uri: str, flow: str) -> None: ...
|
|
57
|
+
async def authorize(self) -> None: ...
|
|
58
|
+
async def current_access_token(self) -> str: ...
|
|
59
|
+
async def recover_after_rejection(self, *, use_reauth: bool) -> bool: ...
|
|
60
|
+
async def reauthorize(self) -> None: ...
|
|
61
|
+
def complete_browser_callback(self, *, error: str | None, error_description: str | None, code: str | None, state: str | None) -> OAuthCallbackResult: ...
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from logfire._internal.cli.ai_tools import resolve_ai_tool as resolve_ai_tool
|
|
4
|
+
from logfire._internal.cli.auth import parse_auth as parse_auth
|
|
5
|
+
from logfire._internal.client import LogfireClient as LogfireClient
|
|
6
|
+
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
7
|
+
|
|
8
|
+
PROMPT_AI_TOOLS: Incomplete
|
|
9
|
+
|
|
10
|
+
def parse_prompt(args: argparse.Namespace) -> None:
|
|
11
|
+
"""Creates a prompt to be used with your favorite LLM.
|
|
12
|
+
|
|
13
|
+
The prompt assumes you are using Logfire MCP.
|
|
14
|
+
"""
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .auth import UserToken as UserToken, UserTokenCollection as UserTokenCollection
|
|
2
|
+
from .server_response import ServerResponseCallback as ServerResponseCallback, install_logfire_response_hook as install_logfire_response_hook
|
|
2
3
|
from .utils import UnexpectedResponse as UnexpectedResponse
|
|
3
4
|
from _typeshed import Incomplete
|
|
4
5
|
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
@@ -19,11 +20,13 @@ class LogfireClient:
|
|
|
19
20
|
|
|
20
21
|
Args:
|
|
21
22
|
user_token: The user token to use when authenticating against the API.
|
|
23
|
+
server_response_hook: Optional override for the API response hook (see
|
|
24
|
+
`AdvancedOptions.server_response_hook`).
|
|
22
25
|
"""
|
|
23
26
|
base_url: Incomplete
|
|
24
|
-
def __init__(self, user_token: UserToken) -> None: ...
|
|
27
|
+
def __init__(self, user_token: UserToken, server_response_hook: ServerResponseCallback | None = None) -> None: ...
|
|
25
28
|
@classmethod
|
|
26
|
-
def from_url(cls, base_url: str | None) -> Self:
|
|
29
|
+
def from_url(cls, base_url: str | None, server_response_hook: ServerResponseCallback | None = None) -> Self:
|
|
27
30
|
"""Create a client from the provided base URL.
|
|
28
31
|
|
|
29
32
|
Args:
|
|
@@ -31,6 +34,8 @@ class LogfireClient:
|
|
|
31
34
|
the user into selecting a token from the token collection (or, if only one available,
|
|
32
35
|
use it directly). The token collection will be created from the `~/.logfire/default.toml`
|
|
33
36
|
file (or an empty one if no such file exists).
|
|
37
|
+
server_response_hook: Optional override for the API response hook (see
|
|
38
|
+
`AdvancedOptions.server_response_hook`).
|
|
34
39
|
"""
|
|
35
40
|
def get_user_organizations(self) -> list[dict[str, Any]]:
|
|
36
41
|
"""Get the organizations of the logged-in user."""
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import atexit
|
|
2
1
|
import dataclasses
|
|
3
2
|
import requests
|
|
4
3
|
from ..propagate import NoExtractTraceContextPropagator as NoExtractTraceContextPropagator, WarnOnExtractTraceContextPropagator as WarnOnExtractTraceContextPropagator
|
|
5
4
|
from ..types import ExceptionCallback as ExceptionCallback
|
|
6
5
|
from .client import InvalidProjectName as InvalidProjectName, LogfireClient as LogfireClient, ProjectAlreadyExists as ProjectAlreadyExists
|
|
7
6
|
from .config_params import ParamManager as ParamManager, PydanticPluginRecordValues as PydanticPluginRecordValues, normalize_token as normalize_token
|
|
8
|
-
from .constants import LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL
|
|
7
|
+
from .constants import ATTRIBUTES_CONFIG as ATTRIBUTES_CONFIG, ATTRIBUTES_PACKAGE_VERSIONS as ATTRIBUTES_PACKAGE_VERSIONS, LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, RESOURCE_ATTRIBUTES_CODE_ROOT_PATH as RESOURCE_ATTRIBUTES_CODE_ROOT_PATH, RESOURCE_ATTRIBUTES_CODE_WORK_DIR as RESOURCE_ATTRIBUTES_CODE_WORK_DIR, RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME as RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION, RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL as RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL, RESOURCE_ATTRIBUTES_VERSION as RESOURCE_ATTRIBUTES_VERSION
|
|
9
8
|
from .exporters.console import ConsoleColorsValues as ConsoleColorsValues, ConsoleLogExporter as ConsoleLogExporter, IndentedConsoleSpanExporter as IndentedConsoleSpanExporter, ShowParentsConsoleSpanExporter as ShowParentsConsoleSpanExporter, SimpleConsoleSpanExporter as SimpleConsoleSpanExporter
|
|
10
9
|
from .exporters.dynamic_batch import DynamicBatchSpanProcessor as DynamicBatchSpanProcessor
|
|
11
10
|
from .exporters.logs import CheckSuppressInstrumentationLogProcessorWrapper as CheckSuppressInstrumentationLogProcessorWrapper, MainLogProcessorWrapper as MainLogProcessorWrapper
|
|
12
|
-
from .exporters.otlp import BodySizeCheckingOTLPSpanExporter as BodySizeCheckingOTLPSpanExporter, OTLPExporterHttpSession as OTLPExporterHttpSession, QuietLogExporter as QuietLogExporter, QuietSpanExporter as QuietSpanExporter, RetryFewerSpansSpanExporter as RetryFewerSpansSpanExporter
|
|
11
|
+
from .exporters.otlp import BodySizeCheckingOTLPSpanExporter as BodySizeCheckingOTLPSpanExporter, OTLPExporterHttpSession as OTLPExporterHttpSession, QuietLogExporter as QuietLogExporter, QuietSpanExporter as QuietSpanExporter, RetryFewerSpansSpanExporter as RetryFewerSpansSpanExporter, cleanup_disk_retryers as cleanup_disk_retryers
|
|
13
12
|
from .exporters.processor_wrapper import CheckSuppressInstrumentationProcessorWrapper as CheckSuppressInstrumentationProcessorWrapper, MainSpanProcessorWrapper as MainSpanProcessorWrapper
|
|
14
13
|
from .exporters.quiet_metrics import QuietMetricExporter as QuietMetricExporter
|
|
15
14
|
from .exporters.remove_pending import RemovePendingSpansExporter as RemovePendingSpansExporter
|
|
@@ -19,15 +18,17 @@ from .logs import ProxyLoggerProvider as ProxyLoggerProvider
|
|
|
19
18
|
from .main import Logfire as Logfire
|
|
20
19
|
from .metrics import ProxyMeterProvider as ProxyMeterProvider
|
|
21
20
|
from .scrubbing import BaseScrubber as BaseScrubber, NOOP_SCRUBBER as NOOP_SCRUBBER, Scrubber as Scrubber, ScrubbingOptions as ScrubbingOptions
|
|
21
|
+
from .server_response import ServerResponseCallback as ServerResponseCallback, install_logfire_response_hook as install_logfire_response_hook
|
|
22
22
|
from .stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
23
23
|
from .tracer import OPEN_SPANS as OPEN_SPANS, PendingSpanProcessor as PendingSpanProcessor, ProxyTracerProvider as ProxyTracerProvider
|
|
24
24
|
from .utils import SeededRandomIdGenerator as SeededRandomIdGenerator, ensure_data_dir_exists as ensure_data_dir_exists, handle_internal_errors as handle_internal_errors, platform_is_emscripten as platform_is_emscripten, suppress_instrumentation as suppress_instrumentation
|
|
25
25
|
from _typeshed import Incomplete
|
|
26
|
-
from collections.abc import Sequence
|
|
26
|
+
from collections.abc import Callable, Sequence
|
|
27
27
|
from dataclasses import dataclass, field
|
|
28
28
|
from datetime import timedelta
|
|
29
29
|
from logfire._internal.auth import PYDANTIC_LOGFIRE_TOKEN_PATTERN as PYDANTIC_LOGFIRE_TOKEN_PATTERN, REGIONS as REGIONS
|
|
30
30
|
from logfire._internal.baggage import DirectBaggageAttributesSpanProcessor as DirectBaggageAttributesSpanProcessor
|
|
31
|
+
from logfire._internal.collect_system_info import collect_package_info as collect_package_info
|
|
31
32
|
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
32
33
|
from logfire.sampling import SamplingOptions as SamplingOptions
|
|
33
34
|
from logfire.sampling._tail_sampling import TailSamplingProcessor as TailSamplingProcessor
|
|
@@ -40,7 +41,7 @@ from opentelemetry.sdk.metrics.view import View
|
|
|
40
41
|
from opentelemetry.sdk.trace import SpanProcessor
|
|
41
42
|
from opentelemetry.sdk.trace.id_generator import IdGenerator
|
|
42
43
|
from pathlib import Path
|
|
43
|
-
from typing import Any,
|
|
44
|
+
from typing import Any, ClassVar, Literal, TextIO, TypedDict
|
|
44
45
|
from typing_extensions import Self, Unpack
|
|
45
46
|
|
|
46
47
|
CREDENTIALS_FILENAME: str
|
|
@@ -68,6 +69,8 @@ class AdvancedOptions:
|
|
|
68
69
|
ns_timestamp_generator: Callable[[], int] = ...
|
|
69
70
|
log_record_processors: Sequence[LogRecordProcessor] = ...
|
|
70
71
|
exception_callback: ExceptionCallback | None = ...
|
|
72
|
+
emit_configuration_span: bool | None = ...
|
|
73
|
+
server_response_hook: ServerResponseCallback | None = ...
|
|
71
74
|
def generate_base_url(self, token: str) -> str: ...
|
|
72
75
|
|
|
73
76
|
@dataclass
|
|
@@ -289,7 +292,13 @@ class LogfireConfig(_LogfireConfigData):
|
|
|
289
292
|
def warn_if_not_initialized(self, message: str): ...
|
|
290
293
|
def suppress_scopes(self, *scopes: str) -> None: ...
|
|
291
294
|
|
|
292
|
-
@
|
|
295
|
+
@handle_internal_errors
|
|
296
|
+
def emit_configuration_span(config: LogfireConfig, logfire_instance: Logfire, *, local: bool) -> None:
|
|
297
|
+
"""Emit a span describing the active Logfire configuration and installed packages.
|
|
298
|
+
|
|
299
|
+
Only runs when `advanced.emit_configuration_span` is `True`. Sends a curated set of
|
|
300
|
+
non-sensitive configuration fields.
|
|
301
|
+
"""
|
|
293
302
|
def exit_open_spans() -> None: ...
|
|
294
303
|
|
|
295
304
|
original_os_exit: Incomplete
|
|
@@ -3,12 +3,12 @@ from .constants import LevelName as LevelName
|
|
|
3
3
|
from .exporters.console import ConsoleColorsValues as ConsoleColorsValues
|
|
4
4
|
from .utils import read_toml_file as read_toml_file
|
|
5
5
|
from _typeshed import Incomplete
|
|
6
|
-
from collections.abc import Sequence
|
|
6
|
+
from collections.abc import Callable, Sequence
|
|
7
7
|
from dataclasses import dataclass
|
|
8
8
|
from functools import cached_property
|
|
9
9
|
from logfire.exceptions import LogfireConfigError as LogfireConfigError
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import Any,
|
|
11
|
+
from typing import Any, TypeVar
|
|
12
12
|
|
|
13
13
|
T = TypeVar('T')
|
|
14
14
|
slots_true: Incomplete
|
|
@@ -54,6 +54,7 @@ INSPECT_ARGUMENTS: Incomplete
|
|
|
54
54
|
IGNORE_NO_CONFIG: Incomplete
|
|
55
55
|
BASE_URL: Incomplete
|
|
56
56
|
DISTRIBUTED_TRACING: Incomplete
|
|
57
|
+
EMIT_CONFIGURATION_SPAN: Incomplete
|
|
57
58
|
HTTPX_CAPTURE_ALL: Incomplete
|
|
58
59
|
AIOHTTP_CLIENT_CAPTURE_ALL: Incomplete
|
|
59
60
|
CONFIG_PARAMS: Incomplete
|
|
@@ -22,7 +22,9 @@ ATTRIBUTES_LOGGING_ARGS_KEY: Incomplete
|
|
|
22
22
|
ATTRIBUTES_LOGGING_NAME: Incomplete
|
|
23
23
|
ATTRIBUTES_VALIDATION_ERROR_KEY: str
|
|
24
24
|
ATTRIBUTES_SCRUBBED_KEY: Incomplete
|
|
25
|
-
|
|
25
|
+
ATTRIBUTES_CONFIG: str
|
|
26
|
+
ATTRIBUTES_PACKAGE_VERSIONS: str
|
|
27
|
+
RESOURCE_ATTRIBUTES_VERSION: str
|
|
26
28
|
RESOURCE_ATTRIBUTES_DEPLOYMENT_ENVIRONMENT_NAME: str
|
|
27
29
|
RESOURCE_ATTRIBUTES_VCS_REPOSITORY_REF_REVISION: str
|
|
28
30
|
RESOURCE_ATTRIBUTES_VCS_REPOSITORY_URL: str
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import atexit
|
|
1
2
|
import requests
|
|
2
3
|
from ..utils import logger as logger, platform_is_emscripten as platform_is_emscripten
|
|
3
4
|
from .wrapper import WrapperLogExporter as WrapperLogExporter, WrapperSpanExporter as WrapperSpanExporter
|
|
@@ -14,6 +15,9 @@ from requests import Session
|
|
|
14
15
|
from threading import Thread
|
|
15
16
|
from typing import Any
|
|
16
17
|
|
|
18
|
+
@atexit.register
|
|
19
|
+
def cleanup_disk_retryers() -> None: ...
|
|
20
|
+
|
|
17
21
|
class BodySizeCheckingOTLPSpanExporter(OTLPSpanExporter):
|
|
18
22
|
max_body_size: Incomplete
|
|
19
23
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
|
@@ -24,6 +28,7 @@ class OTLPExporterHttpSession(Session):
|
|
|
24
28
|
def post(self, url: str, data: bytes, **kwargs: Any): ...
|
|
25
29
|
@cached_property
|
|
26
30
|
def retryer(self) -> DiskRetryer: ...
|
|
31
|
+
def close(self) -> None: ...
|
|
27
32
|
|
|
28
33
|
def raise_for_retryable_status(response: requests.Response): ...
|
|
29
34
|
|
|
@@ -36,10 +41,12 @@ class DiskRetryer:
|
|
|
36
41
|
thread: Thread | None
|
|
37
42
|
tasks: deque[tuple[Path, dict[str, Any]]]
|
|
38
43
|
total_size: int
|
|
44
|
+
closed: bool
|
|
39
45
|
session: Incomplete
|
|
40
46
|
dir: Incomplete
|
|
41
47
|
last_log_time: Incomplete
|
|
42
48
|
def __init__(self, headers: Mapping[str, str | bytes]) -> None: ...
|
|
49
|
+
def close(self) -> None: ...
|
|
43
50
|
def add_task(self, data: bytes, kwargs: dict[str, Any]): ...
|
|
44
51
|
|
|
45
52
|
class RetryFewerSpansSpanExporter(WrapperSpanExporter):
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
from .constants import ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY
|
|
1
|
+
from .constants import ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, LevelName as LevelName, log_level_attributes as log_level_attributes
|
|
2
2
|
from .main import Logfire as Logfire
|
|
3
3
|
from .stack_info import get_filepath_attribute as get_filepath_attribute
|
|
4
4
|
from .utils import safe_repr as safe_repr, uniquify_sequence as uniquify_sequence
|
|
5
5
|
from _typeshed import Incomplete
|
|
6
|
-
from collections.abc import Iterable, Sequence
|
|
6
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
7
7
|
from contextlib import AbstractContextManager as AbstractContextManager
|
|
8
8
|
from opentelemetry.util import types as otel_types
|
|
9
|
-
from typing import Any,
|
|
9
|
+
from typing import Any, TypeVar
|
|
10
10
|
from typing_extensions import LiteralString, ParamSpec
|
|
11
11
|
|
|
12
12
|
P = ParamSpec('P')
|
|
@@ -15,6 +15,6 @@ CONTEXTMANAGER_HELPER_CODE: Incomplete
|
|
|
15
15
|
ASYNCCONTEXTMANAGER_HELPER_CODE: Incomplete
|
|
16
16
|
GENERATOR_WARNING_MESSAGE: str
|
|
17
17
|
|
|
18
|
-
def instrument(logfire: Logfire, tags: Sequence[str], msg_template: LiteralString | None, span_name: str | None, extract_args: bool | Iterable[str], record_return: bool, allow_generator: bool, new_trace: bool) -> Callable[[Callable[P, R]], Callable[P, R]]: ...
|
|
19
|
-
def get_open_span(logfire: Logfire, attributes: dict[str, otel_types.AttributeValue], span_name: str | None, extract_args: bool | Iterable[str], func: Callable[P, R], new_trace: bool) -> Callable[P, AbstractContextManager[Any]]: ...
|
|
18
|
+
def instrument(logfire: Logfire, tags: Sequence[str], msg_template: LiteralString | None, span_name: str | None, extract_args: bool | Iterable[str], record_return: bool, allow_generator: bool, new_trace: bool, level: LevelName | int | None = None) -> Callable[[Callable[P, R]], Callable[P, R]]: ...
|
|
19
|
+
def get_open_span(logfire: Logfire, attributes: dict[str, otel_types.AttributeValue], span_name: str | None, extract_args: bool | Iterable[str], func: Callable[P, R], new_trace: bool, level: LevelName | int | None = None) -> Callable[P, AbstractContextManager[Any]]: ...
|
|
20
20
|
def get_attributes(func: Any, msg_template: str | None, tags: Sequence[str] | None) -> dict[str, otel_types.AttributeValue]: ...
|
{logfire_api-4.32.0 → logfire_api-4.33.0}/logfire_api/_internal/integrations/aiohttp_client.pyi
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
2
2
|
from aiohttp.client_reqrep import ClientResponse
|
|
3
3
|
from aiohttp.tracing import TraceRequestEndParams, TraceRequestExceptionParams, TraceRequestStartParams
|
|
4
|
+
from collections.abc import Callable
|
|
4
5
|
from email.headerregistry import ContentTypeHeader
|
|
5
6
|
from logfire import Logfire as Logfire, LogfireSpan as LogfireSpan
|
|
6
7
|
from logfire._internal.config import GLOBAL_CONFIG as GLOBAL_CONFIG
|
|
@@ -9,7 +10,7 @@ from logfire._internal.stack_info import warn_at_user_stacklevel as warn_at_user
|
|
|
9
10
|
from logfire._internal.utils import handle_internal_errors as handle_internal_errors
|
|
10
11
|
from logfire.integrations.aiohttp_client import AioHttpRequestHeaders as AioHttpRequestHeaders, AioHttpResponseHeaders as AioHttpResponseHeaders, RequestHook as RequestHook, ResponseHook as ResponseHook
|
|
11
12
|
from opentelemetry.trace import Span
|
|
12
|
-
from typing import Any,
|
|
13
|
+
from typing import Any, Literal, ParamSpec
|
|
13
14
|
from yarl import URL
|
|
14
15
|
|
|
15
16
|
P = ParamSpec('P')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from collections.abc import Awaitable
|
|
1
|
+
from collections.abc import Awaitable, Callable
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
from logfire import Logfire as Logfire
|
|
4
4
|
from logfire._internal.constants import log_level_attributes as log_level_attributes
|
|
@@ -6,7 +6,7 @@ from logfire._internal.utils import is_asgi_send_receive_span_name as is_asgi_se
|
|
|
6
6
|
from opentelemetry.context import Context
|
|
7
7
|
from opentelemetry.trace import Span, SpanKind, Tracer, TracerProvider
|
|
8
8
|
from opentelemetry.util import types as otel_types
|
|
9
|
-
from typing import Any,
|
|
9
|
+
from typing import Any, Protocol, TypedDict
|
|
10
10
|
from typing_extensions import Unpack
|
|
11
11
|
|
|
12
12
|
Scope = dict[str, Any]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from opentelemetry.context import Context as Context
|
|
2
3
|
from opentelemetry.metrics import MeterProvider
|
|
3
4
|
from opentelemetry.trace import TracerProvider
|
|
4
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
5
6
|
|
|
6
7
|
LambdaEvent = Any
|
|
7
8
|
LambdaHandler = Callable[[LambdaEvent, Any], Any]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from django.http import HttpRequest as HttpRequest, HttpResponse as HttpResponse
|
|
2
3
|
from logfire._internal.utils import maybe_capture_server_headers as maybe_capture_server_headers
|
|
3
4
|
from opentelemetry.trace import Span as Span
|
|
4
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
5
6
|
|
|
6
7
|
def instrument_django(*, capture_headers: bool, is_sql_commentor_enabled: bool | None, excluded_urls: str | None, request_hook: Callable[[Span, HttpRequest], None] | None, response_hook: Callable[[Span, HttpRequest, HttpResponse], None] | None, **kwargs: Any) -> None:
|
|
7
8
|
"""Instrument the `django` module so that spans are automatically created for each web request.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from ..stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
2
2
|
from _typeshed import Incomplete
|
|
3
|
+
from collections.abc import Callable
|
|
3
4
|
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
|
|
4
5
|
from logfire.propagate import ContextCarrier as ContextCarrier, attach_context as attach_context, get_context as get_context
|
|
5
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
6
7
|
|
|
7
8
|
submit_t_orig: Incomplete
|
|
8
9
|
submit_p_orig: Incomplete
|
|
@@ -4,14 +4,14 @@ from ..stack_info import StackInfo as StackInfo, get_code_object_info as get_cod
|
|
|
4
4
|
from ..utils import handle_internal_errors as handle_internal_errors, maybe_capture_server_headers as maybe_capture_server_headers
|
|
5
5
|
from .asgi import tweak_asgi_spans_tracer_provider as tweak_asgi_spans_tracer_provider
|
|
6
6
|
from _typeshed import Incomplete
|
|
7
|
-
from collections.abc import Awaitable, Iterable
|
|
7
|
+
from collections.abc import Awaitable, Callable, Iterable
|
|
8
8
|
from contextlib import AbstractContextManager, contextmanager
|
|
9
9
|
from fastapi import FastAPI
|
|
10
10
|
from functools import lru_cache
|
|
11
11
|
from opentelemetry.trace import Span
|
|
12
12
|
from starlette.requests import Request
|
|
13
13
|
from starlette.websockets import WebSocket
|
|
14
|
-
from typing import Any
|
|
14
|
+
from typing import Any
|
|
15
15
|
|
|
16
16
|
def find_mounted_apps(app: FastAPI) -> list[FastAPI]:
|
|
17
17
|
"""Fetch all sub-apps mounted to a FastAPI app, including nested sub-apps."""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import contextlib
|
|
2
2
|
import httpx
|
|
3
3
|
from _typeshed import Incomplete
|
|
4
|
-
from collections.abc import Awaitable as Awaitable, Generator, Mapping
|
|
4
|
+
from collections.abc import Awaitable as Awaitable, Callable, Generator, Mapping
|
|
5
5
|
from email.headerregistry import ContentTypeHeader
|
|
6
6
|
from functools import cached_property, lru_cache
|
|
7
7
|
from logfire import Logfire as Logfire, LogfireSpan as LogfireSpan
|
|
@@ -11,7 +11,7 @@ from logfire._internal.stack_info import warn_at_user_stacklevel as warn_at_user
|
|
|
11
11
|
from logfire._internal.utils import handle_internal_errors as handle_internal_errors
|
|
12
12
|
from logfire.integrations.httpx import AsyncRequestHook as AsyncRequestHook, AsyncResponseHook as AsyncResponseHook, RequestHook as RequestHook, RequestInfo as RequestInfo, ResponseHook as ResponseHook, ResponseInfo as ResponseInfo
|
|
13
13
|
from opentelemetry.trace import Span
|
|
14
|
-
from typing import Any,
|
|
14
|
+
from typing import Any, Literal, ParamSpec
|
|
15
15
|
|
|
16
16
|
P = ParamSpec('P')
|
|
17
17
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from opentelemetry.sdk.trace import Span as Span
|
|
2
3
|
from pymongo.monitoring import CommandFailedEvent as CommandFailedEvent, CommandStartedEvent as CommandStartedEvent, CommandSucceededEvent as CommandSucceededEvent
|
|
3
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
4
5
|
|
|
5
6
|
def instrument_pymongo(*, capture_statement: bool, request_hook: Callable[[Span, CommandStartedEvent], None] | None = None, response_hook: Callable[[Span, CommandSucceededEvent], None] | None = None, failed_hook: Callable[[Span, CommandFailedEvent], None] | None = None, **kwargs: Any) -> None:
|
|
6
7
|
"""Instrument the `pymongo` module so that spans are automatically created for each operation.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import requests
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from opentelemetry.sdk.trace import Span as Span
|
|
3
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
4
5
|
|
|
5
6
|
def instrument_requests(excluded_urls: str | None = None, request_hook: Callable[[Span, requests.PreparedRequest], None] | None = None, response_hook: Callable[[Span, requests.PreparedRequest, requests.Response], None] | None = None, **kwargs: Any) -> None:
|
|
6
7
|
"""Instrument the `requests` module so that spans are automatically created for each request.
|
|
@@ -8,4 +8,4 @@ from typing import Any
|
|
|
8
8
|
def get_all_surrealdb_classes() -> set[type]: ...
|
|
9
9
|
def instrument_surrealdb(obj: SyncTemplate | AsyncTemplate | type[SyncTemplate] | type[AsyncTemplate] | None, logfire_instance: Logfire): ...
|
|
10
10
|
@handle_internal_errors
|
|
11
|
-
def patch_method(obj: Any, method_name: str, logfire_instance: Logfire): ...
|
|
11
|
+
def patch_method(obj: Any, method_name: str, template_method: Any, logfire_instance: Logfire): ...
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .json_types import ArraySchema as ArraySchema, DataType as DataType, JSONSchema as JSONSchema
|
|
2
2
|
from .utils import safe_repr as safe_repr
|
|
3
3
|
from _typeshed import Incomplete
|
|
4
|
+
from collections.abc import Callable as Callable
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
7
|
class JsonArgsValueFormatter:
|
|
@@ -34,6 +34,7 @@ from .metrics import ProxyMeterProvider as ProxyMeterProvider
|
|
|
34
34
|
from .stack_info import get_user_stack_info as get_user_stack_info
|
|
35
35
|
from .tracer import ProxyTracerProvider as ProxyTracerProvider, _ProxyTracer, set_exception_status as set_exception_status
|
|
36
36
|
from .utils import SysExcInfo as SysExcInfo, get_version as get_version, handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, uniquify_sequence as uniquify_sequence
|
|
37
|
+
from anthropic.lib.bedrock import AnthropicBedrock as _AnthropicBedrock, AsyncAnthropicBedrock as _AsyncAnthropicBedrock
|
|
37
38
|
from collections.abc import Iterable, Mapping, Sequence
|
|
38
39
|
from contextlib import AbstractContextManager
|
|
39
40
|
from django.http import HttpRequest as HttpRequest, HttpResponse as HttpResponse
|
|
@@ -250,7 +251,7 @@ class Logfire:
|
|
|
250
251
|
Attributes starting with an underscore are not allowed.
|
|
251
252
|
"""
|
|
252
253
|
@overload
|
|
253
|
-
def instrument(self, msg_template: LiteralString | None = None, *, span_name: str | None = None, extract_args: bool | Iterable[str] = True, record_return: bool = False, allow_generator: bool = False, new_trace: bool = False) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
|
254
|
+
def instrument(self, msg_template: LiteralString | None = None, *, span_name: str | None = None, extract_args: bool | Iterable[str] = True, record_return: bool = False, allow_generator: bool = False, new_trace: bool = False, level: LevelName | int | None = None) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
|
254
255
|
"""Decorator for instrumenting a function as a span.
|
|
255
256
|
|
|
256
257
|
```py
|
|
@@ -275,6 +276,8 @@ class Logfire:
|
|
|
275
276
|
Read https://logfire.pydantic.dev/docs/guides/advanced/generators/#using-logfireinstrument first.
|
|
276
277
|
new_trace: Set to `True` to start a new trace with a span link to the current span
|
|
277
278
|
instead of creating a child of the current span.
|
|
279
|
+
level: The log level for the span. If provided, the span will be tagged with this level
|
|
280
|
+
and suppressed if the level is below the configured `min_level`.
|
|
278
281
|
"""
|
|
279
282
|
@overload
|
|
280
283
|
def instrument(self, func: Callable[P, R]) -> Callable[P, R]:
|
|
@@ -591,7 +594,7 @@ class Logfire:
|
|
|
591
594
|
For instrumentation of the standard OpenAI SDK package,
|
|
592
595
|
see [`instrument_openai()`][logfire.Logfire.instrument_openai].
|
|
593
596
|
"""
|
|
594
|
-
def instrument_anthropic(self, anthropic_client: anthropic.Anthropic | anthropic.AsyncAnthropic |
|
|
597
|
+
def instrument_anthropic(self, anthropic_client: anthropic.Anthropic | anthropic.AsyncAnthropic | _AnthropicBedrock | _AsyncAnthropicBedrock | type[anthropic.Anthropic] | type[anthropic.AsyncAnthropic] | type[_AnthropicBedrock] | type[_AsyncAnthropicBedrock] | None = None, *, suppress_other_instrumentation: bool = True, version: SemconvVersion | Sequence[SemconvVersion] = 1) -> AbstractContextManager[None]:
|
|
595
598
|
'''Instrument an Anthropic client so that spans are automatically created for each request.
|
|
596
599
|
|
|
597
600
|
The following methods are instrumented for both the sync and async clients:
|
|
@@ -697,8 +700,14 @@ class Logfire:
|
|
|
697
700
|
A context manager that will revert the instrumentation when exited.
|
|
698
701
|
Use of this context manager is optional.
|
|
699
702
|
"""
|
|
700
|
-
def instrument_asyncpg(self, **kwargs: Any) -> None:
|
|
701
|
-
"""Instrument the `asyncpg` module so that spans are automatically created for each query.
|
|
703
|
+
def instrument_asyncpg(self, capture_parameters: bool = False, **kwargs: Any) -> None:
|
|
704
|
+
"""Instrument the `asyncpg` module so that spans are automatically created for each query.
|
|
705
|
+
|
|
706
|
+
Args:
|
|
707
|
+
capture_parameters: Set to `True` to capture query parameters as span attributes.
|
|
708
|
+
Be cautious when enabling this, as it may lead to sensitive data being captured in traces.
|
|
709
|
+
kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` method.
|
|
710
|
+
"""
|
|
702
711
|
@overload
|
|
703
712
|
def instrument_httpx(self, client: httpx.Client, *, capture_all: bool = False, capture_headers: bool = False, capture_request_body: bool = False, capture_response_body: bool = False, request_hook: HttpxRequestHook | None = None, response_hook: HttpxResponseHook | None = None, **kwargs: Any) -> None: ...
|
|
704
713
|
@overload
|