Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies = [
"typing-extensions >= 4.1.0",
"tomli >= 2.0.1; python_version < '3.11'",
"executing >= 2.0.1",
"inline-snapshot",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -142,7 +143,7 @@ dev = [
"opentelemetry-instrumentation-aws-lambda>=0.42b0",
"eval-type-backport >= 0.2.0",
"requests-mock >= 1.12.1",
"inline-snapshot >= 0.17.1",
"inline-snapshot>=0.17.1",
"structlog >= 24.4.0",
"loguru >= 0.7.3",
"ruff >= 0.8.3",
Expand Down Expand Up @@ -206,12 +207,14 @@ docs = [
"mkdocs-llmstxt>=0.2.0",
]


[tool.inline-snapshot]
default-flags = ["disable"]
format-command = "ruff format --stdin-filename {filename}"
show-updates = true

[tool.uv.sources]
logfire-api = { workspace = true }
inline-snapshot = { git = "https://github.com/15r10nk/inline-snapshot.git", rev = "customize" }

[tool.uv]
default-groups = ["dev", "docs"]
Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import anyio._backends._asyncio # noqa # type: ignore
import pytest
from agents.tracing import get_trace_provider
from inline_snapshot.plugin import Builder, Import, customize
from opentelemetry import trace
from opentelemetry.sdk._logs.export import SimpleLogRecordProcessor
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
Expand Down Expand Up @@ -222,3 +223,21 @@ def vcr_config() -> dict[str, Any]:
'filter_headers': SENSITIVE_HEADERS,
'before_record_response': scrub_headers,
}


@customize
def logfire_handler(value: Any, builder: Builder, local_vars: dict[str, Any], global_vars: dict[str, Any]) -> Any:
all_vars = {**global_vars, **local_vars}
for var in ['redis_port', 'HANDLER_NAME', 'code_function']:
if var in all_vars and all_vars[var] == value:
return builder.create_code(var)

for attr in ['started_at', 'ended_at']:
if 's' in local_vars and hasattr(var := local_vars['s'], attr) and getattr(var, attr) == value:
return builder.create_code(f's.{attr}')

if value == os.getcwd():
return builder.create_code('os.getcwd()', imports=[Import('os')])

if value == sys.version:
return builder.create_code('sys.version', imports=[Import('sys')])
15 changes: 7 additions & 8 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading