Skip to content

Commit

Permalink
Merge pull request #1 from c24t/propagator-javafication
Browse files Browse the repository at this point in the history
Make getter/setter types specific to context
  • Loading branch information
toumorokoshi authored Sep 18, 2019
2 parents 4e9f075 + d856f9d commit 1781bcd
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

import abc
import typing
from typing import Type, TypeVar

from opentelemetry.trace import SpanContext

Setter = typing.Callable[[object, str, str], None]
Getter = typing.Callable[[object, str], typing.List[str]]
_T = typing.TypeVar("_T")

Setter = typing.Callable[[Type[_T], str, str], None]
Getter = typing.Callable[[Type[_T], str], typing.List[str]]


class HTTPTextFormat(abc.ABC):
Expand Down Expand Up @@ -70,7 +73,7 @@ def example_route():

@abc.abstractmethod
def extract(
self, get_from_carrier: Getter, carrier: object
self, get_from_carrier: Getter[_T], carrier: _T
) -> SpanContext:
"""Create a SpanContext from values in the carrier.
Expand All @@ -93,7 +96,7 @@ def extract(

@abc.abstractmethod
def inject(
self, context: SpanContext, set_in_carrier: Setter, carrier: object
self, context: SpanContext, set_in_carrier: Setter[_T], carrier: _T
) -> None:
"""Inject values from a SpanContext into a carrier.
Expand Down

0 comments on commit 1781bcd

Please sign in to comment.