Skip to content

Commit

Permalink
add docs for sampling rate
Browse files Browse the repository at this point in the history
  • Loading branch information
adrnswanberg committed Dec 12, 2024
1 parent ff01b4b commit 70b2c26
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/docs/guides/tracking/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,37 @@ A Weave op is a versioned function that automatically logs all calls.
</TabItem>
</Tabs>

## Control sampling rate

<Tabs groupId="programming-language">
<TabItem value="python" label="Python" default>
You can control how frequently an op's calls are traced by setting the `tracing_sample_rate` parameter in the `@weave.op` decorator. This is useful for high-frequency ops where you only need to trace a subset of calls.

```python
@weave.op(tracing_sample_rate=0.1) # Only trace ~10% of calls
def high_frequency_op(x: int) -> int:
return x + 1

@weave.op(tracing_sample_rate=1.0) # Always trace (default)
def always_traced_op(x: int) -> int:
return x + 1
```

When an op's call is not sampled:
- The function executes normally
- No trace data is sent to Weave
- Child ops are also not traced for that call

The sampling rate must be between 0.0 and 1.0 inclusive.

</TabItem>
<TabItem value="typescript" label="TypeScript">
```plaintext
This feature is not available in TypeScript yet. Stay tuned!
```
</TabItem>
</Tabs>

### Control call link output

If you want to suppress the printing of call links during logging, you can use the `WEAVE_PRINT_CALL_LINK` environment variable to `false`. This can be useful if you want to reduce output verbosity and reduce clutter in your logs.
Expand Down

0 comments on commit 70b2c26

Please sign in to comment.