logfire-api 4.34.0__tar.gz → 4.36.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.34.0 → logfire_api-4.36.0}/PKG-INFO +1 -1
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/__init__.pyi +2 -1
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/config.pyi +8 -4
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/system_metrics.pyi +1 -1
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/logs.pyi +2 -2
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/main.pyi +19 -10
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/metrics.pyi +2 -2
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/tracer.pyi +2 -2
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/db_api.pyi +10 -22
- logfire_api-4.36.0/logfire_api/experimental/query_client.pyi +123 -0
- logfire_api-4.36.0/logfire_api/query_client.pyi +3 -0
- logfire_api-4.36.0/logfire_api/variables/__init__.pyi +6 -0
- logfire_api-4.36.0/logfire_api/variables/_handlebars.pyi +52 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/variables/abstract.pyi +36 -6
- logfire_api-4.36.0/logfire_api/variables/composition.pyi +102 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/variables/config.pyi +12 -5
- logfire_api-4.36.0/logfire_api/variables/template_validation.pyi +53 -0
- logfire_api-4.36.0/logfire_api/variables/variable.pyi +248 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/pyproject.toml +1 -1
- logfire_api-4.34.0/logfire_api/experimental/query_client.pyi +0 -100
- logfire_api-4.34.0/logfire_api/query_client.pyi +0 -1
- logfire_api-4.34.0/logfire_api/variables/__init__.pyi +0 -5
- logfire_api-4.34.0/logfire_api/variables/variable.pyi +0 -130
- {logfire_api-4.34.0 → logfire_api-4.36.0}/.gitignore +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/README.md +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/__init__.py +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/ast_utils.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/async_.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/auth.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/auto_trace/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/auto_trace/import_hook.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/auto_trace/rewrite_ast.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/auto_trace/types.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/baggage.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/ai_tools.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/auth.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/gateway.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/gateway_auth.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/prompt.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli/run.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/cli.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/client.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/collect_system_info.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/config_params.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/constants.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/db_statement_summary.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/console.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/dynamic_batch.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/logs.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/otlp.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/processor_wrapper.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/quiet_metrics.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/remove_pending.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/tail_sampling.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/exporters/wrapper.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/formatter.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/forwarding.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/instrument.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/aiohttp_server.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/asgi.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/asyncpg.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/aws_lambda.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/celery.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/claude_agent_sdk.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/django.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/dspy.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/executors.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/fastapi.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/flask.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/google_genai.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/httpx.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/litellm.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/mcp.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/mysql.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/openai_agents.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/print.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/psycopg.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/pydantic_ai.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/pymongo.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/pytest.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/redis.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/requests.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/sqlite3.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/starlette.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/surrealdb.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/wsgi.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/json_encoder.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/json_formatter.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/json_schema.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/json_types.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/scrubbing.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/server_response.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/stack_info.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/ulid.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/utils.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/cli.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/exceptions.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/experimental/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/experimental/annotations.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/experimental/api_client.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/experimental/datasets/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/experimental/forwarding.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/aiohttp_client.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/flask.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/httpx.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/logging.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/loguru.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/psycopg.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/pydantic.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/redis.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/sqlalchemy.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/structlog.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/integrations/wsgi.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/propagate.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/py.typed +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/sampling/__init__.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/sampling/_tail_sampling.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/types.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/variables/local.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/variables/remote.pyi +0 -0
- {logfire_api-4.34.0 → logfire_api-4.36.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.36.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
|
|
@@ -16,7 +16,7 @@ from logfire.propagate import attach_context as attach_context, get_context as g
|
|
|
16
16
|
from logfire.sampling import SamplingOptions as SamplingOptions
|
|
17
17
|
from typing import Any
|
|
18
18
|
|
|
19
|
-
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'warning', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_pydantic_ai', 'instrument_fastapi', 'instrument_openai', 'instrument_openai_agents', 'instrument_anthropic', 'instrument_google_genai', 'instrument_litellm', 'instrument_dspy', 'instrument_print', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_system_metrics', 'instrument_mcp', 'instrument_claude_agent_sdk', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'add_non_user_code_prefix', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions', 'VariablesOptions', 'LocalVariablesOptions', 'variables', 'var', 'variables_clear', 'variables_get', 'variables_push', 'variables_push_types', 'variables_validate', 'variables_push_config', 'variables_pull_config', 'variables_build_config', 'logfire_info', 'get_baggage', 'set_baggage', 'get_context', 'attach_context', 'url_from_eval', 'forward_export_request', 'forward_export_request_starlette']
|
|
19
|
+
__all__ = ['Logfire', 'LogfireSpan', 'LevelName', 'AdvancedOptions', 'ConsoleOptions', 'CodeSource', 'PydanticPlugin', 'configure', 'span', 'instrument', 'log', 'trace', 'debug', 'notice', 'info', 'warn', 'warning', 'error', 'exception', 'fatal', 'force_flush', 'log_slow_async_callbacks', 'install_auto_tracing', 'instrument_asgi', 'instrument_wsgi', 'instrument_pydantic', 'instrument_pydantic_ai', 'instrument_fastapi', 'instrument_openai', 'instrument_openai_agents', 'instrument_anthropic', 'instrument_google_genai', 'instrument_litellm', 'instrument_dspy', 'instrument_print', 'instrument_asyncpg', 'instrument_httpx', 'instrument_celery', 'instrument_requests', 'instrument_psycopg', 'instrument_django', 'instrument_flask', 'instrument_starlette', 'instrument_aiohttp_client', 'instrument_aiohttp_server', 'instrument_sqlalchemy', 'instrument_sqlite3', 'instrument_aws_lambda', 'instrument_redis', 'instrument_pymongo', 'instrument_mysql', 'instrument_surrealdb', 'instrument_system_metrics', 'instrument_mcp', 'instrument_claude_agent_sdk', 'AutoTraceModule', 'with_tags', 'with_settings', 'suppress_scopes', 'shutdown', 'no_auto_trace', 'ScrubMatch', 'ScrubbingOptions', 'VERSION', 'add_non_user_code_prefix', 'suppress_instrumentation', 'StructlogProcessor', 'LogfireLoggingHandler', 'loguru_handler', 'SamplingOptions', 'MetricsOptions', 'VariablesOptions', 'LocalVariablesOptions', 'variables', 'var', 'template_var', 'variables_clear', 'variables_get', 'variables_push', 'variables_push_types', 'variables_validate', 'variables_push_config', 'variables_pull_config', 'variables_build_config', 'logfire_info', 'get_baggage', 'set_baggage', 'get_context', 'attach_context', 'url_from_eval', 'forward_export_request', 'forward_export_request_starlette']
|
|
20
20
|
|
|
21
21
|
DEFAULT_LOGFIRE_INSTANCE = Logfire()
|
|
22
22
|
span = DEFAULT_LOGFIRE_INSTANCE.span
|
|
@@ -74,6 +74,7 @@ error = DEFAULT_LOGFIRE_INSTANCE.error
|
|
|
74
74
|
fatal = DEFAULT_LOGFIRE_INSTANCE.fatal
|
|
75
75
|
exception = DEFAULT_LOGFIRE_INSTANCE.exception
|
|
76
76
|
var = DEFAULT_LOGFIRE_INSTANCE.var
|
|
77
|
+
template_var = DEFAULT_LOGFIRE_INSTANCE.template_var
|
|
77
78
|
variables_clear = DEFAULT_LOGFIRE_INSTANCE.variables_clear
|
|
78
79
|
variables_get = DEFAULT_LOGFIRE_INSTANCE.variables_get
|
|
79
80
|
variables_push = DEFAULT_LOGFIRE_INSTANCE.variables_push
|
|
@@ -81,8 +81,8 @@ class PydanticPlugin:
|
|
|
81
81
|
This class is deprecated for external use. Use `logfire.instrument_pydantic()` instead.
|
|
82
82
|
"""
|
|
83
83
|
record: PydanticPluginRecordValues = ...
|
|
84
|
-
include: set[str] = field(default_factory=set)
|
|
85
|
-
exclude: set[str] = field(default_factory=set)
|
|
84
|
+
include: set[str] = field(default_factory=set[str])
|
|
85
|
+
exclude: set[str] = field(default_factory=set[str])
|
|
86
86
|
|
|
87
87
|
@dataclass
|
|
88
88
|
class MetricsOptions:
|
|
@@ -99,6 +99,8 @@ class CodeSource:
|
|
|
99
99
|
revision: str
|
|
100
100
|
root_path: str = ...
|
|
101
101
|
|
|
102
|
+
TemplateMismatchPolicy: Incomplete
|
|
103
|
+
|
|
102
104
|
@dataclass
|
|
103
105
|
class VariablesOptions:
|
|
104
106
|
"""Configuration for managed variables using the Logfire remote API.
|
|
@@ -112,6 +114,7 @@ class VariablesOptions:
|
|
|
112
114
|
include_resource_attributes_in_context: bool = ...
|
|
113
115
|
include_baggage_in_context: bool = ...
|
|
114
116
|
instrument: bool = ...
|
|
117
|
+
template_mismatch_policy: TemplateMismatchPolicy = ...
|
|
115
118
|
def __post_init__(self) -> None: ...
|
|
116
119
|
|
|
117
120
|
@dataclass
|
|
@@ -125,6 +128,7 @@ class LocalVariablesOptions:
|
|
|
125
128
|
include_resource_attributes_in_context: bool = ...
|
|
126
129
|
include_baggage_in_context: bool = ...
|
|
127
130
|
instrument: bool = ...
|
|
131
|
+
template_mismatch_policy: TemplateMismatchPolicy = ...
|
|
128
132
|
|
|
129
133
|
class DeprecatedKwargs(TypedDict): ...
|
|
130
134
|
|
|
@@ -286,8 +290,8 @@ class LogfireConfig(_LogfireConfigData):
|
|
|
286
290
|
This is used internally and should not be called by users of the SDK.
|
|
287
291
|
|
|
288
292
|
If no provider has been explicitly configured (i.e. `variables=` was not passed to
|
|
289
|
-
`configure()`), but a `LOGFIRE_API_KEY` is available,
|
|
290
|
-
will be lazily created on the first call.
|
|
293
|
+
`configure()`), but `configure()` has been called and a `LOGFIRE_API_KEY` is available,
|
|
294
|
+
a `LogfireRemoteVariableProvider` will be lazily created on the first call.
|
|
291
295
|
|
|
292
296
|
Returns:
|
|
293
297
|
The variable provider.
|
{logfire_api-4.34.0 → logfire_api-4.36.0}/logfire_api/_internal/integrations/system_metrics.pyi
RENAMED
|
@@ -4,7 +4,7 @@ from logfire import Logfire as Logfire
|
|
|
4
4
|
from typing import Literal
|
|
5
5
|
from typing_extensions import LiteralString
|
|
6
6
|
|
|
7
|
-
MetricName: type[Literal['system.cpu.simple_utilization', 'system.cpu.time', 'system.cpu.utilization', 'system.memory.usage', 'system.memory.utilization', 'system.swap.usage', 'system.swap.utilization', 'system.disk.io', 'system.disk.operations', 'system.disk.time', 'system.network.dropped.packets', 'system.network.packets', 'system.network.errors', 'system.network.io', 'system.network.connections', 'system.thread_count', 'process.open_file_descriptor.count', 'process.context_switches', 'process.cpu.time', 'process.cpu.utilization', 'process.cpu.core_utilization', 'process.memory.usage', 'process.memory.virtual', 'process.thread.count', 'process.runtime.gc_count', 'cpython.gc.collected_objects', 'cpython.gc.collections', 'cpython.gc.uncollectable_objects']]
|
|
7
|
+
MetricName: type[Literal['system.cpu.simple_utilization', 'system.cpu.time', 'system.cpu.utilization', 'system.memory.usage', 'system.memory.utilization', 'system.swap.usage', 'system.swap.utilization', 'system.disk.io', 'system.disk.operations', 'system.disk.time', 'system.network.dropped.packets', 'system.network.packets', 'system.network.errors', 'system.network.io', 'system.network.connections', 'system.thread_count', 'process.open_file_descriptor.count', 'process.context_switches', 'process.cpu.time', 'process.cpu.utilization', 'process.cpu.core_utilization', 'process.disk.io', 'process.memory.usage', 'process.memory.virtual', 'process.thread.count', 'process.runtime.gc_count', 'cpython.gc.collected_objects', 'cpython.gc.collections', 'cpython.gc.uncollectable_objects']]
|
|
8
8
|
Config = dict[MetricName, Iterable[str] | None]
|
|
9
9
|
CPU_FIELDS: list[LiteralString]
|
|
10
10
|
MEMORY_FIELDS: list[LiteralString]
|
|
@@ -11,9 +11,9 @@ from weakref import WeakSet
|
|
|
11
11
|
class ProxyLoggerProvider(LoggerProvider):
|
|
12
12
|
"""A logger provider that wraps another internal logger provider allowing it to be re-assigned."""
|
|
13
13
|
provider: LoggerProvider
|
|
14
|
-
loggers: WeakSet[ProxyLogger] = dataclasses.field(default_factory=WeakSet)
|
|
14
|
+
loggers: WeakSet[ProxyLogger] = dataclasses.field(default_factory=WeakSet['ProxyLogger'])
|
|
15
15
|
lock: Lock = dataclasses.field(default_factory=Lock)
|
|
16
|
-
suppressed_scopes: set[str] = dataclasses.field(default_factory=set)
|
|
16
|
+
suppressed_scopes: set[str] = dataclasses.field(default_factory=set[str])
|
|
17
17
|
min_level: int = ...
|
|
18
18
|
def get_logger(self, name: str, version: str | None = None, schema_url: str | None = None, attributes: _ExtendedAttributes | None = None) -> Logger: ...
|
|
19
19
|
def set_min_level(self, min_level: int) -> None: ...
|
|
@@ -14,10 +14,10 @@ from ..integrations.psycopg import CommenterOptions as PsycopgCommenterOptions
|
|
|
14
14
|
from ..integrations.redis import RequestHook as RedisRequestHook, ResponseHook as RedisResponseHook
|
|
15
15
|
from ..integrations.sqlalchemy import CommenterOptions as SQLAlchemyCommenterOptions
|
|
16
16
|
from ..integrations.wsgi import RequestHook as WSGIRequestHook, ResponseHook as WSGIResponseHook
|
|
17
|
-
from ..variables import ResolveFunction as ResolveFunction, ValidationReport as ValidationReport, Variable as Variable, VariablesConfig as VariablesConfig
|
|
17
|
+
from ..variables import ResolveFunction as ResolveFunction, TemplateVariable as TemplateVariable, ValidationReport as ValidationReport, Variable as Variable, VariablesConfig as VariablesConfig
|
|
18
18
|
from ..version import VERSION as VERSION
|
|
19
19
|
from .auto_trace import AutoTraceModule as AutoTraceModule, install_auto_tracing as install_auto_tracing
|
|
20
|
-
from .config import GLOBAL_CONFIG as GLOBAL_CONFIG, LogfireConfig as LogfireConfig
|
|
20
|
+
from .config import GLOBAL_CONFIG as GLOBAL_CONFIG, LogfireConfig as LogfireConfig, TemplateMismatchPolicy as TemplateMismatchPolicy
|
|
21
21
|
from .config_params import PydanticPluginRecordValues as PydanticPluginRecordValues
|
|
22
22
|
from .constants import ATTRIBUTES_JSON_SCHEMA_KEY as ATTRIBUTES_JSON_SCHEMA_KEY, ATTRIBUTES_LOG_LEVEL_NUM_KEY as ATTRIBUTES_LOG_LEVEL_NUM_KEY, ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY, ATTRIBUTES_MESSAGE_TEMPLATE_KEY as ATTRIBUTES_MESSAGE_TEMPLATE_KEY, ATTRIBUTES_SAMPLE_RATE_KEY as ATTRIBUTES_SAMPLE_RATE_KEY, ATTRIBUTES_SPAN_TYPE_KEY as ATTRIBUTES_SPAN_TYPE_KEY, ATTRIBUTES_TAGS_KEY as ATTRIBUTES_TAGS_KEY, DISABLE_CONSOLE_KEY as DISABLE_CONSOLE_KEY, LEVEL_NUMBERS as LEVEL_NUMBERS, LevelName as LevelName, OTLP_MAX_INT_SIZE as OTLP_MAX_INT_SIZE, log_level_attributes as log_level_attributes
|
|
23
23
|
from .formatter import logfire_format as logfire_format, logfire_format_with_magic as logfire_format_with_magic
|
|
@@ -64,6 +64,7 @@ from wsgiref.types import WSGIApplication
|
|
|
64
64
|
|
|
65
65
|
ExcInfo = SysExcInfo | BaseException | bool | None
|
|
66
66
|
T = TypeVar('T')
|
|
67
|
+
InputsT = TypeVar('InputsT')
|
|
67
68
|
|
|
68
69
|
class Logfire:
|
|
69
70
|
"""The main logfire class."""
|
|
@@ -1214,16 +1215,21 @@ class Logfire:
|
|
|
1214
1215
|
def var(self, name: str, *, default: T, description: str | None = None) -> Variable[T]: ...
|
|
1215
1216
|
@overload
|
|
1216
1217
|
def var(self, name: str, *, type: type[T], default: T | ResolveFunction[T], description: str | None = None) -> Variable[T]: ...
|
|
1218
|
+
@overload
|
|
1219
|
+
def template_var(self, name: str, *, default: T, inputs_type: type[InputsT], description: str | None = None, template_mismatch_policy: TemplateMismatchPolicy | None = None) -> TemplateVariable[T, InputsT]: ...
|
|
1220
|
+
@overload
|
|
1221
|
+
def template_var(self, name: str, *, type: type[T], default: T | ResolveFunction[T], inputs_type: type[InputsT], description: str | None = None, template_mismatch_policy: TemplateMismatchPolicy | None = None) -> TemplateVariable[T, InputsT]: ...
|
|
1217
1222
|
def variables_clear(self) -> None:
|
|
1218
1223
|
"""Clear all registered variables from this Logfire instance.
|
|
1219
1224
|
|
|
1220
|
-
This removes all variables previously registered via [`var()`][logfire.Logfire.var]
|
|
1225
|
+
This removes all variables previously registered via [`var()`][logfire.Logfire.var]
|
|
1226
|
+
or [`template_var()`][logfire.Logfire.template_var],
|
|
1221
1227
|
allowing them to be re-registered. This is primarily intended for use in tests
|
|
1222
1228
|
to ensure a clean state between test cases.
|
|
1223
1229
|
"""
|
|
1224
|
-
def variables_get(self) -> list[Variable[Any]]:
|
|
1230
|
+
def variables_get(self) -> list[Variable[Any] | TemplateVariable[Any, Any]]:
|
|
1225
1231
|
"""Get all variables registered with this Logfire instance."""
|
|
1226
|
-
def variables_push(self, variables: list[Variable[Any]] | None = None, *, dry_run: bool = False, yes: bool = False, strict: bool = False) -> bool:
|
|
1232
|
+
def variables_push(self, variables: list[Variable[Any] | TemplateVariable[Any, Any]] | None = None, *, dry_run: bool = False, yes: bool = False, strict: bool = False) -> bool:
|
|
1227
1233
|
"""Push variable definitions (metadata only) to the configured variable provider.
|
|
1228
1234
|
|
|
1229
1235
|
This method syncs local variable definitions with the provider:
|
|
@@ -1239,7 +1245,8 @@ class Logfire:
|
|
|
1239
1245
|
registered with this Logfire instance will be pushed.
|
|
1240
1246
|
dry_run: If True, only show what would change without applying.
|
|
1241
1247
|
yes: If True, skip confirmation prompt.
|
|
1242
|
-
strict: If True, fail if any existing label values are incompatible with new schemas
|
|
1248
|
+
strict: If True, fail if any existing label values are incompatible with new schemas
|
|
1249
|
+
or any reference errors are found.
|
|
1243
1250
|
|
|
1244
1251
|
Returns:
|
|
1245
1252
|
True if changes were applied (or would be applied in dry_run mode), False otherwise.
|
|
@@ -1316,7 +1323,7 @@ class Logfire:
|
|
|
1316
1323
|
)
|
|
1317
1324
|
```
|
|
1318
1325
|
"""
|
|
1319
|
-
def variables_validate(self, variables: list[Variable[Any]] | None = None) -> ValidationReport:
|
|
1326
|
+
def variables_validate(self, variables: list[Variable[Any] | TemplateVariable[Any, Any]] | None = None) -> ValidationReport:
|
|
1320
1327
|
"""Validate that provider-side variable label values match local type definitions.
|
|
1321
1328
|
|
|
1322
1329
|
This method fetches the current variable configuration from the provider and
|
|
@@ -1350,8 +1357,10 @@ class Logfire:
|
|
|
1350
1357
|
def variables_push_config(self, config: VariablesConfig, *, mode: Literal['merge', 'replace'] = 'merge', dry_run: bool = False, yes: bool = False) -> bool:
|
|
1351
1358
|
'''Push a VariablesConfig to the configured provider.
|
|
1352
1359
|
|
|
1353
|
-
This method pushes a
|
|
1354
|
-
|
|
1360
|
+
This method pushes a VariablesConfig (including labels and rollouts) to the
|
|
1361
|
+
provider. For remote providers, version records are created from label
|
|
1362
|
+
entries with inline serialized values; `latest_version` is pull/read state
|
|
1363
|
+
derived by the server and is not pushed directly. It\'s useful for:
|
|
1355
1364
|
- Pushing configs generated or modified locally
|
|
1356
1365
|
- Pushing configs read from files
|
|
1357
1366
|
- Partial updates (merge mode) or full replacement (replace mode)
|
|
@@ -1396,7 +1405,7 @@ class Logfire:
|
|
|
1396
1405
|
print(config.model_dump_json(indent=2))
|
|
1397
1406
|
```
|
|
1398
1407
|
'''
|
|
1399
|
-
def variables_build_config(self, variables: list[Variable[Any]] | None = None) -> VariablesConfig:
|
|
1408
|
+
def variables_build_config(self, variables: list[Variable[Any] | TemplateVariable[Any, Any]] | None = None) -> VariablesConfig:
|
|
1400
1409
|
'''Build a VariablesConfig from registered Variable instances.
|
|
1401
1410
|
|
|
1402
1411
|
This creates a minimal config with just the name, schema, and example for each variable.
|
|
@@ -11,9 +11,9 @@ from weakref import WeakSet
|
|
|
11
11
|
@dataclasses.dataclass
|
|
12
12
|
class ProxyMeterProvider(MeterProvider):
|
|
13
13
|
provider: MeterProvider
|
|
14
|
-
meters: WeakSet[_ProxyMeter] = dataclasses.field(default_factory=WeakSet)
|
|
14
|
+
meters: WeakSet[_ProxyMeter] = dataclasses.field(default_factory=WeakSet['_ProxyMeter'])
|
|
15
15
|
lock: Lock = dataclasses.field(default_factory=Lock)
|
|
16
|
-
suppressed_scopes: set[str] = dataclasses.field(default_factory=set)
|
|
16
|
+
suppressed_scopes: set[str] = dataclasses.field(default_factory=set[str])
|
|
17
17
|
def get_meter(self, name: str, version: str | None = None, schema_url: str | None = None, attributes: Attributes | None = None) -> Meter: ...
|
|
18
18
|
def suppress_scopes(self, *scopes: str) -> None: ...
|
|
19
19
|
def set_meter_provider(self, meter_provider: MeterProvider) -> None: ...
|
|
@@ -25,9 +25,9 @@ class ProxyTracerProvider(TracerProvider):
|
|
|
25
25
|
"""A tracer provider that wraps another internal tracer provider allowing it to be re-assigned."""
|
|
26
26
|
provider: TracerProvider
|
|
27
27
|
config: LogfireConfig
|
|
28
|
-
tracers: WeakKeyDictionary[_ProxyTracer, Callable[[], Tracer]] = field(default_factory=WeakKeyDictionary)
|
|
28
|
+
tracers: WeakKeyDictionary[_ProxyTracer, Callable[[], Tracer]] = field(default_factory=WeakKeyDictionary['_ProxyTracer', Callable[[], Tracer]])
|
|
29
29
|
lock: Lock = field(default_factory=Lock)
|
|
30
|
-
suppressed_scopes: set[str] = field(default_factory=set)
|
|
30
|
+
suppressed_scopes: set[str] = field(default_factory=set[str])
|
|
31
31
|
def set_provider(self, provider: SDKTracerProvider) -> None: ...
|
|
32
32
|
def suppress_scopes(self, *scopes: str) -> None: ...
|
|
33
33
|
def get_tracer(self, instrumenting_module_name: str, *args: Any, is_span_tracer: bool = True, **kwargs: Any) -> _ProxyTracer: ...
|
|
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
|
|
|
2
2
|
from collections.abc import Sequence
|
|
3
3
|
from datetime import datetime, timedelta
|
|
4
4
|
from logfire.experimental.query_client import ColumnDetails as ColumnDetails, LogfireQueryClient as LogfireQueryClient
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any, overload
|
|
6
6
|
|
|
7
7
|
apilevel: str
|
|
8
8
|
threadsafety: int
|
|
@@ -49,11 +49,15 @@ class Cursor:
|
|
|
49
49
|
"""PEP 249 Cursor that executes queries via `LogfireQueryClient.query_json_rows()`."""
|
|
50
50
|
rowcount: int
|
|
51
51
|
arraysize: int
|
|
52
|
-
min_timestamp: datetime | None
|
|
53
52
|
max_timestamp: datetime | None
|
|
54
53
|
limit: int
|
|
55
54
|
def __init__(self, connection: Connection) -> None: ...
|
|
56
55
|
@property
|
|
56
|
+
def min_timestamp(self) -> datetime | None:
|
|
57
|
+
"""Per-cursor override for the lower `start_timestamp` bound."""
|
|
58
|
+
@min_timestamp.setter
|
|
59
|
+
def min_timestamp(self, value: datetime | None) -> None: ...
|
|
60
|
+
@property
|
|
57
61
|
def description(self) -> list[tuple[Any, ...]] | None:
|
|
58
62
|
"""Column description as a list of 7-tuples per PEP 249.
|
|
59
63
|
|
|
@@ -88,23 +92,7 @@ class Cursor:
|
|
|
88
92
|
def __enter__(self) -> Cursor: ...
|
|
89
93
|
def __exit__(self, *args: Any) -> None: ...
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
read_token: A Logfire read token for authentication.
|
|
96
|
-
base_url: Override the default API base URL (inferred from token region).
|
|
97
|
-
timeout: HTTP request timeout in seconds.
|
|
98
|
-
min_timestamp: Default lower bound for `start_timestamp` filtering.
|
|
99
|
-
Accepts a `datetime` for an exact bound, a `timedelta` for a
|
|
100
|
-
relative window (computed as `now - timedelta`), or `None` to
|
|
101
|
-
disable the filter. Defaults to 1 day ago.
|
|
102
|
-
max_timestamp: Default upper bound for `start_timestamp` filtering.
|
|
103
|
-
limit: Default row limit per query (max 10,000). When the number of
|
|
104
|
-
returned rows equals the limit a warning is emitted.
|
|
105
|
-
**kwargs: Additional keyword arguments forwarded to the underlying
|
|
106
|
-
`httpx.Client`.
|
|
107
|
-
|
|
108
|
-
Returns:
|
|
109
|
-
A PEP 249 `Connection` object.
|
|
110
|
-
"""
|
|
95
|
+
@overload
|
|
96
|
+
def connect(read_token: str, base_url: str | None = None, timeout: float = 30.0, *, min_timestamp: None, max_timestamp: datetime | None = None, limit: int = ..., **kwargs: Any) -> Connection: ...
|
|
97
|
+
@overload
|
|
98
|
+
def connect(read_token: str, base_url: str | None = None, timeout: float = 30.0, *, min_timestamp: datetime | timedelta = ..., max_timestamp: datetime | None = None, limit: int = ..., **kwargs: Any) -> Connection: ...
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from httpx import AsyncClient, Client, Response, Timeout
|
|
4
|
+
from httpx._client import BaseClient
|
|
5
|
+
from logfire import VERSION as VERSION
|
|
6
|
+
from logfire._internal.config import get_base_url_from_token as get_base_url_from_token
|
|
7
|
+
from logfire._internal.stack_info import warn_at_user_stacklevel as warn_at_user_stacklevel
|
|
8
|
+
from pyarrow import Table
|
|
9
|
+
from types import TracebackType
|
|
10
|
+
from typing import Any, Generic, TypeVar, TypedDict, overload
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
|
|
13
|
+
DEFAULT_TIMEOUT: Incomplete
|
|
14
|
+
|
|
15
|
+
class QueryExecutionError(RuntimeError):
|
|
16
|
+
"""Raised when the query execution fails on the server."""
|
|
17
|
+
class QueryRequestError(RuntimeError):
|
|
18
|
+
"""Raised when the query request is invalid."""
|
|
19
|
+
class InfoRequestError(RuntimeError):
|
|
20
|
+
"""Raised when the request for read token info fails because of unavailable information."""
|
|
21
|
+
|
|
22
|
+
class ReadTokenInfo(TypedDict, total=False):
|
|
23
|
+
"""Information about the read token."""
|
|
24
|
+
organization_name: str
|
|
25
|
+
project_name: str
|
|
26
|
+
|
|
27
|
+
class ColumnDetails(TypedDict):
|
|
28
|
+
"""The details of a column in the row-oriented JSON-format query results."""
|
|
29
|
+
name: str
|
|
30
|
+
datatype: Any
|
|
31
|
+
nullable: bool
|
|
32
|
+
|
|
33
|
+
class ColumnData(ColumnDetails):
|
|
34
|
+
"""The data of a column in the column-oriented JSON-format query results."""
|
|
35
|
+
values: list[Any]
|
|
36
|
+
|
|
37
|
+
class QueryResults(TypedDict):
|
|
38
|
+
"""The (column-oriented) results of a JSON-format query."""
|
|
39
|
+
columns: list[ColumnData]
|
|
40
|
+
|
|
41
|
+
class RowQueryResults(TypedDict):
|
|
42
|
+
"""The row-oriented results of a JSON-format query."""
|
|
43
|
+
columns: list[ColumnDetails]
|
|
44
|
+
rows: list[dict[str, Any]]
|
|
45
|
+
T = TypeVar('T', bound=BaseClient)
|
|
46
|
+
|
|
47
|
+
class _BaseLogfireQueryClient(Generic[T]):
|
|
48
|
+
base_url: Incomplete
|
|
49
|
+
read_token: Incomplete
|
|
50
|
+
timeout: Incomplete
|
|
51
|
+
client: T
|
|
52
|
+
def __init__(self, base_url: str, read_token: str, timeout: Timeout, client: type[T], **client_kwargs: Any) -> None: ...
|
|
53
|
+
def handle_response_errors(self, response: Response) -> None: ...
|
|
54
|
+
|
|
55
|
+
class LogfireQueryClient(_BaseLogfireQueryClient[Client]):
|
|
56
|
+
"""A synchronous client for querying Logfire data."""
|
|
57
|
+
def __init__(self, read_token: str, base_url: str | None = None, timeout: Timeout = ..., **client_kwargs: Any) -> None: ...
|
|
58
|
+
def __enter__(self) -> Self: ...
|
|
59
|
+
def __exit__(self, exc_type: type[BaseException] | None = None, exc_value: BaseException | None = None, traceback: TracebackType | None = None) -> None: ...
|
|
60
|
+
def info(self) -> ReadTokenInfo:
|
|
61
|
+
"""Get information about the read token."""
|
|
62
|
+
def query_json(self, sql: str, min_timestamp: datetime | None = None, max_timestamp: datetime | None = None, limit: int | None = None) -> QueryResults:
|
|
63
|
+
"""Query Logfire data and return the results as a column-oriented dictionary."""
|
|
64
|
+
@overload
|
|
65
|
+
def query_json_rows(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> RowQueryResults: ...
|
|
66
|
+
@overload
|
|
67
|
+
def query_json_rows(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> RowQueryResults: ...
|
|
68
|
+
@overload
|
|
69
|
+
def query_arrow(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> Table: ...
|
|
70
|
+
@overload
|
|
71
|
+
def query_arrow(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> Table: ...
|
|
72
|
+
@overload
|
|
73
|
+
def query_csv(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> str: ...
|
|
74
|
+
@overload
|
|
75
|
+
def query_csv(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> str: ...
|
|
76
|
+
|
|
77
|
+
class AsyncLogfireQueryClient(_BaseLogfireQueryClient[AsyncClient]):
|
|
78
|
+
"""An asynchronous client for querying Logfire data."""
|
|
79
|
+
def __init__(self, read_token: str, base_url: str | None = None, timeout: Timeout = ..., **async_client_kwargs: Any) -> None: ...
|
|
80
|
+
async def __aenter__(self) -> Self: ...
|
|
81
|
+
async def __aexit__(self, exc_type: type[BaseException] | None = None, exc_value: BaseException | None = None, traceback: TracebackType | None = None) -> None: ...
|
|
82
|
+
async def info(self) -> ReadTokenInfo:
|
|
83
|
+
"""Get information about the read token."""
|
|
84
|
+
@overload
|
|
85
|
+
async def query_json_rows(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> RowQueryResults: ...
|
|
86
|
+
@overload
|
|
87
|
+
async def query_json_rows(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> RowQueryResults: ...
|
|
88
|
+
async def query_json(self, sql: str, min_timestamp: datetime | None = None, max_timestamp: datetime | None = None, limit: int | None = None) -> QueryResults:
|
|
89
|
+
"""Query Logfire data and return the results as a column-oriented dictionary."""
|
|
90
|
+
async def query_json_rows(self, sql: str, min_timestamp: datetime | None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> RowQueryResults:
|
|
91
|
+
"""Query Logfire data and return the results as a row-oriented dictionary.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
sql: The SQL `SELECT` query to execute.
|
|
95
|
+
min_timestamp: The minimum timestamp to use when querying data. If the provided
|
|
96
|
+
[`datetime`][datetime.datetime] doesn't have a timezone set, it is assumed to
|
|
97
|
+
be UTC.
|
|
98
|
+
|
|
99
|
+
/// version-deprecated | v4.35.0
|
|
100
|
+
Not providing a `min_timestamp` is deprecated.
|
|
101
|
+
///
|
|
102
|
+
max_timestamp: The maximum timestamp to use when querying data. If the provided
|
|
103
|
+
[`datetime`][datetime.datetime] doesn't have a timezone set, it is assumed to
|
|
104
|
+
be UTC.
|
|
105
|
+
limit: The maximum number of rows to query. This value takes priority over the
|
|
106
|
+
`LIMIT` clause in the `sql` query.
|
|
107
|
+
timezone: The timezone to use for the query execution context.
|
|
108
|
+
environment: Restrict rows to the provided environment(s). To only query rows where no environment is set,
|
|
109
|
+
use the empty string (`''`).
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
A dictionary with two entries:
|
|
113
|
+
* `columns`: A list of column details including the name, datatype and whether the column is nullable.
|
|
114
|
+
* `rows`: The list of rows matching the query.
|
|
115
|
+
"""
|
|
116
|
+
@overload
|
|
117
|
+
async def query_arrow(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> Table: ...
|
|
118
|
+
@overload
|
|
119
|
+
async def query_arrow(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> Table: ...
|
|
120
|
+
@overload
|
|
121
|
+
async def query_csv(self, sql: str, min_timestamp: None = None, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> str: ...
|
|
122
|
+
@overload
|
|
123
|
+
async def query_csv(self, sql: str, min_timestamp: datetime, max_timestamp: datetime | None = None, limit: int | None = None, *, timezone: str | None = None, environment: str | list[str] | None = None) -> str: ...
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
from .experimental.query_client import AsyncLogfireQueryClient as AsyncLogfireQueryClient, ColumnData as ColumnData, ColumnDetails as ColumnDetails, InfoRequestError as InfoRequestError, LogfireQueryClient as LogfireQueryClient, QueryExecutionError as QueryExecutionError, QueryRequestError as QueryRequestError, QueryResults as QueryResults, ReadTokenInfo as ReadTokenInfo, RowQueryResults as RowQueryResults
|
|
2
|
+
|
|
3
|
+
__all__ = ['QueryExecutionError', 'QueryRequestError', 'InfoRequestError', 'ReadTokenInfo', 'ColumnDetails', 'ColumnData', 'QueryResults', 'RowQueryResults', 'LogfireQueryClient', 'AsyncLogfireQueryClient']
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from logfire.variables.abstract import ResolutionReason as ResolutionReason, ResolvedVariable as ResolvedVariable, SyncMode as SyncMode, ValidationReport as ValidationReport, VariableAlreadyExistsError as VariableAlreadyExistsError, VariableNotFoundError as VariableNotFoundError, VariableWriteError as VariableWriteError
|
|
2
|
+
from logfire.variables.composition import ComposedReference as ComposedReference, VariableCompositionCycleError as VariableCompositionCycleError, VariableCompositionError as VariableCompositionError
|
|
3
|
+
from logfire.variables.config import KeyIsNotPresent as KeyIsNotPresent, KeyIsPresent as KeyIsPresent, LabelRef as LabelRef, LabeledValue as LabeledValue, LatestVersion as LatestVersion, LocalVariablesOptions as LocalVariablesOptions, Rollout as Rollout, RolloutOverride as RolloutOverride, TemplateMismatchPolicy as TemplateMismatchPolicy, ValueDoesNotEqual as ValueDoesNotEqual, ValueDoesNotMatchRegex as ValueDoesNotMatchRegex, ValueEquals as ValueEquals, ValueIsIn as ValueIsIn, ValueIsNotIn as ValueIsNotIn, ValueMatchesRegex as ValueMatchesRegex, VariableConfig as VariableConfig, VariableTypeConfig as VariableTypeConfig, VariablesConfig as VariablesConfig
|
|
4
|
+
from logfire.variables.variable import ResolveFunction as ResolveFunction, TemplateInputsMismatchError as TemplateInputsMismatchError, TemplateVariable as TemplateVariable, Variable as Variable, targeting_context as targeting_context
|
|
5
|
+
|
|
6
|
+
__all__ = ['Variable', 'TemplateVariable', 'ResolvedVariable', 'ResolveFunction', 'VariablesConfig', 'VariableConfig', 'VariableTypeConfig', 'LocalVariablesOptions', 'LabeledValue', 'LabelRef', 'LatestVersion', 'Rollout', 'RolloutOverride', 'KeyIsPresent', 'KeyIsNotPresent', 'ValueEquals', 'ValueDoesNotEqual', 'ValueIsIn', 'ValueIsNotIn', 'ValueMatchesRegex', 'ValueDoesNotMatchRegex', 'targeting_context', 'ComposedReference', 'ResolutionReason', 'SyncMode', 'TemplateMismatchPolicy', 'ValidationReport', 'TemplateInputsMismatchError', 'VariableAlreadyExistsError', 'VariableCompositionCycleError', 'VariableCompositionError', 'VariableNotFoundError', 'VariableWriteError']
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from functools import cache
|
|
2
|
+
from pydantic_handlebars import CompiledTemplate, HandlebarsEnvironment
|
|
3
|
+
|
|
4
|
+
COMPOSITION_OPEN_DELIM: str
|
|
5
|
+
COMPOSITION_CLOSE_DELIM: str
|
|
6
|
+
|
|
7
|
+
@cache
|
|
8
|
+
def get_environment(strict: bool = False) -> HandlebarsEnvironment:
|
|
9
|
+
"""Return a cached `HandlebarsEnvironment` configured for `@{...}@` composition.
|
|
10
|
+
|
|
11
|
+
Uses non-default delimiters so the composition pass leaves any
|
|
12
|
+
`{{...}}` runtime placeholders in the template as plain content; a
|
|
13
|
+
subsequent render pass with the default delimiters consumes those.
|
|
14
|
+
|
|
15
|
+
When *strict* is `True`, the environment raises `HandlebarsRuntimeError`
|
|
16
|
+
for any `@{ref}@` (or dotted `@{ref.field}@`) that doesn't resolve, rather
|
|
17
|
+
than rendering it as an empty string. Composition uses the strict
|
|
18
|
+
environment for provider/override values (so a missing reference triggers a
|
|
19
|
+
fall back to the code default) and the non-strict one for the code default
|
|
20
|
+
itself (the lenient last resort, where a missing reference renders empty).
|
|
21
|
+
"""
|
|
22
|
+
@cache
|
|
23
|
+
def get_runtime_environment() -> HandlebarsEnvironment:
|
|
24
|
+
"""Return a cached default-delimiter `HandlebarsEnvironment` for `{{...}}` rendering.
|
|
25
|
+
|
|
26
|
+
Used by `TemplateVariable.get(inputs)` to render the post-composition
|
|
27
|
+
serialized value against the provided inputs.
|
|
28
|
+
"""
|
|
29
|
+
def compile_composition_template(source: str, strict: bool = False) -> CompiledTemplate:
|
|
30
|
+
"""Return a cached `CompiledTemplate` for *source* under composition delimiters.
|
|
31
|
+
|
|
32
|
+
Managed-variable values are typically stable across many resolutions, so
|
|
33
|
+
caching the parsed program lets `Variable._resolve` skip the parse on
|
|
34
|
+
every `get()` call. 1024 is large enough for any realistic number of
|
|
35
|
+
distinct templates in a single process while staying bounded for
|
|
36
|
+
long-running workers. Same rationale for `compile_runtime_template`.
|
|
37
|
+
|
|
38
|
+
*strict* selects the strict vs non-strict composition environment (see
|
|
39
|
+
`get_environment`); the two are cached separately.
|
|
40
|
+
"""
|
|
41
|
+
def compile_runtime_template(source: str) -> CompiledTemplate:
|
|
42
|
+
"""Return a cached `CompiledTemplate` for *source* under default `{{...}}` delimiters."""
|
|
43
|
+
def extract_composition_dependencies(template: str) -> frozenset[str]:
|
|
44
|
+
"""Return the top-level `@{name}@` references in *template*.
|
|
45
|
+
|
|
46
|
+
Cached because cycle / reference validation runs over the same template
|
|
47
|
+
strings multiple times per push or sync. The underlying delegation goes
|
|
48
|
+
to `pydantic_handlebars.extract_dependencies` configured for the
|
|
49
|
+
composition delimiters, so block helpers, dotted paths, and helper
|
|
50
|
+
sub-expressions are handled AST-correctly. A `frozenset` is returned so the
|
|
51
|
+
cached value can't be mutated by a caller and poison later lookups.
|
|
52
|
+
"""
|
|
@@ -2,12 +2,14 @@ import logfire
|
|
|
2
2
|
from _typeshed import Incomplete
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from collections.abc import Mapping, Sequence
|
|
5
|
-
from dataclasses import dataclass
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from logfire.variables.composition import ComposedReference
|
|
6
7
|
from logfire.variables.config import VariableConfig, VariableTypeConfig, VariablesConfig
|
|
8
|
+
from logfire.variables.template_validation import TemplateFieldIssue
|
|
7
9
|
from logfire.variables.variable import Variable
|
|
8
10
|
from typing import Any, Generic, TypeVar
|
|
9
11
|
|
|
10
|
-
__all__ = ['ResolvedVariable', 'ResolutionReason', 'SyncMode', 'ValidationReport', 'VariableProvider', 'NoOpVariableProvider', 'VariableWriteError', 'VariableNotFoundError', 'VariableAlreadyExistsError']
|
|
12
|
+
__all__ = ['ResolvedVariable', 'ResolutionReason', 'SyncMode', 'ValidationReport', 'VariableProvider', 'NoOpVariableProvider', 'VariableWriteError', 'VariableNotFoundError', 'VariableAlreadyExistsError', 'render_serialized_string']
|
|
11
13
|
|
|
12
14
|
SyncMode: Incomplete
|
|
13
15
|
T = TypeVar('T')
|
|
@@ -46,11 +48,27 @@ class ResolvedVariable(Generic[T_co]):
|
|
|
46
48
|
label: str | None = ...
|
|
47
49
|
version: int | None = ...
|
|
48
50
|
exception: Exception | None = ...
|
|
51
|
+
composed_from: list[ComposedReference] = field(default_factory=list['ComposedReference'])
|
|
49
52
|
reason: ResolutionReason
|
|
50
53
|
def __post_init__(self) -> None: ...
|
|
51
54
|
def __enter__(self): ...
|
|
52
55
|
def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any) -> None: ...
|
|
53
56
|
|
|
57
|
+
def render_serialized_string(serialized_json: str, inputs: Any) -> str:
|
|
58
|
+
"""Render Handlebars templates in a serialized JSON string.
|
|
59
|
+
|
|
60
|
+
Decodes the JSON, renders all string values containing `{{placeholders}}`
|
|
61
|
+
using the provided inputs, then re-encodes to JSON.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
serialized_json: A JSON-encoded string potentially containing Handlebars templates.
|
|
65
|
+
inputs: Template context values. Can be a Pydantic `BaseModel`, `dict`,
|
|
66
|
+
`Mapping`, or `None`.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
The rendered JSON string.
|
|
70
|
+
"""
|
|
71
|
+
|
|
54
72
|
@dataclass
|
|
55
73
|
class LabelCompatibility:
|
|
56
74
|
"""Result of checking a label value's compatibility with a schema."""
|
|
@@ -72,12 +90,18 @@ class VariableChange:
|
|
|
72
90
|
local_description: str | None = ...
|
|
73
91
|
server_description: str | None = ...
|
|
74
92
|
description_differs: bool = ...
|
|
93
|
+
template_inputs_schema: dict[str, Any] | None = ...
|
|
94
|
+
value_schema_changed: bool = ...
|
|
95
|
+
inputs_schema_changed: bool = ...
|
|
75
96
|
|
|
76
97
|
@dataclass
|
|
77
98
|
class VariableDiff:
|
|
78
99
|
"""Represents the diff between local and server variables."""
|
|
79
100
|
changes: list[VariableChange]
|
|
80
101
|
orphaned_server_variables: list[str]
|
|
102
|
+
reference_errors: list[str] = field(default_factory=list[str])
|
|
103
|
+
reference_cycles: list[str] = field(default_factory=list[str])
|
|
104
|
+
template_field_issues: list[TemplateFieldIssue] = field(default_factory=list)
|
|
81
105
|
@property
|
|
82
106
|
def has_changes(self) -> bool:
|
|
83
107
|
"""Return True if there are any changes to apply."""
|
|
@@ -116,12 +140,15 @@ class ValidationReport:
|
|
|
116
140
|
variables_checked: int
|
|
117
141
|
variables_not_on_server: list[str]
|
|
118
142
|
description_differences: list[DescriptionDifference]
|
|
143
|
+
reference_errors: list[str] = field(default_factory=list[str])
|
|
144
|
+
reference_cycles: list[str] = field(default_factory=list[str])
|
|
145
|
+
template_field_issues: list[TemplateFieldIssue] = field(default_factory=list)
|
|
119
146
|
@property
|
|
120
147
|
def has_errors(self) -> bool:
|
|
121
148
|
"""Return True if there are any validation errors."""
|
|
122
149
|
@property
|
|
123
150
|
def is_valid(self) -> bool:
|
|
124
|
-
"""Return False if there are
|
|
151
|
+
"""Return False if there are validation errors, missing variables, or reference errors."""
|
|
125
152
|
def format(self, *, colors: bool = True) -> str:
|
|
126
153
|
"""Format the validation report for human-readable output.
|
|
127
154
|
|
|
@@ -276,8 +303,10 @@ class VariableProvider(ABC):
|
|
|
276
303
|
def push_config(self, config: VariablesConfig, *, mode: SyncMode = 'merge', dry_run: bool = False, yes: bool = False) -> bool:
|
|
277
304
|
"""Push a VariablesConfig to this provider.
|
|
278
305
|
|
|
279
|
-
This method pushes a
|
|
280
|
-
|
|
306
|
+
This method pushes a VariablesConfig (including labels and rollouts) to the
|
|
307
|
+
provider. For remote providers, version records are created from label
|
|
308
|
+
entries with inline serialized values; `latest_version` is pull/read state
|
|
309
|
+
derived by the server and is not pushed directly. It's useful for:
|
|
281
310
|
- Pushing configs generated or modified locally
|
|
282
311
|
- Pushing configs read from files
|
|
283
312
|
- Partial updates (merge mode) or full replacement (replace mode)
|
|
@@ -313,7 +342,8 @@ class VariableProvider(ABC):
|
|
|
313
342
|
variables: Variable instances to push.
|
|
314
343
|
dry_run: If True, only show what would change without applying.
|
|
315
344
|
yes: If True, skip confirmation prompt.
|
|
316
|
-
strict: If True, fail if any existing label values are incompatible with new schemas
|
|
345
|
+
strict: If True, fail if any existing label values are incompatible with new schemas
|
|
346
|
+
or any reference errors are found.
|
|
317
347
|
|
|
318
348
|
Returns:
|
|
319
349
|
True if changes were applied (or would be applied in dry_run mode), False otherwise.
|