Ejemplo n.º 1
0
def test_opentracing_extension_calls_custom_arg_filter(schema, mocker):
    arg_filter = mocker.Mock(return_value={})
    graphql(
        schema,
        {"query": '{ hello(name: "Bob") }'},
        extensions=[opentracing_extension(arg_filter=arg_filter)],
    )
    arg_filter.assert_called_once_with({"name": "Bob"}, ANY)
Ejemplo n.º 2
0
def test_opentracing_extension_sets_filtered_args_on_span(
        schema, active_span_mock, mocker):
    arg_filter = mocker.Mock(return_value={"name": "[filtered]"})
    graphql(
        schema,
        {"query": '{ hello(name: "Bob") }'},
        extensions=[opentracing_extension(arg_filter=arg_filter)],
    )

    span_mock = active_span_mock.__enter__.return_value.span
    span_mock.set_tag.assert_has_calls([
        call("component", "graphql"),
        call("graphql.parentType", "Query"),
        call("graphql.path", "hello"),
        call("graphql.param.name", "[filtered]"),
    ])
Ejemplo n.º 3
0
def app_with_tracing(schema):
    def dummy_filter(args, _):
        return args

    return GraphQL(schema,
                   extensions=[opentracing_extension(arg_filter=dummy_filter)])