Types of Metrics¤
Gauge
stores single numerical values which can go up and down. Implementsset
method to set the metric values.Counter
is a cumulative metric whose values can increase or decrease. Implementsadd
andsub
methods.- Event per Second Counter (
EPSCounter
) divides all values by delta time. DutyCycle
measures the fraction of a period in which a signal/system is active https://en.wikipedia.org/wiki/Duty_cycleAggregationCounter
allows toset
values based on an aggregation function.max
function is default.Histogram
represents cumulative histogram withset
method.
Counter
, AggregationCounter
, and Histogram
come also in variants
respecting dynamic tags. (See section Dynamic Tags)
asab.metrics.metrics.Gauge
¤
Bases: Metric
Source code in asab/metrics/metrics.py
set(name, value)
¤
The function sets a value for a given value name and updates the 'measured_at' field with the current time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the value to be set. |
required |
value
|
The value that you want to set for the given name in the field. |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.Counter
¤
Bases: Metric
Source code in asab/metrics/metrics.py
add(name, value, init_value=None)
¤
The add
function adds a specified value to a counter, and if the counter does not exist, it
creates it and initializes it with an optional initial value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Value name to which the |
required |
value
|
Value that needs to be added to the counter. It is the amount by which the counter will be incremented. |
required | |
init_value
|
dict
|
The |
None
|
Source code in asab/metrics/metrics.py
sub(name, value, init_value=None)
¤
The function subtracts a value from a variable and updates the 'measured_at' field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable or field that you want to subtract the value from. |
required |
value
|
Value that needs to be added to the counter. It is the amount by which the counter will be incremented. |
required | |
init_value
|
dict
|
The |
None
|
Source code in asab/metrics/metrics.py
asab.metrics.metrics.EPSCounter
¤
Bases: Counter
Event per Second Counter Divides the count of event by a time difference between measurements. It effectively produces the EPS metric. The type of the metric is an integer (int).
Source code in asab/metrics/metrics.py
asab.metrics.metrics.DutyCycle
¤
Bases: Metric
https://en.wikipedia.org/wiki/Duty_cycle
Source code in asab/metrics/metrics.py
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 229 230 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 |
|
set(name, on_off)
¤
The function set
updates the state of a variable, tracking the duration of on and off cycles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the value that you want to set. |
required |
on_off
|
bool
|
The |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.AggregationCounter
¤
Bases: Counter
Sets value aggregated with the last one.
Takes a function object as the aggregator
argument.
The aggregation function can take two arguments only.
Maximum is used as a default aggregation function.
Source code in asab/metrics/metrics.py
set(name, value)
¤
The function sets a value in a dictionary, updating it if the key already exists, and also updates a 'measured_at' field if a certain condition is met.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Name of the value being set. |
required | |
value
|
Value that you want to set for the given name. |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.Histogram
¤
Bases: Metric
Creates cumulative histograms.
Source code in asab/metrics/metrics.py
301 302 303 304 305 306 307 308 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 |
|
set(value_name, value)
¤
The function updates the values of the histogram based on the input value and value name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value_name
|
String that represents the name of the value being set. |
required | |
value
|
Value that needs to be set. |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.CounterWithDynamicTags
¤
Bases: MetricWithDynamicTags
Source code in asab/metrics/metrics.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 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 |
|
add(name, value, tags)
¤
The add
function adds a specified value to a counter, and if the counter does not exist, it
creates it and initializes it with an optional initial value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Value name to which the |
required |
value
|
Value that needs to be added to the counter. It is the amount by which the counter will be incremented. |
required | |
init_value
|
dict
|
The |
required |
tags
|
dict
|
Dynamic tags appliying to this value. |
required |
Source code in asab/metrics/metrics.py
sub(name, value, tags)
¤
The function subtracts a value from a variable and updates the 'measured_at' field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the variable or field that you want to subtract the value from. |
required |
value
|
Value that needs to be added to the counter. It is the amount by which the counter will be incremented. |
required | |
init_value
|
dict
|
The |
required |
tags
|
dict
|
Dynamic tags appliying to this value. |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.AggregationCounterWithDynamicTags
¤
Bases: CounterWithDynamicTags
Source code in asab/metrics/metrics.py
set(name, value, tags)
¤
The function sets a value for a given name and tags in a field, updates the measured_at and expires_at timestamps, and handles resetting the field if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
String that represents the name of the value being set. |
required |
value
|
Value that you want to set for a specific field. |
required | |
tags
|
dict
|
Dictionary of tags that are used to locate a specific field. |
required |
Source code in asab/metrics/metrics.py
asab.metrics.metrics.HistogramWithDynamicTags
¤
Bases: MetricWithDynamicTags
Creates cumulative histograms with dynamic tags
Source code in asab/metrics/metrics.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
|
set(value_name, value, tags)
¤
The function updates the values of the histogram based on the input value and value name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value_name
|
str
|
String that represents the name of the value being set. |
required |
value
|
Value that needs to be set. |
required | |
tags
|
dict
|
Dynamic tags appliying to this value. |
required |