Skip to content

Commit

Permalink
Correlation context docs (#490)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Boten <aboten@lightstep.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 18, 2020
1 parent 4e551ba commit b615804
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ OpenTelemetry Python API

configuration
context
correlationcontext
metrics
trace
7 changes: 7 additions & 0 deletions docs/api/correlationcontext.propagation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.correlationcontext.propagation package
====================================================

Module contents
---------------

.. automodule:: opentelemetry.correlationcontext.propagation
14 changes: 14 additions & 0 deletions docs/api/correlationcontext.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
opentelemetry.correlationcontext package
========================================

Subpackages
-----------

.. toctree::

correlationcontext.propagation

Module contents
---------------

.. automodule:: opentelemetry.correlationcontext
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import abc
import typing

from opentelemetry.context import get_value, set_value
Expand All @@ -24,7 +23,7 @@
def get_correlations(
context: typing.Optional[Context] = None,
) -> typing.Dict[str, object]:
""" Returns the name/value pairs in the CorrelationContext
"""Returns the name/value pairs in the CorrelationContext
Args:
context: The Context to use. If not set, uses current Context
Expand All @@ -41,7 +40,8 @@ def get_correlations(
def get_correlation(
name: str, context: typing.Optional[Context] = None
) -> typing.Optional[object]:
""" Provides access to the value for a name/value pair in the CorrelationContext
"""Provides access to the value for a name/value pair in the
CorrelationContext
Args:
name: The name of the value to retrieve
Expand Down Expand Up @@ -76,6 +76,7 @@ def remove_correlation(
name: str, context: typing.Optional[Context] = None
) -> Context:
"""Removes a value from the CorrelationContext
Args:
name: The name of the value to remove
context: The Context to use. If not set, uses current Context
Expand All @@ -91,6 +92,7 @@ def remove_correlation(

def clear_correlations(context: typing.Optional[Context] = None) -> Context:
"""Removes all values from the CorrelationContext
Args:
context: The Context to use. If not set, uses current Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import re
import typing
import urllib.parse

Expand All @@ -36,9 +35,10 @@ def extract(
carrier: httptextformat.HTTPTextFormatT,
context: typing.Optional[Context] = None,
) -> Context:
""" Extract CorrelationContext from the carrier.
"""Extract CorrelationContext from the carrier.
See `opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.extract`
See
`opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.extract`
"""

if context is None:
Expand Down Expand Up @@ -79,7 +79,8 @@ def inject(
) -> None:
"""Injects CorrelationContext into the carrier.
See `opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.inject`
See
`opentelemetry.trace.propagation.httptextformat.HTTPTextFormat.inject`
"""
correlations = correlationcontext.get_correlations(context=context)
if not correlations:
Expand Down

0 comments on commit b615804

Please sign in to comment.