Skip to content

Feature Request: Return mock object from get_tracer() when inactive #670

@aradzu10

Description

@aradzu10

Feature Request: Return mock object from get_tracer() when inactive

Details

When running without viztracer, viztracer.get_tracer() returns None. This causes crashes when instrumentation code is present in the application but the tracer is not active.

It should instead return a mock or no-op object so that code execution continues without AttributeError.

Example:
The following code currently crashes if viztracer is not running:

# AttributeError: 'NoneType' object has no attribute 'log_event'
with get_tracer().log_event("scope"):
    pass

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