Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getter/setter types specific to context #1

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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