open-telemetry / open-telemetry/opentelemetry-python
Give a warning whenever span attribute was truncated
Open
Nobody has claimed this yet.
feature-request
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Is your feature request related to a problem?
I'd like my app's users to be informed whenever their span is truncated. Currently there's no warning being logged in Otel.
opentelemetry/attributes/__init__.py
Describe the solution you'd like
I'd like this method to log a warning whenever span attribute is truncated due to limitation:
def _clean_attribute_value(
value: types.AttributeValue, limit: Optional[int]
) -> Optional[types.AttributeValue]:
if value is None:
return None
if isinstance(value, bytes):
try:
value = value.decode()
except UnicodeDecodeError:
_logger.warning("Byte attribute could not be decoded.")
return None
if limit is not None and isinstance(value, str):
value = value[:limit]
return value
Describe alternatives you've considered
No response
Additional Context
No response
Would you like to implement a fix?
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in opentelemetry/attributes/init.py at _clean_attribute_value and inspect how the existing byte-decoding warning is handled. Add a warning for string values truncated by the limit, then verify that truncation emits the warning while unaffected values do not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100