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

Make span attributes json parseable for celery

Open
#3,169 0 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

OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.8.10)
Package version: (e.g., 0.46.0)

What happened?

Currently, the "delivery_info" attribute in celery is a string and not a map (or even a json).
The attribute is transformed into a string, which makes it hard to parse, and one has to use regex instead.

Steps to Reproduce

Run the celery instrumentation application from https://github.com/shivanshuraj1333/celery-opentelemetry-instrumentation/

Expected Result

attribute name: celetry.delivery_info

option 1: return a python dict

{
    'exchange': '',
    'routing_key': 'queue2',
    'priority': 0,
    'redelivered': False
}

option 2: return a valid json

{
  "exchange": "",
  "routing_key": "queue2",
  "priority": 0,
  "redelivered": false
}

A dict is supported by semconv and proto message https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto#L37

Also, the unmarshalling is already supported, see.

So, let's go for having option 1 makes sense, since, it helps in extracting the keys from map values of an attribute

Actual Result

attribute name: celetry.delivery_info
value: {'exchange': '', 'routing_key': 'queue2', 'priority': 0, 'redelivered': False}

Additional context

No response

Would you like to implement a fix?

None

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 the Celery instrumentation application linked in the reproduction steps and trace where the delivery_info span attribute is created. Compare its current value with the OpenTelemetry common.proto attribute map and the exporter unmarshalling code linked in the issue; done means delivery_info is emitted as a map that preserves its keys and value types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.