Skip to content

refactor(telemetry): drop traceloop entity input/output and dead OpenInference mapping - #487

Open
LucasAlvesSoares wants to merge 2 commits into
mainfrom
drop-traceloop-inputoutput
Open

LucasAlvesSoares wants to merge 2 commits into
mainfrom
drop-traceloop-inputoutput

Conversation

@LucasAlvesSoares

@LucasAlvesSoares LucasAlvesSoares commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Disclaimer: Do not include SAP-internal or customer-specific information in this PR (e.g. internal system URLs, customer names, tenant IDs, or confidential configurations). This is a public repository.

Description

Reworks vendor-attribute handling in GenAIAttributeTransformer (src/sap_cloud_sdk/core/telemetry/genai_attribute_transformer.py). Replaces the hardcoded drop of traceloop.entity.input/traceloop.entity.output with an explicit class-level _DENY_LIST frozenset (exact-key, O(1), easy to extend), and removes the dead OpenInference llm.* handling — the _map_llm_usage method, the _LLM_USAGE_* constants, and the llm. trigger prefix. OpenInference is not a dependency and nothing in src/ emits llm.*; the active opentelemetry-instrumentation-langchain instrumentor already writes usage directly as gen_ai.usage.*, so that mapping was unreachable. The entity I/O blobs duplicated the payload already carried by gen_ai.input.messages/gen_ai.output.messages, so dropping them reduces span size and raw prompt/response exposure.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

  1. uv run pytest tests/core/unit/telemetry/test_genai_attribute_transformer.py — all pass (includes new test_normalize_attributes_drops_deny_listed_attributes and test_normalize_attributes_deny_list_uses_exact_keys).
  2. Construct a span carrying traceloop.entity.input, traceloop.entity.output, traceloop.entity.name, and traceloop.custom.foo; run it through GenAIAttributeTransformer.export(). Confirm entity.input/entity.output are dropped while entity.name and custom.foo are preserved (exact-key, not prefix).

Checklist

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have updated documentation (if applicable)
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

@LucasAlvesSoares LucasAlvesSoares left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: #487: refactor(telemetry): drop traceloop entity input/output and dead OpenInference mapping

Author: LucasAlvesSoares Branch: drop-traceloop-inputoutput → main
Verdict: ⚠️ Needs Minor Work
Summary: Clean, well-tested internal telemetry refactor; CI green and security-clean — only an unlinked issue and a non-Conventional first-commit subject remain, both non-blocking.


A: Process & Compliance

# Criterion Status Finding
A1 PR template complete ✅ Description, Type of Change (Code refactoring), How to Test, and full checklist present.
A2 Conventional Commits ✅ PR title refactor(telemetry): ... is compliant; Commit Validation CI passed. (First commit subject drop traceloop ... is non-Conventional, but squash-merge uses the PR title.)
A3 Issue linked ⚠️ No Closes #N in the body. Non-blocking, but AGENTS.md expects contributions to start from an accepted issue — link one if it exists.
A4 AI-generated code disclosure ➖ No explicit disclosure; apply the SAP GenAI contribution guideline if applicable.

B: Security & Sensitive Data

# Criterion Status Finding
B1 No sensitive data in code ✅ Only semconv attribute-key literals and fake test fixtures (gpt-4, session-123). Change removes raw entity I/O payloads from exported spans — net data-minimization gain.
B2 No sensitive data in PR body ✅ No internal URLs/tenant IDs/customer data.

C: Code Quality

# Criterion Status Finding
C1 CI checks passing ✅ Code Quality Checks, Tests & Coverage, Build & Package, Commit Validation, Check Version Bump, CodeQL, Analyze (python), REUSE, CLA all pass. Integration Tests pending at review time.
C2 Version bump ➖ No pyproject.toml change.
C3 Type hints ✅ Touched helpers retain full annotations; _DENY_LIST: frozenset literal is clear.
C4 No hardcoded values ✅ Denied keys centralized in class-level _DENY_LIST frozenset (genai_attribute_transformer.py:38), improving on the prior scattered constants.
C5 Import organization ✅ No import changes in source.
C6 Naming conventions ✅ _DENY_LIST private + SCREAMING_SNAKE; snake_case files.
C7 No unused code ✅ Dead OpenInference path (_map_llm_usage, _LLM_USAGE_*, _OPENINFERENCE_PREFIX, llm. trigger) fully removed; no dangling refs. Earlier orphaned-test issue resolved in commit 3106d13 — test_normalize_attributes_skips_non_genai_spans is a proper def (test file:165) with its docstring at :166.
C8 New dependencies ➖ None added.
C9 Proto freshness ➖ No proto changes.

D: API & Design

# Criterion Status Finding
D1 API future-proofing ✅ Internal exporter wrapper; no public config surface touched.
D2 Public API hygiene ✅ All touched symbols _-private; nothing in __all__ changed.
D3 Breaking changes marked ✅ _map_llm_usage was private — no public-API break. Exported-span attributes do change (no traceloop.entity.input/output; no llm.usage.*→gen_ai.usage.* mapping), but the mapping was dead against current instrumentation. Documented under Additional Notes for downstream dashboard owners. Not a code-level breaking change.
D4 Pagination & tenant filtering ➖ N/A.
D5 Telemetry instrumentation ➖ This is telemetry infra, not a client method; no @record_metrics applicable.
D6 Multi-tenancy support ➖ N/A — core telemetry, not a service module.

E: Tests & Documentation

# Criterion Status Finding
E1 Tests added/updated ✅ New _DENY_LIST behaviour covered by test_normalize_attributes_drops_deny_listed_attributes (:116) and test_normalize_attributes_deny_list_uses_exact_keys (:135, asserts exact-key, not prefix). Non-GenAI-skip path restored (:165). Obsolete llm.* tests removed; suite passes.
E2 Documentation quality ✅ Module + class docstrings rewritten to describe Traceloop normalization / vendor-attribute dropping; no stale OpenInference claims. No user-guide reference to the changed keys exists, so none needs updating.
E2a Multi-tenancy documentation ➖ N/A — no user-guide.md for core telemetry.
E3 Module structure compliance ➖ Not a new module.

❌ Blocking Issues

None.

⚠️ Non-Blocking Suggestions

  • [A3] Link the tracked issue (Closes #N) if one exists.
  • [A2] First commit subject drop traceloop input and output and openinference normalization isn't Conventional — harmless under squash-merge (PR title governs) and Commit Validation passed, but worth tidying if the branch history is kept.
  • [D3] Keep the "exported-telemetry change" note visible for downstream dashboard/query owners (entity.input/output dropped; llm.usage.* mapping gone).

✅ Things Done Well

  • Source is clean: entire dead OpenInference path removed with no dangling references; ty and the unit suite pass.
  • _DENY_LIST as a class-level frozenset is the right pattern — centralized, immutable, O(1) membership, exact-key (not greedy prefix) matching, with a dedicated test proving sibling/custom keys are preserved.
  • Net privacy improvement: raw traceloop.entity.input/output payload blobs no longer exported.
  • Docstrings updated to match actual behaviour.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant