Skip to content

Commit 9ee2ef8

Browse files
committed
fix(masking): scope mask function to resources singleton
1 parent 864588e commit 9ee2ef8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

langfuse/_client/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ def __init__(
162162
):
163163
self._host = host or os.environ.get(LANGFUSE_HOST, "https://cloud.langfuse.com")
164164
self._environment = environment or os.environ.get(LANGFUSE_TRACING_ENVIRONMENT)
165-
self._mask = mask
166165
self._project_id = None
167166
sample_rate = sample_rate or float(os.environ.get(LANGFUSE_SAMPLE_RATE, 1.0))
168167
if not 0.0 <= sample_rate <= 1.0:
@@ -219,7 +218,9 @@ def __init__(
219218
httpx_client=httpx_client,
220219
media_upload_thread_count=media_upload_thread_count,
221220
sample_rate=sample_rate,
221+
mask=mask,
222222
)
223+
self._mask = self._resources.mask
223224

224225
self._otel_tracer = (
225226
self._resources.tracer

langfuse/_client/resource_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import os
1919
import threading
2020
from queue import Full, Queue
21-
from typing import Dict, Optional, cast, Any
21+
from typing import Any, Dict, Optional, cast
2222

2323
import httpx
2424
from opentelemetry import trace as otel_trace_api
@@ -43,6 +43,7 @@
4343
from langfuse._utils.request import LangfuseClient
4444
from langfuse.api.client import AsyncFernLangfuse, FernLangfuse
4545
from langfuse.logger import langfuse_logger
46+
from langfuse.types import MaskFunction
4647

4748
from ..version import __version__ as langfuse_version
4849

@@ -90,6 +91,7 @@ def __new__(
9091
httpx_client: Optional[httpx.Client] = None,
9192
media_upload_thread_count: Optional[int] = None,
9293
sample_rate: Optional[float] = None,
94+
mask: Optional[MaskFunction] = None,
9395
) -> "LangfuseResourceManager":
9496
if public_key in cls._instances:
9597
return cls._instances[public_key]
@@ -110,6 +112,7 @@ def __new__(
110112
httpx_client=httpx_client,
111113
media_upload_thread_count=media_upload_thread_count,
112114
sample_rate=sample_rate,
115+
mask=mask,
113116
)
114117

115118
cls._instances[public_key] = instance
@@ -130,8 +133,10 @@ def _initialize_instance(
130133
media_upload_thread_count: Optional[int] = None,
131134
httpx_client: Optional[httpx.Client] = None,
132135
sample_rate: Optional[float] = None,
136+
mask: Optional[MaskFunction] = None,
133137
):
134138
self.public_key = public_key
139+
self.mask = mask
135140

136141
# OTEL Tracer
137142
tracer_provider = _init_tracer_provider(

0 commit comments

Comments
 (0)