open-telemetry / open-telemetry/opentelemetry-python-contrib

Add an additional keyword arg to RedisInstrumentor.intrument to ignore root spans 🌈 🙏

Open
#1,164 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Hello everyone, I'm new to the OTEL community (and python 🌈 ( and writing github issues)).

I've been trying to instrument a python app with the RedisInstrumentor.

I have an issue with noisy redis spans in my collector. Ideally, I don't want to collect any spans without a parent_id attached.

It would be neat to be able to pass an additional keyword arg (something along the lines of trace_root_span) so that when the instrument method is called, it breaks out early and does not process any span where span.parent is None.

eg: RedisInstrumentor().instrument(request_hook=request_hook, response_hook=response_hook, trace_root_span: false)

I saw this neat configuration option in the ruby redis instrumentation which ignores spans without a parent id.

I thought I would be able to use the response_hook to ignore spans without a parent but I still saw spans in my collector as the response is returned here.

Additional context
I may be missing something obvious and happy to close the issue (or try open a PR) if there is a way to do this via a response_hook 👍

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/init.py around the span handling near line 159, and inspect how RedisInstrumentor.instrument processes its keyword arguments. Confirm the desired behavior for spans whose parent is None, then add coverage showing that the option suppresses root spans while retaining child spans.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, redis
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.