Monitoring System ExampleΒΆ
This guide provides a professional, step-by-step walkthrough for using the MonitoringSystem in the agenticaiframework package to log events and record metrics. It is intended for developers who want to track agent activities, performance, and operational metrics in real-time.
Enterprise Observability
Part of 237 enterprise modules with 16 observability modules including distributed tracing, APM integration, and real-time dashboards.
Prerequisites & ConfigurationΒΆ
- Installation: Ensure
agenticaiframeworkis installed and accessible in your Python environment. - No additional configuration is required for this example.
- Python Version: Compatible with Python 3.10+.
CodeΒΆ
Step-by-Step ExecutionΒΆ
-
Import the Class Import
MonitoringSystemfromagenticaiframework.monitoring. -
Instantiate the Monitoring System Create an instance of
MonitoringSystemto manage event logging and metric recording. -
Log Events Use
log_eventto record significant occurrences, passing: event_type: A string describing the event.-
details: A dictionary with event-specific data. -
Record Metrics Use
record_metricto store performance or operational metrics, passing: metric_name: The name of the metric.-
value: The metric's value. -
Inspect Logged Data Access
eventsandmetricsattributes to review stored information.
Best Practice: Use consistent naming conventions for events and metrics to simplify analysis and reporting.
Expected InputΒΆ
No user input is required; the script uses hardcoded values for demonstration purposes. In production, events and metrics could be generated dynamically from agent activities, API calls, or system monitoring hooks.
Expected OutputΒΆ
How to RunΒΆ
Run the example from the project root:
| Bash | |
|---|---|
If installed as a package, you can also run it from anywhere:
| Bash | |
|---|---|
Tip: Integrate
MonitoringSysteminto your agents to automatically log key lifecycle events and performance metrics.