open-telemetry / open-telemetry/opentelemetry-python-contrib
How to instrument multiple remote service as separate resources?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
Not specific to any version of python or OS or cloud provider.
Steps to reproduce
Using opentelemetry-instrument-redis to illustrate this problem.
setup:
- a python
flaskweb application that connects to 2 different Redis servers:redisAandredisB OTelsetup:- 1
ResourceandTraceProviderfor the web application:api_trace_provider. ("service.name"="my-api") - 1
ResourceandTraceProviderfor the redis:redis_trace_provider. ("service.name"="my-redis") - same processor(s) for the 2 trace providers
- set
api_tracer_provideras global trace provider:trace.set_tracer_provider(api_tracer_provider) - instrument
flaskapp:FlaskInstrumentor().instrument_app(app) - instrument
redislibrary:RedisInstrumentor().instrument(tracer_provider=redis_tracer_provider)
- 1
- web app set up:
redis_client_a = redis.StrictRedis(host=redisA_host, port=6379)redis_client_b = redis.StrictRedis(host=redisB_host, port=6379)
APIs in this application uses a combination of redis_client_a and redis_client_b
What is the expected behavior?
1 Resource per Redis client (instead of per Redis library)
and RedisInstrumentor instrument on the level of per-client instead of per library.
this way I can instrument different redis client with different Resources.
What is the actual behavior?
all redis traces are reported under my-redis Resource.
I would like to use 2 Resources: 1 for redisA and 1 for redisB but I can't figure out how that can be supported with current RedisInstrumentor from opentelemetry-instrument-redis
Additional context
Same problem for other instruments. e.g. if I instrument requests and uses requests for multiple services.
I may be wrong here, please feel free to correct me.
I'd be more than happy to be told that I was wrong and it's totally doable in current version. Thanks in advance!
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 with instrumentation/opentelemetry-instrumentation-redis and inspect how RedisInstrumentor accepts a tracer provider and applies it to clients. Compare the stated requests instrumentation case and determine whether per-client resources are supported by the instrumentation model. Done would require a decided, documented approach for assigning separate resources to multiple remote services.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python, redis
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100