Files
signoz/tests/conftest.py
Nikhil Soni a6346183e8 feat(traces-qb): read span attributes from the JSON column (evolution-gated) (#12715)
#### Description

Enables the v5 traces query builder to read span attributes from the
native `attributes` `JSON(max_dynamic_paths=0)` column, alongside the
legacy `attributes_string/number/bool` maps, which will get deprecated
over time once the dual ingestion can be stopped.

- **Evolution-gated rollout.** A key resolves to the JSON column only
once its column-evolution set names `attributes`; with no such entry it
resolves to the Map column exactly as before.
- **Negative operators** - In currently live system, records with
missing keys for number/bool types are included in the negative operator
queries while string data type is not included. So we are preserving the
same be
- Data-type-unspecified attribute keys keep the existing
`CandidateKeys`/synthesis path (no branch-flip of the most common query
shape) - will be fixed in
https://github.com/SigNoz/engineering-pod/issues/6018

Part of https://github.com/SigNoz/engineering-pod/issues/5878 

#### Additional Information

First of a stacked series. Using json in span listing and other module
like waterfall, flamegraph will be follow up changes tracked in
https://github.com/SigNoz/engineering-pod/issues/5967

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-10 14:38:08 +00:00

120 lines
4.0 KiB
Python

import subprocess
import pytest
pytest_plugins = [
"fixtures.auth",
"fixtures.clickhouse",
"fixtures.fs",
"fixtures.http",
"fixtures.migrator",
"fixtures.network",
"fixtures.postgres",
"fixtures.sql",
"fixtures.sqlite",
"fixtures.keeper",
"fixtures.signoz",
"fixtures.audit",
"fixtures.logs",
"fixtures.traces",
"fixtures.metrics",
"fixtures.queriercommon",
"fixtures.semconvfamilies",
"fixtures.metadata",
"fixtures.meter",
"fixtures.browser",
"fixtures.keycloak",
"fixtures.idp",
"fixtures.googleidp",
"fixtures.tls",
"fixtures.notification_channel",
"fixtures.maildev",
"fixtures.alerts",
"fixtures.cloudintegrations",
"fixtures.jsontypes",
"fixtures.seeder",
"fixtures.serviceaccount",
"fixtures.role",
"fixtures.savedview",
"fixtures.seed_golden_dataset",
]
def pytest_configure(config: pytest.Config):
if config.getoption("--rebuild"):
if not config.getoption("--reuse"):
raise pytest.UsageError("--rebuild requires --reuse: it replaces the signoz container within an environment that is being reused.")
if config.getoption("--teardown"):
raise pytest.UsageError("--rebuild cannot be combined with --teardown.")
if config.getoption("--clean"):
raise pytest.UsageError("--rebuild cannot be combined with --clean: --clean forces a cold build, which defeats the purpose of --rebuild.")
def pytest_sessionstart(session: pytest.Session):
if session.config.getoption("--clean"):
# The type filter removes only cache mounts, leaving images and layer cache intact.
subprocess.run(["docker", "builder", "prune", "--force", "--filter", "type=exec.cachemount"], check=True)
def pytest_addoption(parser: pytest.Parser):
parser.addoption(
"--reuse",
action="store_true",
default=False,
help="Reuse environment. Use pytest --basetemp=./tmp/ -vv --reuse src/bootstrap/setup::test_setup to setup your local dev environment for writing tests.",
)
parser.addoption(
"--teardown",
action="store_true",
default=False,
help="Teardown environment. Run pytest --basetemp=./tmp/ -vv --teardown src/bootstrap/setup::test_teardown to teardown your local dev environment.",
)
parser.addoption(
"--rebuild",
action="store_true",
default=False,
help="Rebuild the signoz container from the current sources while reusing the rest of the stack (databases, mocks, migrations). Only meaningful together with --reuse: pytest --basetemp=./tmp/ -vv --reuse --rebuild integration/bootstrap/setup.py::test_setup.",
)
parser.addoption(
"--clean",
action="store_true",
default=False,
help="Prune the BuildKit cache mounts (go build and module caches) used by the signoz image build, forcing the next build to start cold. Combine with --teardown to reset everything: pytest --basetemp=./tmp/ -vv --teardown --clean integration/bootstrap/setup.py::test_teardown.",
)
parser.addoption(
"--with-web",
action="store_true",
default=False,
help="Build and run with web. Run pytest --basetemp=./tmp/ -vv --with-web src/bootstrap/setup::test_setup to setup your local dev environment with web.",
)
parser.addoption(
"--sqlstore-provider",
action="store",
default="postgres",
help="sqlstore provider",
)
parser.addoption(
"--sqlite-mode",
action="store",
default="delete",
help="sqlite mode",
)
parser.addoption(
"--postgres-version",
action="store",
default="15",
help="postgres version",
)
parser.addoption(
"--clickhouse-version",
action="store",
default="25.12.5",
help="clickhouse version",
)
parser.addoption(
"--schema-migrator-version",
action="store",
default="v0.144.9", # todo(nikhil): change to 0.144.10
help="schema migrator version",
)