From e56bd1f5b6903f6fc92bc09b65a0413f7b5c862d Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Wed, 13 Nov 2024 14:01:47 +0200 Subject: [PATCH] Bump version to v2.2.0 --- CHANGELOG.md | 6 ++++++ logfire-api/logfire_api/_internal/integrations/httpx.pyi | 3 ++- logfire-api/logfire_api/_internal/main.pyi | 5 ++++- logfire-api/logfire_api/_internal/metrics.pyi | 9 +++++---- logfire-api/pyproject.toml | 2 +- pyproject.toml | 2 +- uv.lock | 4 ++-- 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ecb976b8..528b71823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release Notes +## [v2.2.0] (2024-11-13) + +* Allow instrumenting a single httpx client by @alexmojaki in [#575](https://github.com/pydantic/logfire/pull/575) +* Log LLM tool call for streamed response by @jackmpcollins in [#545](https://github.com/pydantic/logfire/pull/545) + ## [v2.1.2] (2024-11-04) * Check `.logfire` for creds to respect `'if-token-present'` setting by @sydney-runkle in [#561](https://github.com/pydantic/logfire/pull/561) @@ -406,3 +411,4 @@ First release from new repo! [v2.1.0]: https://github.com/pydantic/logfire/compare/v2.0.0...v2.1.0 [v2.1.1]: https://github.com/pydantic/logfire/compare/v2.1.0...v2.1.1 [v2.1.2]: https://github.com/pydantic/logfire/compare/v2.1.1...v2.1.2 +[v2.2.0]: https://github.com/pydantic/logfire/compare/v2.1.2...v2.2.0 diff --git a/logfire-api/logfire_api/_internal/integrations/httpx.pyi b/logfire-api/logfire_api/_internal/integrations/httpx.pyi index 390370318..cc7237558 100644 --- a/logfire-api/logfire_api/_internal/integrations/httpx.pyi +++ b/logfire-api/logfire_api/_internal/integrations/httpx.pyi @@ -1,3 +1,4 @@ +import httpx from _typeshed import Incomplete from logfire import Logfire as Logfire from typing import TypedDict, Unpack @@ -14,7 +15,7 @@ class HTTPXInstrumentKwargs(TypedDict, total=False): async_response_hook: AsyncResponseHook skip_dep_check: bool -def instrument_httpx(logfire_instance: Logfire, **kwargs: Unpack[HTTPXInstrumentKwargs]) -> None: +def instrument_httpx(logfire_instance: Logfire, client: httpx.Client | httpx.AsyncClient | None, **kwargs: Unpack[HTTPXInstrumentKwargs]) -> None: """Instrument the `httpx` module so that spans are automatically created for each request. See the `Logfire.instrument_httpx` method for details. diff --git a/logfire-api/logfire_api/_internal/main.pyi b/logfire-api/logfire_api/_internal/main.pyi index 820ea8baf..4a30d19dd 100644 --- a/logfire-api/logfire_api/_internal/main.pyi +++ b/logfire-api/logfire_api/_internal/main.pyi @@ -1,4 +1,5 @@ import anthropic +import httpx import openai import opentelemetry.trace as trace_api from . import async_ as async_ @@ -529,9 +530,11 @@ class Logfire: """ def instrument_asyncpg(self, **kwargs: Unpack[AsyncPGInstrumentKwargs]) -> None: """Instrument the `asyncpg` module so that spans are automatically created for each query.""" - def instrument_httpx(self, **kwargs: Unpack[HTTPXInstrumentKwargs]) -> None: + def instrument_httpx(self, client: httpx.Client | httpx.AsyncClient | None = None, **kwargs: Unpack[HTTPXInstrumentKwargs]) -> None: """Instrument the `httpx` module so that spans are automatically created for each request. + Optionally, pass an `httpx.Client` instance to instrument only that client. + Uses the [OpenTelemetry HTTPX Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/httpx/httpx.html) library, specifically `HTTPXClientInstrumentor().instrument()`, to which it passes `**kwargs`. diff --git a/logfire-api/logfire_api/_internal/metrics.pyi b/logfire-api/logfire_api/_internal/metrics.pyi index a5f56d253..2c4d71dc6 100644 --- a/logfire-api/logfire_api/_internal/metrics.pyi +++ b/logfire-api/logfire_api/_internal/metrics.pyi @@ -1,6 +1,7 @@ import dataclasses from _typeshed import Incomplete from abc import ABC +from opentelemetry.context import Context from opentelemetry.metrics import CallbackT as CallbackT, Counter, Histogram, Instrument, Meter, MeterProvider, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter, _Gauge from opentelemetry.util.types import Attributes from threading import Lock @@ -45,17 +46,17 @@ class _ProxyAsynchronousInstrument(_ProxyInstrument[InstrumentT], ABC): def __init__(self, instrument: InstrumentT, name: str, callbacks: Sequence[CallbackT] | None, unit: str, description: str) -> None: ... class _ProxyCounter(_ProxyInstrument[Counter], Counter): - def add(self, amount: int | float, attributes: Attributes | None = None) -> None: ... + def add(self, amount: int | float, attributes: Attributes | None = None, context: Context | None = None) -> None: ... class _ProxyHistogram(_ProxyInstrument[Histogram], Histogram): - def record(self, amount: int | float, attributes: Attributes | None = None) -> None: ... + def record(self, amount: int | float, attributes: Attributes | None = None, context: Context | None = None) -> None: ... class _ProxyObservableCounter(_ProxyAsynchronousInstrument[ObservableCounter], ObservableCounter): ... class _ProxyObservableGauge(_ProxyAsynchronousInstrument[ObservableGauge], ObservableGauge): ... class _ProxyObservableUpDownCounter(_ProxyAsynchronousInstrument[ObservableUpDownCounter], ObservableUpDownCounter): ... class _ProxyUpDownCounter(_ProxyInstrument[UpDownCounter], UpDownCounter): - def add(self, amount: int | float, attributes: Attributes | None = None) -> None: ... + def add(self, amount: int | float, attributes: Attributes | None = None, context: Context | None = None) -> None: ... class _ProxyGauge(_ProxyInstrument[Gauge], Gauge): - def set(self, amount: int | float, attributes: Attributes | None = None) -> None: ... + def set(self, amount: int | float, attributes: Attributes | None = None, context: Context | None = None) -> None: ... diff --git a/logfire-api/pyproject.toml b/logfire-api/pyproject.toml index 268098a65..1e2d856f5 100644 --- a/logfire-api/pyproject.toml +++ b/logfire-api/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "logfire-api" -version = "2.1.2" +version = "2.2.0" description = "Shim for the Logfire SDK which does nothing unless Logfire is installed" authors = [ { name = "Pydantic Team", email = "engineering@pydantic.dev" }, diff --git a/pyproject.toml b/pyproject.toml index 087e47506..f8b580868 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "logfire" -version = "2.1.2" +version = "2.2.0" description = "The best Python observability tool!" requires-python = ">=3.8" authors = [ diff --git a/uv.lock b/uv.lock index d65aad5c5..cdc96dffd 100644 --- a/uv.lock +++ b/uv.lock @@ -1387,7 +1387,7 @@ wheels = [ [[package]] name = "logfire" -version = "2.1.2" +version = "2.2.0" source = { editable = "." } dependencies = [ { name = "executing" }, @@ -1648,7 +1648,7 @@ docs = [ [[package]] name = "logfire-api" -version = "2.1.2" +version = "2.2.0" source = { editable = "logfire-api" } [package.metadata]