Skip to content

Commit

Permalink
Filter Root (not children) (#961)
Browse files Browse the repository at this point in the history
When sampling, don't randomly sample within a trace; sample whole traces
only.
  • Loading branch information
hinthornw authored Aug 31, 2024
1 parent 0e1c328 commit cb7fcf0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.1.48",
"version": "0.1.49",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "yarn@1.22.19",
"files": [
Expand Down
5 changes: 5 additions & 0 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ export class Client {
} else {
const sampled = [];
for (const run of runs) {
if (run.id !== run.trace_id) {
sampled.push(run);
this.sampledPostUuids.add(run.id);
continue;
}
if (Math.random() < this.tracingSampleRate) {
sampled.push(run);
this.sampledPostUuids.add(run.id);
Expand Down
2 changes: 1 addition & 1 deletion js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export type {
export { RunTree, type RunTreeConfig } from "./run_trees.js";

// Update using yarn bump-version
export const __version__ = "0.1.48";
export const __version__ = "0.1.49";
5 changes: 4 additions & 1 deletion python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,10 @@ def _filter_for_sampling(
else:
sampled = []
for run in runs:
if random.random() < self.tracing_sample_rate:
if (
run["id"] != run.get("trace_id")
or random.random() < self.tracing_sample_rate
):
sampled.append(run)
self._sampled_post_uuids.add(_as_uuid(run["id"]))
return sampled
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.1.107"
version = "0.1.108"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down

0 comments on commit cb7fcf0

Please sign in to comment.