Пример #1
0
def add_span_arg_tags(
    span,  # type: Span
    endpoint_name,  # type: str
    args,  # type: Tuple[Any]
    args_names,  # type: Tuple[str]
    args_traced,  # type: Set[str]
):
    # type: (...) -> None
    if endpoint_name not in EXCLUDED_ENDPOINT:
        tags = dict((name, value) for (name, value) in zip(args_names, args) if name in args_traced)
        flat_tags = flatten_dict(tags, exclude=EXCLUDED_ENDPOINT_TAGS.get(endpoint_name))
        span.set_tags({k: truncate_arg_value(v) for k, v in flat_tags.items()})
Пример #2
0
def test_flatten_dict_keys():
    """Ensure expected keys in flattened dictionary"""
    d = dict(A=1, B=2, C=dict(A=3, B=4, C=dict(A=5, B=6)))
    e = dict(A=1, B=2, C_A=3, C_B=4, C_C_A=5, C_C_B=6)
    assert trace_utils.flatten_dict(d, sep="_") == e
Пример #3
0
def test_flatten_dict_exclude():
    """Ensure expected keys in flattened dictionary with exclusion set"""
    d = dict(A=1, B=2, C=dict(A=3, B=4, C=dict(A=5, B=6)))
    e = dict(A=1, B=2, C_B=4)
    assert trace_utils.flatten_dict(d, sep="_", exclude={"C_A", "C_C"}) == e
Пример #4
0
def test_flatten_dict_is_flat(d):
    """Ensure that flattening of a nested dict results in a normalized, 1-level dict"""
    f = trace_utils.flatten_dict(d)
    assert isinstance(f, dict)
    assert not any(isinstance(v, dict) for v in f.values())