Skip to content

Commit f313854

Browse files
committed
feat: add log sampling to langchain
1 parent 20d25e7 commit f313854

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

parea/utils/trace_integrations/langchain.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class PareaAILangchainTracer(BaseTracer):
2424
_metadata: Dict[str, Any] = {}
2525
_end_user_identifier: Optional[str] = None
2626
_deployment_id: Optional[str] = None
27+
_log_sample_rate: Optional[float] = 1.0,
2728

2829
def __init__(
2930
self,
@@ -32,12 +33,14 @@ def __init__(
3233
metadata: Optional[Dict[str, Any]] = None,
3334
end_user_identifier: Optional[str] = None,
3435
deployment_id: Optional[str] = None,
36+
log_sample_rate: Optional[float] = 1.0,
3537
**kwargs: Any,
3638
):
3739
super().__init__(**kwargs)
3840
self._session_id = session_id
3941
self._end_user_identifier = end_user_identifier
4042
self._deployment_id = deployment_id
43+
self._log_sample_rate = log_sample_rate
4144
if tags:
4245
self._tags = tags
4346
if metadata:
@@ -56,6 +59,7 @@ def _persist_run(self, run: Union[Run, LLMRun, ChainRun, ToolRun]) -> None:
5659
data["_metadata"] = self._metadata
5760
data["_end_user_identifier"] = self._end_user_identifier
5861
data["_deployment_id"] = self._deployment_id
62+
data["_log_sample_rate"] = self._log_sample_rate
5963
# check if run has an attribute execution order
6064
if (hasattr(run, "execution_order") and run.execution_order == 1) or run.parent_run_id is None:
6165
data["_parea_parent_trace_id"] = self._parea_parent_trace_id or None

0 commit comments

Comments
 (0)