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

How to instrument multiple remote service as separate resources?

Open
#1,070 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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 flask web application that connects to 2 different Redis servers: redisA and redisB
  • OTel setup:
    • 1 Resource and TraceProvider for the web application:api_trace_provider. ("service.name"="my-api")
    • 1 Resource and TraceProvider for the redis:redis_trace_provider. ("service.name"="my-redis")
    • same processor(s) for the 2 trace providers
    • set api_tracer_provider as global trace provider: trace.set_tracer_provider(api_tracer_provider)
    • instrument flask app: FlaskInstrumentor().instrument_app(app)
    • instrument redis library: RedisInstrumentor().instrument(tracer_provider=redis_tracer_provider)
  • 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.