logfire-api 5.2.0__tar.gz → 5.3.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-5.2.0 → logfire_api-5.3.0}/PKG-INFO +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/auth.pyi +5 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/config.pyi +2 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/config_params.pyi +1 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi +7 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/fastapi.pyi +26 -3
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/flask.pyi +2 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/openai_agents.pyi +2 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/starlette.pyi +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/json_encoder.pyi +4 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/main.pyi +4 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/tracer.pyi +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/logging.pyi +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/structlog.pyi +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/pyproject.toml +1 -1
- {logfire_api-5.2.0 → logfire_api-5.3.0}/.gitignore +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/README.md +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/__init__.py +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/ast_utils.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/async_.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/auth.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/auto_trace/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/auto_trace/import_hook.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/auto_trace/rewrite_ast.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/auto_trace/types.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/baggage.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/ai_tools.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/gateway.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/gateway_auth.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/prompt.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli/run.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/cli.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/collect_system_info.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/constants.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/db_statement_summary.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/console.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/dynamic_batch.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/logs.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/otlp.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/processor_wrapper.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/quiet_metrics.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/remove_pending.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/tail_sampling.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/wrapper.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/formatter.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/forwarding.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/http_transport.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/instrument.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/aiohttp_server.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/asgi.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/asyncpg.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/aws_lambda.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/celery.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/django.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/dspy.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/executors.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/google_genai.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/httpx.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/litellm.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/litestar.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/mcp.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/monty.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/mysql.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/print.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/psycopg.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/pydantic_ai.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/pymongo.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/pytest.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/redis.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/requests.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/snowflake.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/sqlite3.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/surrealdb.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/system_metrics.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/wsgi.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/interactive.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/json_formatter.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/json_schema.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/json_types.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/logs.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/metrics.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/scrubbing.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/server_response.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/stack_info.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/ulid.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/utils.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/cli.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/db_api.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/exceptions.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/experimental/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/experimental/annotations.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/experimental/api_client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/experimental/datasets/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/experimental/query_client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/flask.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/httpx.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/loguru.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/psycopg.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/pydantic.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/redis.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/integrations/wsgi.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/propagate.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/py.typed +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/query_client.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/sampling/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/sampling/_tail_sampling.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/types.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/__init__.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/_handlebars.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/abstract.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/composition.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/config.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/local.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/remote.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/template_validation.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/variables/variable.pyi +0 -0
- {logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/version.pyi +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: logfire-api
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.3.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
|
|
@@ -10,4 +10,8 @@ def parse_auth(args: argparse.Namespace) -> None:
|
|
|
10
10
|
This will authenticate your machine with Logfire and store the credentials.
|
|
11
11
|
"""
|
|
12
12
|
def parse_logout(args: argparse.Namespace) -> None:
|
|
13
|
-
"""Log out from Logfire.
|
|
13
|
+
"""Log out from Logfire.
|
|
14
|
+
|
|
15
|
+
Remove stored user tokens for --region, --base-url, or a non-empty LOGFIRE_BASE_URL.
|
|
16
|
+
With no target configured, remove all stored user tokens.
|
|
17
|
+
"""
|
|
@@ -45,6 +45,7 @@ from opentelemetry.sdk.metrics.export import MetricReader as MetricReader
|
|
|
45
45
|
from opentelemetry.sdk.metrics.view import View
|
|
46
46
|
from opentelemetry.sdk.resources import ResourceDetector
|
|
47
47
|
from opentelemetry.sdk.trace import SpanProcessor
|
|
48
|
+
from opentelemetry.sdk.trace.export import SpanExporter as SpanExporter
|
|
48
49
|
from opentelemetry.sdk.trace.id_generator import IdGenerator
|
|
49
50
|
from pathlib import Path
|
|
50
51
|
from typing import Any, ClassVar, Literal, TextIO
|
|
@@ -80,6 +81,7 @@ class AdvancedOptions:
|
|
|
80
81
|
server_response_hook: ServerResponseCallback | None = ...
|
|
81
82
|
resource_detectors: Sequence[ResourceDetector | str] | None = ...
|
|
82
83
|
compression: CompressionValues | None = ...
|
|
84
|
+
pending_spans: bool | None = ...
|
|
83
85
|
def generate_base_url(self, token: str, warn_unknown_region: bool = True) -> str:
|
|
84
86
|
"""Resolve the base API URL for `token`, honouring an explicitly configured `base_url`.
|
|
85
87
|
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi
RENAMED
|
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
|
|
|
2
2
|
from claude_agent_sdk import AssistantMessage
|
|
3
3
|
from claude_agent_sdk.types import HookContext, SyncHookJSONOutput
|
|
4
4
|
from contextlib import AbstractContextManager
|
|
5
|
-
from logfire._internal.integrations.llm_providers.semconv import CONVERSATION_ID as CONVERSATION_ID, ChatMessage as ChatMessage, ERROR_TYPE as ERROR_TYPE, INPUT_MESSAGES as INPUT_MESSAGES, MessagePart as MessagePart, OPERATION_NAME as OPERATION_NAME, OUTPUT_MESSAGES as OUTPUT_MESSAGES, OutputMessage as OutputMessage, PROVIDER_NAME as PROVIDER_NAME, REQUEST_MODEL as REQUEST_MODEL, RESPONSE_MODEL as RESPONSE_MODEL, ReasoningPart as ReasoningPart, SYSTEM as SYSTEM, SYSTEM_INSTRUCTIONS as SYSTEM_INSTRUCTIONS, TOOL_CALL_ARGUMENTS as TOOL_CALL_ARGUMENTS, TOOL_CALL_ID as TOOL_CALL_ID, TOOL_CALL_RESULT as TOOL_CALL_RESULT, TOOL_NAME as TOOL_NAME, TextPart as TextPart, ToolCallPart as ToolCallPart, ToolCallResponsePart as ToolCallResponsePart
|
|
5
|
+
from logfire._internal.integrations.llm_providers.semconv import CONVERSATION_ID as CONVERSATION_ID, ChatMessage as ChatMessage, ERROR_TYPE as ERROR_TYPE, INPUT_MESSAGES as INPUT_MESSAGES, MessagePart as MessagePart, OPERATION_NAME as OPERATION_NAME, OUTPUT_MESSAGES as OUTPUT_MESSAGES, OutputMessage as OutputMessage, PROVIDER_NAME as PROVIDER_NAME, REQUEST_MODEL as REQUEST_MODEL, RESPONSE_FINISH_REASONS as RESPONSE_FINISH_REASONS, RESPONSE_ID as RESPONSE_ID, RESPONSE_MODEL as RESPONSE_MODEL, ReasoningPart as ReasoningPart, SYSTEM as SYSTEM, SYSTEM_INSTRUCTIONS as SYSTEM_INSTRUCTIONS, TOOL_CALL_ARGUMENTS as TOOL_CALL_ARGUMENTS, TOOL_CALL_ID as TOOL_CALL_ID, TOOL_CALL_RESULT as TOOL_CALL_RESULT, TOOL_NAME as TOOL_NAME, TextPart as TextPart, ToolCallPart as ToolCallPart, ToolCallResponsePart as ToolCallResponsePart
|
|
6
6
|
from logfire._internal.main import Logfire as Logfire, LogfireSpan as LogfireSpan
|
|
7
7
|
from logfire._internal.stack_info import get_user_stack_info as get_user_stack_info
|
|
8
8
|
from logfire._internal.utils import handle_internal_errors as handle_internal_errors
|
|
@@ -63,5 +63,11 @@ class _ConversationState:
|
|
|
63
63
|
"""Handle UserMessage: open a new chat span for the next LLM call."""
|
|
64
64
|
def handle_assistant_message(self, message: AssistantMessage) -> None:
|
|
65
65
|
"""Handle AssistantMessage: add output and usage to the current chat span."""
|
|
66
|
+
def set_finish_reason(self, stop_reason: str | None) -> None:
|
|
67
|
+
"""Record the stop reason on the current chat span.
|
|
68
|
+
|
|
69
|
+
The CLI streams assistant messages with a null `stop_reason`;
|
|
70
|
+
the final one is only reported on the ResultMessage.
|
|
71
|
+
"""
|
|
66
72
|
def close(self) -> None:
|
|
67
73
|
"""Close chat span and end any orphaned tool spans."""
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dataclasses
|
|
1
2
|
from ..constants import ONE_SECOND_IN_NANOSECONDS as ONE_SECOND_IN_NANOSECONDS
|
|
2
3
|
from ..main import Logfire as Logfire, NoopSpan as NoopSpan, set_user_attributes_on_raw_span as set_user_attributes_on_raw_span
|
|
3
4
|
from ..stack_info import StackInfo as StackInfo, get_code_object_info as get_code_object_info
|
|
@@ -8,21 +9,43 @@ from collections.abc import Awaitable, Callable, Iterable
|
|
|
8
9
|
from contextlib import AbstractContextManager, contextmanager
|
|
9
10
|
from fastapi import FastAPI
|
|
10
11
|
from functools import lru_cache
|
|
12
|
+
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
|
|
11
13
|
from opentelemetry.trace import Span
|
|
12
14
|
from starlette.requests import Request
|
|
15
|
+
from starlette.types import Receive, Scope, Send
|
|
13
16
|
from starlette.websockets import WebSocket
|
|
14
17
|
from typing import Any
|
|
18
|
+
from weakref import WeakKeyDictionary
|
|
15
19
|
|
|
16
20
|
def find_mounted_apps(app: FastAPI) -> list[FastAPI]:
|
|
17
21
|
"""Fetch all sub-apps mounted to a FastAPI app, including nested sub-apps."""
|
|
18
|
-
def instrument_fastapi(logfire_instance: Logfire, app: FastAPI, *, capture_headers: bool = False, request_attributes_mapper: Callable[[Request | WebSocket, dict[str, Any]], dict[str, Any] | None] | None = None, excluded_urls: str | Iterable[str] | None = None, record_send_receive: bool = False, extra_spans: bool = False, **opentelemetry_kwargs: Any) -> AbstractContextManager[None]:
|
|
22
|
+
def instrument_fastapi(logfire_instance: Logfire, app: FastAPI | None = None, *, capture_headers: bool = False, request_attributes_mapper: Callable[[Request | WebSocket, dict[str, Any]], dict[str, Any] | None] | None = None, excluded_urls: str | Iterable[str] | None = None, record_send_receive: bool = False, extra_spans: bool = False, **opentelemetry_kwargs: Any) -> AbstractContextManager[None]:
|
|
19
23
|
"""Instrument a FastAPI app so that spans and logs are automatically created for each request.
|
|
20
24
|
|
|
21
25
|
See `Logfire.instrument_fastapi` for more details.
|
|
22
26
|
"""
|
|
27
|
+
|
|
28
|
+
class OncePerRequest:
|
|
29
|
+
"""Run only the outermost FastAPI OpenTelemetry middleware for each ASGI request.
|
|
30
|
+
|
|
31
|
+
This way mounted apps don't start duplicate spans for the same request,
|
|
32
|
+
and they don't trace requests that were excluded by their outer app.
|
|
33
|
+
"""
|
|
34
|
+
app: Incomplete
|
|
35
|
+
def __init__(self, app: OpenTelemetryMiddleware) -> None: ...
|
|
36
|
+
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: ...
|
|
37
|
+
|
|
38
|
+
@dataclasses.dataclass
|
|
39
|
+
class _FastAPIRegistry:
|
|
40
|
+
"""Track Logfire instrumentation settings for FastAPI apps."""
|
|
41
|
+
global_instrumentation: FastAPIInstrumentation | None = ...
|
|
42
|
+
per_app: WeakKeyDictionary[FastAPI, FastAPIInstrumentation] = dataclasses.field(default_factory=Incomplete)
|
|
43
|
+
def get_instrumentation(self, app: FastAPI) -> FastAPIInstrumentation | None:
|
|
44
|
+
"""Get the instrumentation for a specific app, or the global instrumentation if none is set."""
|
|
45
|
+
|
|
23
46
|
@lru_cache
|
|
24
|
-
def patch_fastapi():
|
|
25
|
-
"""Globally monkeypatch fastapi functions and return
|
|
47
|
+
def patch_fastapi() -> _FastAPIRegistry:
|
|
48
|
+
"""Globally monkeypatch fastapi functions and return their instrumentation registry."""
|
|
26
49
|
|
|
27
50
|
class FastAPIInstrumentation:
|
|
28
51
|
logfire_instance: Incomplete
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from flask.app import Flask
|
|
2
|
+
from logfire import Logfire as Logfire
|
|
2
3
|
from logfire._internal.utils import maybe_capture_server_headers as maybe_capture_server_headers
|
|
3
4
|
from logfire.integrations.flask import CommenterOptions as CommenterOptions, RequestHook as RequestHook, ResponseHook as ResponseHook
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
|
-
def instrument_flask(app: Flask, *, capture_headers: bool, enable_commenter: bool, commenter_options: CommenterOptions | None, excluded_urls: str | None = None, request_hook: RequestHook | None = None, response_hook: ResponseHook | None = None, **kwargs: Any):
|
|
7
|
+
def instrument_flask(logfire_instance: Logfire, app: Flask | None = None, *, capture_headers: bool = False, enable_commenter: bool = True, commenter_options: CommenterOptions | None = None, excluded_urls: str | None = None, request_hook: RequestHook | None = None, response_hook: ResponseHook | None = None, **kwargs: Any) -> None:
|
|
7
8
|
"""Instrument `app` so that spans are automatically created for each request.
|
|
8
9
|
|
|
9
10
|
See the `Logfire.instrument_flask` method for details.
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/openai_agents.pyi
RENAMED
|
@@ -7,7 +7,8 @@ from agents.tracing.spans import SpanError, TSpanData
|
|
|
7
7
|
from dataclasses import dataclass
|
|
8
8
|
from logfire import Logfire as Logfire, LogfireSpan as LogfireSpan
|
|
9
9
|
from logfire._internal.formatter import logfire_format as logfire_format
|
|
10
|
-
from logfire._internal.integrations.llm_providers.openai import get_openai_usage_attributes as get_openai_usage_attributes, inputs_to_events as inputs_to_events, responses_output_events as responses_output_events
|
|
10
|
+
from logfire._internal.integrations.llm_providers.openai import get_openai_usage_attributes as get_openai_usage_attributes, inputs_to_events as inputs_to_events, responses_finish_reasons as responses_finish_reasons, responses_output_events as responses_output_events
|
|
11
|
+
from logfire._internal.integrations.llm_providers.semconv import RESPONSE_FINISH_REASONS as RESPONSE_FINISH_REASONS, RESPONSE_ID as RESPONSE_ID
|
|
11
12
|
from logfire._internal.scrubbing import NOOP_SCRUBBER as NOOP_SCRUBBER
|
|
12
13
|
from logfire._internal.utils import handle_internal_errors as handle_internal_errors, log_internal_error as log_internal_error, truncate_string as truncate_string
|
|
13
14
|
from openai.types.responses import Response
|
|
@@ -5,7 +5,7 @@ from opentelemetry.instrumentation.asgi.types import ClientRequestHook, ClientRe
|
|
|
5
5
|
from starlette.applications import Starlette
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
|
-
def instrument_starlette(logfire_instance: Logfire, app: Starlette, *, record_send_receive: bool = False, capture_headers: bool = False, server_request_hook: ServerRequestHook | None = None, client_request_hook: ClientRequestHook | None = None, client_response_hook: ClientResponseHook | None = None, **kwargs: Any):
|
|
8
|
+
def instrument_starlette(logfire_instance: Logfire, app: Starlette | None = None, *, record_send_receive: bool = False, capture_headers: bool = False, server_request_hook: ServerRequestHook | None = None, client_request_hook: ClientRequestHook | None = None, client_response_hook: ClientResponseHook | None = None, **kwargs: Any) -> None:
|
|
9
9
|
"""Instrument `app` so that spans are automatically created for each request.
|
|
10
10
|
|
|
11
11
|
See the `Logfire.instrument_starlette` method for details.
|
|
@@ -4,6 +4,10 @@ from functools import cache, lru_cache
|
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
6
|
NUMPY_DIMENSION_MAX_SIZE: int
|
|
7
|
+
|
|
8
|
+
def pandas_display_slices(count: int, limit: int | None) -> tuple[slice, ...]:
|
|
9
|
+
"""Return the first and last positions selected by a pandas display limit."""
|
|
10
|
+
|
|
7
11
|
EncoderFunction: Incomplete
|
|
8
12
|
|
|
9
13
|
@cache
|
|
@@ -938,6 +938,10 @@ class Logfire:
|
|
|
938
938
|
[OpenTelemetry SQLAlchemy Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/sqlalchemy/sqlalchemy.html)
|
|
939
939
|
library, specifically `SQLAlchemyInstrumentor().instrument()`, to which it passes `**kwargs`.
|
|
940
940
|
|
|
941
|
+
If the installed SQLAlchemy version is outside the range that instrumentation supports, this raises
|
|
942
|
+
`RuntimeError` instead of returning without recording queries.
|
|
943
|
+
Pass `skip_dep_check=True` to bypass this check. That may produce no spans or errors if the version really is incompatible.
|
|
944
|
+
|
|
941
945
|
Args:
|
|
942
946
|
engine: The `sqlalchemy` engine to instrument.
|
|
943
947
|
engines: An iterable of `sqlalchemy` engines to instrument.
|
|
@@ -2,7 +2,7 @@ import opentelemetry.trace as trace_api
|
|
|
2
2
|
from ..types import ExceptionCallback as ExceptionCallback
|
|
3
3
|
from .config import LogfireConfig as LogfireConfig
|
|
4
4
|
from .constants import ATTRIBUTES_EXCEPTION_FINGERPRINT_KEY as ATTRIBUTES_EXCEPTION_FINGERPRINT_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY as ATTRIBUTES_PENDING_SPAN_REAL_PARENT_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_VALIDATION_ERROR_KEY as ATTRIBUTES_VALIDATION_ERROR_KEY, log_level_attributes as log_level_attributes
|
|
5
|
-
from .utils import handle_internal_errors as handle_internal_errors, sha256_string as sha256_string
|
|
5
|
+
from .utils import handle_internal_errors as handle_internal_errors, is_instrumentation_suppressed as is_instrumentation_suppressed, sha256_string as sha256_string
|
|
6
6
|
from _typeshed import Incomplete
|
|
7
7
|
from collections.abc import Callable, Mapping, Sequence
|
|
8
8
|
from dataclasses import dataclass, field
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from .. import Logfire as Logfire
|
|
2
|
-
from .._internal.constants import ATTRIBUTES_LOGGING_ARGS_KEY as ATTRIBUTES_LOGGING_ARGS_KEY, ATTRIBUTES_LOGGING_NAME as ATTRIBUTES_LOGGING_NAME, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, LOGGING_TO_OTEL_LEVEL_NUMBERS as LOGGING_TO_OTEL_LEVEL_NUMBERS
|
|
2
|
+
from .._internal.constants import ATTRIBUTES_LOGGING_ARGS_KEY as ATTRIBUTES_LOGGING_ARGS_KEY, ATTRIBUTES_LOGGING_NAME as ATTRIBUTES_LOGGING_NAME, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, LOGGING_TO_OTEL_LEVEL_NUMBERS as LOGGING_TO_OTEL_LEVEL_NUMBERS
|
|
3
3
|
from .._internal.utils import is_instrumentation_suppressed as is_instrumentation_suppressed
|
|
4
4
|
from _typeshed import Incomplete
|
|
5
5
|
from collections.abc import Mapping as Mapping
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from .. import Logfire as Logfire
|
|
2
|
-
from .._internal.constants import ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY
|
|
2
|
+
from .._internal.constants import ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY
|
|
3
3
|
from _typeshed import Incomplete
|
|
4
4
|
from structlog.types import EventDict, WrappedLogger
|
|
5
5
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "logfire-api"
|
|
7
|
-
version = "5.
|
|
7
|
+
version = "5.3.0"
|
|
8
8
|
description = "Shim for the Logfire SDK which does nothing unless Logfire is installed"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Pydantic Team", email = "engineering@pydantic.dev" },
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/exporters/processor_wrapper.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/aiohttp_client.pyi
RENAMED
|
File without changes
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/aiohttp_server.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logfire_api-5.2.0 → logfire_api-5.3.0}/logfire_api/_internal/integrations/system_metrics.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|