deep.api.tracepoint.trigger
Handlers for triggers and action configs.
FunctionLocation
Bases: Location
A location for a method entry/exit/capture point.
Source code in deep/api/tracepoint/trigger.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
id
property
The location id.
line
property
The method location always has a line of -1.
name: str
property
The name for this location.
For Method locations should be method name.
path
property
The source file path.
__eq__(__value)
__init__(path, function_name, position)
Create a new method location.
:param path: the source file path :param function_name: the function name :param position: the position
Source code in deep/api/tracepoint/trigger.py
__repr__()
__str__()
at_location(event, file, line, function_name, frame)
Check if we are at the location defined by this location.
:param event: the trigger event :param file: the file path :param line: the line number :param function_name: the method name :param frame: the triggering frame object :return: True, if we are at this location we expect, else False.
Source code in deep/api/tracepoint/trigger.py
LineLocation
Bases: Location
A location for a line entry/exit/capture point.
Source code in deep/api/tracepoint/trigger.py
id
property
The location id.
line
property
The line number.
name: str
property
The name for this location.
For line location should be the file#line number.
path
property
The source file path.
__eq__(__value)
__init__(path, line, position)
Create new line location.
:param path: the source file path :param line: the line number :param position: the position
Source code in deep/api/tracepoint/trigger.py
__repr__()
__str__()
at_location(event, file, line, function_name, frame)
Check if we are at the location defined by this location.
Line actions must always trigger on the line they define. So we do not look at the position here.
:param event: the trigger event :param file: the file path :param line: the line number :param function_name: the method name :param frame: the triggering frame object :return: True, if we are at this location we expect, else False.
Source code in deep/api/tracepoint/trigger.py
Location
Bases: ABC
A location is the line or method at which actions should be performed.
Source code in deep/api/tracepoint/trigger.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
id: str
abstractmethod
property
The location id.
line: int
abstractmethod
property
The line number.
name: str
abstractmethod
property
The name for this location.
For Method locations should be method name. For line location should be the file#line number.
path: str
abstractmethod
property
The source file path.
Position
Bases: Enum
Position lets the location be at the start, end or capture.
Source code in deep/api/tracepoint/trigger.py
from_stage(stage_)
classmethod
Get the stage enum from a string.
:param (str) stage_: the input string :return: the appropriate stage enum
Source code in deep/api/tracepoint/trigger.py
__init__(position=None)
at_location(event, file, line, function_name, frame)
abstractmethod
Check if we are at the location defined by this location.
:param event: the trigger event :param file: the file path :param line: the line number :param function_name: the function name :param frame: the triggering frame object :return: True, if we are at this location we expect, else False.
Source code in deep/api/tracepoint/trigger.py
LocationAction
Bases: object
This defines an action to perform. This action can be any action that is configured via a tracepoint.
Supported actions are
- snapshot: collect local variable data and stack frames at location
- log: evaluate a log message at the location
- metric: evaluate a metric and process via provider
- span: create a span at this location
Source code in deep/api/tracepoint/trigger.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
action_type: ActionType
property
Get the action type.
condition: Optional[str]
property
The condition that is set on the tracepoint.
:return: the condition if set
config: Dict[str, any]
property
The config for this action.
:return: the full action config.
fire_count
property
Get the allowed number of triggers.
:return: the configured number of triggers, or -1 for unlimited triggers
fire_period
property
Get the minimum amount of time that has to have elapsed before this can trigger again.
:return: the time in ms
id: str
property
The id of the tracepoint that created this action.
:return: the tracepoint id
location: Optional[Location]
property
Get the location config.
tracepoint: TracePointConfig
property
Get the tracepoint config for this trigger.
ActionType
Bases: Enum
The type of action.
Source code in deep/api/tracepoint/trigger.py
__repr__()
__eq__(__value)
Check if this is equal to another.
__init__(tp_id, condition, config, action_type)
Create a new location action.
:param tp_id: the tracepoint id :param condition: the condition :param config: the config :param action_type: the action type
Source code in deep/api/tracepoint/trigger.py
__repr__()
__str__()
can_trigger(ts)
Check if the tracepoint can trigger.
This is to check the config. e.g. fire count, fire windows etc. :param ts: the time the tracepoint has been triggered :return: true, if we should collect data; else false
Source code in deep/api/tracepoint/trigger.py
record_triggered(ts)
Record a fire.
Call this to record this tracepoint being triggered.
:param ts: the time in nanoseconds
with_location(location)
Attach the location to this action.
It is sometimes required to get the location information from an action. So we attach them here.
:param location: the location we are attached to. :return: self
Source code in deep/api/tracepoint/trigger.py
Trigger
Bases: Location
A trigger is a location with actions.
A trigger describes the location at which deep should take some actions.
A location is the combination of the file, line, function name, and position. Combining these we can add actions at the start or end of lines, or functions.
Source code in deep/api/tracepoint/trigger.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
actions: List[LocationAction]
property
The actions that are attached to this location.
id
property
The location id.
line
property
The line number.
name: str
property
The name for this location.
For Method locations should be method name. For line location should be the file#line number.
path
property
The source file path.
__eq__(__value)
__init__(location, actions)
Create new trigger.
:param location: the location :param actions: the actions
Source code in deep/api/tracepoint/trigger.py
__repr__()
__str__()
at_location(event, file, line, function_name, frame)
Check if we are at the location defined by this location.
:param event: the trigger event :param file: the file path :param line: the line number :param function_name: the method name :param frame: the triggering frame object :return: True, if we are at this location we expect, else False.
Source code in deep/api/tracepoint/trigger.py
build_log_action(tp_id, args)
Create a log action from the tracepoint arguments.
:param str tp_id: the tracepoint id :param Dict[str, str] args: the tracepoint arguments :return: the new action, or None
Source code in deep/api/tracepoint/trigger.py
build_metric_action(tp_id, args, metrics)
Create an action to create a metric.
:param tp_id: the tracepoint id :param args: the args :param metrics: the tracepoint metrics :return: the location action
Source code in deep/api/tracepoint/trigger.py
build_snapshot_action(tp_id, args, watches)
Create an action to create a snapshot.
:param tp_id: the tracepoint id :param args: the args :param watches: the watch expressions :return: the location action
Source code in deep/api/tracepoint/trigger.py
build_span_action(tp_id, args)
Create an action to create a span.
:param tp_id: the tracepoint id :param args: the args :return: the location action
Source code in deep/api/tracepoint/trigger.py
build_trigger(tp_id, path, line_no, args, watches, metrics)
Build a trigger definition.
:param tp_id: the tracepoint id :param path: the source file path :param line_no: the line number :param args: the tracepoint args :param watches: the watch configs :param metrics: the metric configs :return: the trigger with the actions.