1414 or:
1515 export SCRAPEGRAPHAI_TELEMETRY_ENABLED=false
1616"""
17-
1817import configparser
1918import functools
2019import importlib .metadata
@@ -68,14 +67,16 @@ def _check_config_and_environ_for_telemetry_flag(
6867 try :
6968 telemetry_enabled = config_obj .getboolean ("DEFAULT" , "telemetry_enabled" )
7069 except ValueError as e :
71- logger .debug (f"Unable to parse value for `telemetry_enabled` from config. Encountered { e } " )
70+ logger .debug (f"""Unable to parse value for
71+ `telemetry_enabled` from config. Encountered { e } """ )
7272 if os .environ .get ("SCRAPEGRAPHAI_TELEMETRY_ENABLED" ) is not None :
7373 env_value = os .environ .get ("SCRAPEGRAPHAI_TELEMETRY_ENABLED" )
7474 config_obj ["DEFAULT" ]["telemetry_enabled" ] = env_value
7575 try :
7676 telemetry_enabled = config_obj .getboolean ("DEFAULT" , "telemetry_enabled" )
7777 except ValueError as e :
78- logger .debug (f"Unable to parse value for `SCRAPEGRAPHAI_TELEMETRY_ENABLED` from environment. Encountered { e } " )
78+ logger .debug (f"""Unable to parse value for `SCRAPEGRAPHAI_TELEMETRY_ENABLED`
79+ from environment. Encountered { e } """ )
7980 return telemetry_enabled
8081
8182
@@ -94,15 +95,13 @@ def _check_config_and_environ_for_telemetry_flag(
9495 "telemetry_version" : "0.0.3" ,
9596}
9697
97-
9898def disable_telemetry ():
9999 """
100100 function for disabling the telemetries
101101 """
102102 global g_telemetry_enabled
103103 g_telemetry_enabled = False
104104
105-
106105def is_telemetry_enabled () -> bool :
107106 """
108107 function for checking if a telemetry is enables
@@ -122,7 +121,6 @@ def is_telemetry_enabled() -> bool:
122121 else :
123122 return False
124123
125-
126124def _send_event_json (event_json : dict ):
127125 headers = {
128126 "Content-Type" : "application/json" ,
@@ -141,7 +139,6 @@ def _send_event_json(event_json: dict):
141139 else :
142140 logger .debug (f"Telemetry data sent: { data } " )
143141
144-
145142def send_event_json (event_json : dict ):
146143 """
147144 fucntion for sending event json
@@ -154,7 +151,6 @@ def send_event_json(event_json: dict):
154151 except Exception as e :
155152 logger .debug (f"Failed to send telemetry data in a thread: { e } " )
156153
157-
158154def log_event (event : str , properties : Dict [str , any ]):
159155 """
160156 function for logging the events
@@ -167,7 +163,6 @@ def log_event(event: str, properties: Dict[str, any]):
167163 }
168164 send_event_json (event_json )
169165
170-
171166def log_graph_execution (graph_name : str , source : str , prompt :str , schema :dict ,
172167 llm_model : str , embedder_model : str , source_type : str ,
173168 execution_time : float , content : str = None , response : dict = None ,
@@ -193,8 +188,10 @@ def log_graph_execution(graph_name: str, source: str, prompt:str, schema:dict,
193188 }
194189 log_event ("graph_execution" , properties )
195190
196-
197191def capture_function_usage (call_fn : Callable ) -> Callable :
192+ """
193+ function that captures the usage
194+ """
198195 @functools .wraps (call_fn )
199196 def wrapped_fn (* args , ** kwargs ):
200197 try :
0 commit comments