File size: 1,047 Bytes
d8ad0fd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | from typing import Any, Dict, List, Optional
def build_trace_default_query(function_name: str) -> str:
return f'service(id(name: "{function_name}"))'
def build_put_annotations_input(**annotations: str) -> List[Dict]:
"""Create trace annotations input to be used with Tracer.put_annotation()
Parameters
----------
annotations : str
annotations in key=value form
Returns
-------
List[Dict]
List of put annotations input
"""
return [{"key": key, "value": value} for key, value in annotations.items()]
def build_put_metadata_input(namespace: Optional[str] = None, **metadata: Any) -> List[Dict]:
"""Create trace metadata input to be used with Tracer.put_metadata()
All metadata will be under `test` namespace
Parameters
----------
metadata : Any
metadata in key=value form
Returns
-------
List[Dict]
List of put metadata input
"""
return [{"key": key, "value": value, "namespace": namespace} for key, value in metadata.items()]
|