Conversation
Log a one-time warning at the export stage when mask is set without mask_otel_spans and exported spans carry input or output attributes from other OpenTelemetry instrumentations. The warning names attribute keys, never values, and does not change what is exported.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Log a one-time warning at the export stage when mask is set without mask_otel_spans and exported spans carry input or output attributes from other OpenTelemetry instrumentations. The warning names attribute keys, never values, and does not change what is exported.
What does this PR do?
Addresses langfuse/langfuse#15372 on the SDK side.
When
maskis configured andmask_otel_spansis not, spans from other OpenTelemetry instrumentations can be exported with raw input/output attributes (for exampleinput.valueorllm.input_messages.*), becausemaskonly runs when Langfuse SDK attributes are created. Today this happens silently.This PR logs a one-time warning at the export stage when that situation is detected. The warning names the attribute keys (never values) and points to
mask_otel_spans. What gets exported does not change.langfuse/langfuse#17509 adds a signal on the ingestion side. This is the client-side counterpart: it fires before the data leaves the process and is visible to the user who configured
mask.How it works:
LangfuseSpanProcessoracceptsmaskand passesmask_configuredtoLangfuseTransformingSpanExporter.LangfuseResourceManagerforwards the client'smask.mask_otel_spansis not set, the exporter checks for string attributes that the existing_media_field_for_attributemapping classifies as input or output, excludinglangfuse.*keys.langfuse-sdkscope, as @Allgoodok showed in the issue.Limitations: only keys already mapped as input/output are considered, to keep false positives low. The warning is logged once per exporter instance.
Type of change
Verification
List the main commands you ran:
uv run --frozen pytest tests/unit/test_mask_coverage_warning.py uv run --frozen pytest tests/unit/test_mask_otel_spans.py tests/unit/test_mask_coverage_warning.py tests/unit/test_resource_manager.py uv run --frozen pytest -n auto --dist worksteal tests/unit uv run --frozen ruff check . uv run --frozen ruff format --check langfuse/_client tests/unit/test_mask_coverage_warning.py uv run --frozen mypy langfuse --no-error-summarytest_prompt.py,test_prompt_atexit.pyandtest_serializer.py::test_pathreproduce identically on unmodifiedmainon Windows, and are unrelated to this change.Checklist
code_review.md..env.templateif needed.