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

Ability to access zipkin_context when using zipkin_span as a decorator #122

Open
jdb8 opened this issue Mar 9, 2019 · 0 comments
Open

Comments

@jdb8
Copy link
Member

jdb8 commented Mar 9, 2019

I like being able to use zipkin_span as a decorator, but it means that I currently can't use update_binary_annotations without converting it to a contextmanager, since I need access to the zipkin_context variable.

E.g. from the docs:

def some_function(a, b):
    with zipkin_span(
        service_name='my_service',
        span_name='some_function',
        transport_handler=some_handler,
        port=42,
        sample_rate=0.05,
    ) as zipkin_context:
        result = do_stuff(a, b)

        # Can add stuff here!
        zipkin_context.update_binary_annotations({'result': result})

vs.

@zipkin_span(
    service_name='my_service',
    span_name='some_function',
    transport_handler=some_handler,
    port=42,
    sample_rate=0.05,
)
def some_function(a, b):
    result = do_stuff(a, b)

    # No access to zipkin_context :(
    zipkin_context.update_binary_annotations({'result': result})

Perhaps a way to solve this would be to add a flag to zipkin_span such as inject_context, which would pass the zipkin_context object to the wrapped function? Then my some_function could receive it as a kwarg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant