#574·viztracer

absolute include file not working.

Author: HernandoRCreated Mar 17, 2025Updated May 9, 2025
Labelsneed repro

I made a custom decorator as follows:

python
from viztracer import trace_and_save as _trace_and_save

def trace_and_save(func=None):
    if os.environ.get("TRACER", None) is None:
        return func

    project_root = rootutils.autosetup()
    include_files=None
    # include_files = list(map(str, project_root.glob("src/**/*.py")))
    include_files =["src/"]
    # BUG: stops working when using absolute path
    include_files=[os.path.abspath(f) for f in include_files if not f.startswith("/")]


    output_dir = os.path.join(project_root, "output/profiles", func.__module__)
    if not Path(output_dir).exists():
        Path(output_dir).mkdir(parents=True)

    # return decorator with trace_and_save(output_dir=output_dir, include_files=include_files)

    return _trace_and_save(
        func,
        output_dir=output_dir,
        include_files=include_files,
        tracer_entries=2_000_000,
    )

behaviour:

  1. If we pass the relative path only, the viztracer recorded 56092 entries,
  2. If we pass the absolute path only, the viztracer recorded 2 entries, AKA nothing

expected behaviour:

If we pass the absolute path only, the viztracer records 56092 entries align with relative path calling.

debugs

In both experiments, the path was passed to https://github.com/gaogaotiantian/viztracer/blob/86775df01cb9b4ce57a8bf79b1598e806427949b/src/viztracer/viztracer.py#L71-L74

As to my understanding, this line is to appending abs path to the included files. Which means it should be equal to pass only the abs path.

I could not dig in more, since I didn't find where the self.include_files was used

Source: gaogaotiantian/viztracer