Skip to content

Commit

Permalink
Merge branch 'master' into DOCS-1050
Browse files Browse the repository at this point in the history
  • Loading branch information
J2-D2-3PO authored Dec 13, 2024
2 parents aa0a8cd + c964e3f commit 9d6e961
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 88 deletions.
33 changes: 33 additions & 0 deletions docs/docs/guides/tracking/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,39 @@ 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.

Note that sampling rates are only applied to root calls. If an op has a sample rate, but is called by another op first, then that sampling rate will be ignored.

```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

0 comments on commit 9d6e961

Please sign in to comment.