Skip to content

Inconsistent documentation about HTTPPropagator usage #546

@yatishb

Description

@yatishb

The docs on injecting the context attributes for propagation of HTTP requests states that the inject() can be called on the HTTPPropagator class as follows:

def parent_call():
  with tracer.trace("parent_span") as span:
    headers = {}
    HTTPPropagator.inject(span.context, headers)
    url = "<some RPC endpoint>"
    r = requests.get(url, headers=headers)

When doing this, I get an error that the method HTTPPropagator.inject() requires an instance to be passed. Looking at the code, inject() is not a classmethod or a staticmethod, and the example should be updated to:

def parent_call():
  with tracer.trace("parent_span") as span:
    headers = {}
    propagator = HTTPPropagator()
    propagator.inject(span.context, headers)
    url = "<some RPC endpoint>"
    r = requests.get(url, headers=headers)

The same follows for the extract() method as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions