Disable tracing

no
Summary: Learn options to disable or conditionally turn off W&B Weave tracing

Original Documentation

Documentation Index#

Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt Use this file to discover all available pages before exploring further.

Learn options to disable or conditionally turn off W&B Weave tracing

There are different options available to control the level of Weave tracing in your application, depending on your environment and needs.

Environment variable#

In situations where you want to unconditionally disable tracing for the entire program, you can set the environment variable WEAVE_DISABLED=true.

WEAVE_DISABLED is read only once, at function-definition time. This variable cannot be used to toggle tracing at runtime.

Client initialization#

Sometimes, you may want to conditionally enable tracing for a specific initialization based on some condition. In this case, you can initialize the client with the disabled flag in init settings.

    import weave

    # Initialize the client
    client = weave.init(..., settings={"disabled": True})
    ```
  <span class="tab-end"></span>

  <span class="tab-start" data-tab-title="TypeScript"></span>
```plaintext
    This feature is not available for the TypeScript SDK yet.
    ```
  <span class="tab-end"></span>
<span class="tab-group-end"></span>

## Context manager

To conditionally disable tracing for a specific block of code, you can use a tracing context manager. Use `with tracing_disabled()` to suppress tracing **only for the function calls executed inside the `with` block**. Use it in application code to scope which calls should not be logged.

<span class="tab-group-start"></span>
  <span class="tab-start" data-tab-title="Python"></span>
```python
    import weave
    from weave.trace.context.call_context import tracing_disabled

    client = weave.init('your-team/your-project-name')

    @weave.op
    def my_op():
        ...

    with tracing_disabled():
        my_op()
    ```
  <span class="tab-end"></span>

  <span class="tab-start" data-tab-title="TypeScript"></span>
```plaintext
    This feature is not available for the TypeScript SDK yet.
    ```
  <span class="tab-end"></span>
<span class="tab-group-end"></span>

Although tracing behavior is fixed when functions are defined, this can be used for runtime control when combined with application logic. For example, you can wrap the context manager in a conditional to dynamically enable or disable tracing based on a runtime value:

<span class="tab-group-start"></span>
  <span class="tab-start" data-tab-title="Python"></span>
```python
    if should_trace:
        my_op()
    else:
        with tracing_disabled():
            my_op()
    ```
  <span class="tab-end"></span>

  <span class="tab-start" data-tab-title="TypeScript"></span>
```plaintext
    This feature is not available for the TypeScript SDK yet.
    ```
  <span class="tab-end"></span>
<span class="tab-group-end"></span>
Link last verified June 7, 2026. View original ↗
Source: Weights & Biases Docs
Link last verified: 2026-04-05