pip_services4_observability

Last updated:

0 purchases

pip_services4_observability Image
pip_services4_observability Images
Add to Cart

Description:

pip services4 observability

Observability Component definitions for Dart #
This module is a part of the Pip.Services polyglot microservices toolkit.
The Observability module contains observability component definitions that can be used to build applications and services.
The module contains the following packages:

Count - performance counters
Log - basic logging components that provide console and composite logging, as well as an interface for developing custom loggers
Trace - tracing components

Quick links:

Logging
Configuration
API Reference
Change Log
Get Help
Contribute
Examples

Use #
Add this to your package's pubspec.yaml file:
dependencies:
pip_services4_observability: version
copied to clipboard
Now you can install package from the command line:
pub get
copied to clipboard
Example how to use Logging and Performance counters.
Here we are going to use CompositeLogger and CompositeCounters components.
They will pass through calls to loggers and counters that are set in references.
import 'package:pip_services4_components/src/config/ConfigParams.dart';
import 'package:pip_services4_components/src/config/IConfigurable.dart';
import 'package:pip_services4_components/src/refer/IReferences.dart';
import 'package:pip_services4_components/src/refer/IReferenceable.dart';
import 'package:pip_services4_observability/src/log/CompositeLogger.dart';
import 'package:pip_services4_observability/src/count/CompositeCounters.dart';
import 'package:pip_services4_observability/src/count/Timing.dart';


class MyComponent implements IConfigurable, IReferenceable {
CompositeLogger _logger = CompositeLogger();
CompositeCounters _counters = CompositeCounters();

configure(ConfigParams config) {
this._logger.configure(config);
}

setReferences(IReferences refs) {
this._logger.setReferences(refs);
this._counters.setReferences(refs);
}

myMethod(IContext context, dynamic param1) {
try{
this._logger.trace(context, "Executed method mycomponent.mymethod");
this._counters.increment("mycomponent.mymethod.exec_count", 1);
Timing timing = this._counters.beginTiming("mycomponent.mymethod.exec_time");
....
timing.endTiming();
} catch(e) {
this._logger.error(context, e, "Failed to execute mycomponent.mymethod");
this._counters.increment("mycomponent.mymethod.error_count", 1);
}
}
}
copied to clipboard
Develop #
For development you shall install the following prerequisites:

Dart SDK 3
Visual Studio Code or another IDE of your choice
Docker

Install dependencies:
pub get
copied to clipboard
Run automated tests:
pub run test
copied to clipboard
Generate API documentation:
./docgen.ps1
copied to clipboard
Before committing changes run dockerized build and test as:
./build.ps1
./test.ps1
./clear.ps1
copied to clipboard
Contacts #
The library is created and maintained by Sergey Seroukhov and Levichev Dmitry.
The documentation is written by Egor Nuzhnykh, Alexey Dvoykin, Mark Makarychev, Levichev Dmitry.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.