Skip to content

Parametrized tests should use same span name #41

@sk-

Description

@sk-

Currently the span name for parametrized tests include the attributes. This means that the spans are different and won't be grouped in views like the flamegraph.

Using the test file below

import time
from collections.abc import Iterator

import pytest


@pytest.fixture(scope="session", autouse=True)
def session_fixture() -> Iterator[None]:
    time.sleep(2)
    yield
    time.sleep(2)


@pytest.fixture(scope="module", autouse=True)
def module_fixture() -> Iterator[None]:
    time.sleep(1)
    yield
    time.sleep(1)


@pytest.fixture
def function_fixture() -> Iterator[None]:
    time.sleep(0.5)
    yield
    time.sleep(0.5)


@pytest.mark.parametrize("header", ["without bearer", "bearer ", "bearer not_found"])
def test_parametrized(header: str, function_fixture: None) -> None:
    assert header
    time.sleep(1)

We can see that the tree tests have different span names and are not grouped
Image

However, it would be useful to have the same span name so that one can know the total time that specific test is taking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions