Skip to content

Commit b10f6e9

Browse files
authored
Release v0.50.0 (#366)
1 parent be319da commit b10f6e9

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release Notes
22

3+
## [v0.50.0] (2024-08-06)
4+
5+
* **BREAKING CHANGES:** Separate sending to Logfire from using standard OTEL environment variables by @alexmojaki in https://github.com/pydantic/logfire/pull/351. See https://docs.pydantic.dev/logfire/guides/advanced/alternative_backends/ for details. Highlights:
6+
* `OTEL_EXPORTER_OTLP_ENDPOINT` is no longer just an alternative to `LOGFIRE_BASE_URL`. Setting `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, and/or `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` will set up appropriate exporters *in addition* to sending to Logfire, which must be turned off separately if desired. These are basic exporters relying on OTEL defaults. In particular they don't use our custom retrying logic.
7+
* `LOGFIRE_BASE_URL` / `logfire.configure(base_url=...)` is now only intended for actual alternative Logfire backends, which are currently only available to Logfire developers, and unlike `OTEL_EXPORTER_OTLP_ENDPOINT` requires authenticating with Logfire.
8+
* Pending spans are only sent to logfire-specific exporters.
9+
* Add `capture_statement` to Redis instrumentation by @Kludex in https://github.com/pydantic/logfire/pull/355
10+
311
## [v0.49.1] (2024-08-05)
412

513
* Add missing return on instrument methods by @Kludex in https://github.com/pydantic/logfire/pull/360
@@ -242,6 +250,7 @@ First release from new repo!
242250
* Ensure `logfire.testing` doesn't depend on pydantic and eval_type_backport by @alexmojaki in https://github.com/pydantic/logfire/pull/40
243251
* Allow using pydantic plugin with models defined before calling logfire.configure by @alexmojaki in https://github.com/pydantic/logfire/pull/36
244252

253+
[v0.50.0]: https://github.com/pydantic/logfire/compare/v0.49.1...v0.50.0
245254
[v0.49.1]: https://github.com/pydantic/logfire/compare/v0.49.0...v0.49.1
246255
[v0.49.0]: https://github.com/pydantic/logfire/compare/v0.48.1...v0.49.0
247256
[v0.48.1]: https://github.com/pydantic/logfire/compare/v0.48.0...v0.48.1

logfire-api/logfire_api/_internal/config.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dataclasses
22
import requests
3+
from ..testing import TestExporter as TestExporter
34
from .auth import DEFAULT_FILE as DEFAULT_FILE, DefaultFile as DefaultFile, is_logged_in as is_logged_in
45
from .collect_system_info import collect_package_info as collect_package_info
56
from .config_params import ParamManager as ParamManager, PydanticPluginRecordValues as PydanticPluginRecordValues
@@ -93,8 +94,6 @@ def configure(*, send_to_logfire: bool | Literal['if-token-present'] | None = No
9394
metric_readers: Legacy argument, use `additional_metric_readers` instead.
9495
additional_metric_readers: Sequence of metric readers to be used in addition to the default reader
9596
which exports metrics to Logfire's API.
96-
Ensure that `preferred_temporality=logfire.METRICS_PREFERRED_TEMPORALITY`
97-
is passed to the constructor of metric readers/exporters that accept the `preferred_temporality` argument.
9897
pydantic_plugin: Configuration for the Pydantic plugin. If `None` uses the `LOGFIRE_PYDANTIC_PLUGIN_*` environment
9998
variables, otherwise defaults to `PydanticPlugin(record='off')`.
10099
fast_shutdown: Whether to shut down exporters and providers quickly, mostly used for tests. Defaults to `False`.

logfire-api/logfire_api/_internal/integrations/redis.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from logfire._internal.constants import ATTRIBUTES_MESSAGE_KEY as ATTRIBUTES_MESSAGE_KEY
2+
from logfire._internal.utils import truncate_string as truncate_string
13
from opentelemetry.trace import Span
24
from redis import Connection
35
from typing import Any
@@ -14,8 +16,12 @@ class RedisInstrumentKwargs(TypedDict, total=False):
1416
response_hook: ResponseHook | None
1517
skip_dep_check: bool
1618

17-
def instrument_redis(**kwargs: Unpack[RedisInstrumentKwargs]) -> None:
19+
def instrument_redis(capture_statement: bool = False, **kwargs: Unpack[RedisInstrumentKwargs]) -> None:
1820
"""Instrument the `redis` module so that spans are automatically created for each operation.
1921
2022
See the `Logfire.instrument_redis` method for details.
23+
24+
Args:
25+
capture_statement: Whether to capture the statement being executed. Defaults to False.
26+
**kwargs: Additional keyword arguments to pass to the `RedisInstrumentor.instrument` method.
2127
"""

logfire-api/logfire_api/_internal/main.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,16 @@ class Logfire:
617617
[OpenTelemetry pymongo Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/pymongo/pymongo.html)
618618
library, specifically `PymongoInstrumentor().instrument()`, to which it passes `**kwargs`.
619619
"""
620-
def instrument_redis(self, **kwargs: Unpack[RedisInstrumentKwargs]) -> None:
620+
def instrument_redis(self, capture_statement: bool = False, **kwargs: Unpack[RedisInstrumentKwargs]) -> None:
621621
"""Instrument the `redis` module so that spans are automatically created for each operation.
622622
623623
Uses the
624624
[OpenTelemetry Redis Instrumentation](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/redis/redis.html)
625625
library, specifically `RedisInstrumentor().instrument()`, to which it passes `**kwargs`.
626+
627+
Args:
628+
capture_statement: Set to `True` to capture the statement in the span attributes.
629+
kwargs: Additional keyword arguments to pass to the OpenTelemetry `instrument` methods.
626630
"""
627631
def instrument_mysql(self, conn: MySQLConnection = None, **kwargs: Unpack[MySQLInstrumentKwargs]) -> MySQLConnection:
628632
"""Instrument the `mysql` module or a specific MySQL connection so that spans are automatically created for each operation.

logfire-api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "logfire-api"
7-
version = "0.49.1"
7+
version = "0.50.0"
88
description = "Shim for the Logfire SDK which does nothing unless Logfire is installed"
99
authors = [
1010
{ name = "Pydantic Team", email = "[email protected]" },

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "logfire"
7-
version = "0.49.1"
7+
version = "0.50.0"
88
description = "The best Python observability tool! 🪵🔥"
99
authors = [
1010
{ name = "Pydantic Team", email = "[email protected]" },

tests/otel_integrations/test_redis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ def redis_container() -> Iterator[RedisContainer]:
1818

1919

2020
@pytest.fixture
21-
def redis(redis_container: RedisContainer) -> Redis:
22-
return redis_container.get_client() # type: ignore
21+
def redis(redis_container: RedisContainer):
22+
with redis_container.get_client() as redis: # type: ignore
23+
yield redis
2324

2425

2526
@pytest.fixture

0 commit comments

Comments
 (0)