Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: declare variables which should not be managed by inline-snapshot #569

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions tests/otel_integrations/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Iterator

import pytest
from inline_snapshot import snapshot
from inline_snapshot import Is, snapshot
from opentelemetry.instrumentation.redis import RedisInstrumentor
from opentelemetry.trace import Span
from redis import Connection, Redis
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_instrument_redis(redis: Redis, redis_port: str, exporter: TestExporter)
'db.system': 'redis',
'db.redis.database_index': 0,
'net.peer.name': 'localhost',
'net.peer.port': redis_port,
'net.peer.port': Is(redis_port),
'net.transport': 'ip_tcp',
'db.redis.args_length': 3,
},
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_instrument_redis_with_capture_statement(redis: Redis, redis_port: str,
'db.system': 'redis',
'db.redis.database_index': 0,
'net.peer.name': 'localhost',
'net.peer.port': redis_port,
'net.peer.port': Is(redis_port),
'net.transport': 'ip_tcp',
'db.redis.args_length': 3,
},
Expand All @@ -116,7 +116,7 @@ def test_instrument_redis_with_big_capture_statement(redis: Redis, redis_port: s
'db.system': 'redis',
'db.redis.database_index': 0,
'net.peer.name': 'localhost',
'net.peer.port': redis_port,
'net.peer.port': Is(redis_port),
'net.transport': 'ip_tcp',
'db.redis.args_length': 3,
'db.statement': 'SET kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk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150,7 @@ def request_hook(span: Span, instance: Connection, *args: Any, **kwargs: Any) ->
'db.system': 'redis',
'db.redis.database_index': 0,
'net.peer.name': 'localhost',
'net.peer.port': redis_port,
'net.peer.port': Is(redis_port),
'net.transport': 'ip_tcp',
'db.redis.args_length': 3,
'potato': 'tomato',
Expand Down
22 changes: 11 additions & 11 deletions tests/test_logfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import pytest
from dirty_equals import IsJson, IsStr
from inline_snapshot import snapshot
from inline_snapshot import Is, snapshot
from opentelemetry.proto.common.v1.common_pb2 import AnyValue
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
from opentelemetry.sdk.trace import ReadableSpan
Expand Down Expand Up @@ -1810,7 +1810,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 9,
'logfire.msg_template': 'log {GLOBAL_VAR} {local_var}',
'logfire.msg': f'log {GLOBAL_VAR} {local_var}',
'logfire.msg': Is(f'log {GLOBAL_VAR} {local_var}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -1831,7 +1831,7 @@ def foo():
'code.lineno': 123,
'local_var': 2,
'logfire.msg_template': 'span2 {local_var}',
'logfire.msg': f'span2 {local_var}',
'logfire.msg': Is(f'span2 {local_var}'),
'logfire.json_schema': '{"type":"object","properties":{"local_var":{}}}',
'logfire.span_type': 'span',
},
Expand All @@ -1846,7 +1846,7 @@ def foo():
'logfire.span_type': 'span',
'logfire.msg_template': 'span {GLOBAL_VAR} {local_var}',
'GLOBAL_VAR': 1,
'logfire.msg': f'span {GLOBAL_VAR} {local_var}',
'logfire.msg': Is(f'span {GLOBAL_VAR} {local_var}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand Down Expand Up @@ -1883,7 +1883,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 17,
'logfire.msg_template': 'log3 {GLOBAL_VAR}',
'logfire.msg': f'log3 {GLOBAL_VAR}',
'logfire.msg': Is(f'log3 {GLOBAL_VAR}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -1901,7 +1901,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 17,
'logfire.msg_template': 'log4 {GLOBAL_VAR}',
'logfire.msg': f'log4 {GLOBAL_VAR}',
'logfire.msg': Is(f'log4 {GLOBAL_VAR}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -1919,7 +1919,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 9,
'logfire.msg_template': 'log5 local_var = {local_var}',
'logfire.msg': f'log5 {local_var = }',
'logfire.msg': Is(f'log5 {local_var = }'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -1937,7 +1937,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 9,
'logfire.msg_template': 'log6 {x}',
'logfire.msg': f'log6 {x:.{local_var}f}',
'logfire.msg': Is(f'log6 {x:.{local_var}f}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -1955,7 +1955,7 @@ def foo():
'logfire.span_type': 'log',
'logfire.level_num': 9,
'logfire.msg_template': 'log7 {str(local_var)}',
'logfire.msg': f'log7 {str(local_var)!r}',
'logfire.msg': Is(f'log7 {str(local_var)!r}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand Down Expand Up @@ -2203,7 +2203,7 @@ def foo(): # pragma: no cover (coverage being weird)
'logfire.span_type': 'log',
'logfire.level_num': 9,
'logfire.msg_template': 'log {GLOBAL_VAR} {local_var}',
'logfire.msg': f'log {GLOBAL_VAR} {local_var}',
'logfire.msg': Is(f'log {GLOBAL_VAR} {local_var}'),
'code.filepath': 'test_logfire.py',
'code.function': 'foo',
'code.lineno': 123,
Expand All @@ -2225,7 +2225,7 @@ def foo(): # pragma: no cover (coverage being weird)
'GLOBAL_VAR': 1,
'local_var': 2,
'logfire.msg_template': 'span {GLOBAL_VAR} {local_var}',
'logfire.msg': f'span {GLOBAL_VAR} {local_var}',
'logfire.msg': Is(f'span {GLOBAL_VAR} {local_var}'),
'logfire.json_schema': '{"type":"object","properties":{"GLOBAL_VAR":{},"local_var":{}}}',
'logfire.span_type': 'span',
},
Expand Down
18 changes: 9 additions & 9 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import requests
from dirty_equals._numeric import IsInt
from inline_snapshot import snapshot
from inline_snapshot import Is, snapshot
from opentelemetry.metrics import CallbackOptions, Observation
from opentelemetry.sdk.metrics._internal.export import MetricExporter, MetricExportResult
from opentelemetry.sdk.metrics.export import AggregationTemporality, InMemoryMetricReader, MetricsData
Expand Down Expand Up @@ -49,10 +49,10 @@ def test_create_metric_counter(metrics_reader: InMemoryMetricReader) -> None:
'attributes': {},
'start_time_unix_nano': IsInt(),
'time_unix_nano': IsInt(),
'value': 300 + 4000,
'value': Is(300 + 4000),
}
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down Expand Up @@ -95,16 +95,16 @@ def test_create_metric_histogram(metrics_reader: InMemoryMetricReader) -> None:
'time_unix_nano': IsInt(),
'count': 2,
'sum': 4300,
'scale': scale,
'scale': Is(scale),
'zero_count': 0,
'positive': {'offset': offset, 'bucket_counts': bucket_counts},
'positive': {'offset': Is(offset), 'bucket_counts': Is(bucket_counts)},
'negative': {'offset': 0, 'bucket_counts': [0]},
'flags': 0,
'min': 300,
'max': 4000,
}
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
},
}
]
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_create_metric_up_down_counter(metrics_reader: InMemoryMetricReader) ->
'value': 4321,
}
],
'aggregation_temporality': AggregationTemporality.CUMULATIVE,
'aggregation_temporality': Is(AggregationTemporality.CUMULATIVE),
'is_monotonic': False,
},
}
Expand Down Expand Up @@ -227,7 +227,7 @@ def observable_counter(options: CallbackOptions):
'value': 4300,
}
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down Expand Up @@ -294,7 +294,7 @@ def observable_counter(options: CallbackOptions):
'value': 4321,
}
],
'aggregation_temporality': AggregationTemporality.CUMULATIVE,
'aggregation_temporality': Is(AggregationTemporality.CUMULATIVE),
'is_monotonic': False,
},
}
Expand Down
10 changes: 5 additions & 5 deletions tests/test_pydantic_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import cloudpickle
import pytest
from dirty_equals import IsInt
from inline_snapshot import snapshot
from inline_snapshot import Is, snapshot
from opentelemetry.sdk.metrics.export import AggregationTemporality, InMemoryMetricReader
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from pydantic import BaseModel, ConfigDict, ValidationError, field_validator
Expand Down Expand Up @@ -214,7 +214,7 @@ class MyModel(BaseModel, plugin_settings={'logfire': {'record': 'failure'}}):
'value': 1,
},
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down Expand Up @@ -266,7 +266,7 @@ class MyModel(BaseModel, plugin_settings={'logfire': {'record': 'metrics'}}):
'value': 2,
},
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down Expand Up @@ -327,7 +327,7 @@ class MyModel(BaseModel, plugin_settings={'logfire': {'record': 'all'}}):
'value': 1,
}
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down Expand Up @@ -412,7 +412,7 @@ class MyModel(BaseModel, plugin_settings={'logfire': {'record': 'failure'}}):
'value': 2,
}
],
'aggregation_temporality': AggregationTemporality.DELTA,
'aggregation_temporality': Is(AggregationTemporality.DELTA),
'is_monotonic': True,
},
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_source_code_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any

import pytest
from inline_snapshot import snapshot
from inline_snapshot import Is, snapshot

import logfire
from logfire._internal.formatter import InspectArgumentsFailedWarning
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_source_code_extraction_method(exporter: TestExporter) -> None:
'attributes': {
'code.filepath': 'tests/test_source_code_extraction.py',
'code.lineno': 21,
'code.function': code_function,
'code.function': Is(code_function),
'logfire.msg_template': 'from method',
'logfire.span_type': 'span',
'logfire.msg': 'from method',
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_source_code_extraction_nested(exporter: TestExporter) -> None:
'attributes': {
'code.filepath': 'tests/test_source_code_extraction.py',
'code.lineno': 29,
'code.function': code_function,
'code.function': Is(code_function),
'logfire.msg_template': 'hi!',
'logfire.span_type': 'span',
'logfire.msg': 'hi!',
Expand Down