Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weave): Add 'tracing_sample_rate' param to weave.op #3195

Merged
merged 15 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading