The Fabasoft app.telemetry Python API was introduced in the Release 2026 August Release and allows you to instrument any Python application with instrumentation points to see what's going on in complex Python applications.
The Python API can be installed through the provided .whl file and pip. Afterwards, you can include the API in your Python application.
Import API |
|---|
from fabasoft.swtapipython.apm_const import APMConst |
All of the constants mentioned below are defined in the Python API file fabasoft.swtapipython.apm_const in the class “APMConst”. The environment configuration is defined in fabasoft.swtapipython.apm_sdk, in the class “APM” as a variable.
APMConst.version contains the version number of the Python API.
Example: print(APMConst.version) // => “26.0.1”
Flags are used to specify the type of an event and are passed as argument to every event call.
Name | Value | Description |
|---|---|---|
APMConst.FLAG_NONE | 0 | normal event |
APMConst.FLAG_ENTER | 1 | indicates a starting point |
APMConst.FLAG_LEAVE | 2 | indicates an ending point |
APMConst.FLAG_WAIT | 4 | indicates a wait condition |
APMConst.FLAG_WARNING | 8 | mark event as warning |
APMConst.FLAG_ERROR | 16 | mark event as error |
APMConst.FLAG_PROCESS_INFO | 32 | force writing SessionInfo just before the event |
An event will only be logged if the event-level is lower or equal to the value selected in the session or log-definition.
Name | Value | Description |
|---|---|---|
APMConst.EVENT_LEVEL_LOG | 0 | for events that should always be included and for logging parameters for the request overview |
APMConst.EVENT_LEVEL_NORMAL | 50 | for general events for normal recording sessions |
APMConst.EVENT_LEVEL_DETAIL | 60 | for detail level events for detailed session analysis |
APMConst.EVENT_LEVEL_DEBUG | 70 | event with debugging information - highest level of precision with huge data amount and performance impact |
The SDK already provides a set of predefined events used for general purpose. For a full listing of all available predefined events see the generic chapter Predefined Events.
All predefined events are declared and available as global constants in the Python class “APMConst”.
Error/Trace Events:
Use these standard events to mark error, warning or info conditions in your application:
View the language agnostic Application Values section for an explanation of the properties listed below.
All predefined application value keys and names are available as public constants in the Python class “APMConst”.
Some settings for the Python SDK are configured directly for the initialized APM class. When the APM class is instantiated as “apm”, the following can be set for “apm.env”:
Name | Default Value | Description |
|---|---|---|
apm.env.url | “web.telemetry” | The address to which the Python API posts its data. |
apm.env.active | True | With this Boolean value you can switch the Python API on or off |
apm.env.flush_interval | 60 (= 1 min) | Telemetry data cache flush interval (in s). |
apm.env.events_per_flush | 10000 | Number of telemetry events sent with each cache flush. |
apm.env.reregister_timeout | 600000 (= 10 min) | Interval (in µs) when synchronizing full registration information with agent/server. |
apm.env. | True | This setting allows to turn off the ssl verification for the connection to the “apm.env.url”. This is only needed, when the url has no trusted ssl certificate in the local . |
Besides setting the basic configuration variables (like apm.env.url) you can modify some parameters for your needs with the following setup functions described in the next sub chapters.
Call apm.flush to trigger immediately sending events to the Fabasoft app.telemetry WebAPI service.
Syntax |
|---|
apm.flush(self, send_all_events: bool = False) |
Parameters:
Return Value:
This function does not return any value.
Call this function once to provide information about the context of the application.
Syntax |
|---|
apm.register_application(app_name, app_id, app_tier_name, app_tier_id) |
Parameters:
Return Value:
This function does not return any value.
Remarks:
Usage Example |
|---|
apm.register_application("Software-Telemetry", "Demo", "Browser", "browser") |
Call register_application_value to register additional static information about your application such as the version number.
Syntax |
|---|
apm.register_application_value(value_key, value_name, value) |
Parameters:
Return Value:
This function does not return any value.
Call this function to register modules inside your application.
Syntax |
|---|
apm.register_module(module_name) |
Parameters:
Return Value:
Remarks:
Usage Example |
|---|
page = apm.register_module("Page") page.register_event(1, "ButtonClicked", "ArticleID") module2 = apm.register_module("AJAX Status") |
Call register_event on a registered module instance object to provide information about every event_id used for event tracing.
Syntax |
|---|
<module-instance>.register_event(event_id, description, parameter_description) |
Parameters:
Return Value:
This function does not return any value.
Remarks:
If an event has more than one parameter you need to separate the parameter_description with colons (,).
Usage Example |
|---|
module = apm.register_module("AJAX Request"); module.register_event(4, "RequestResult", "status;status Text"); |
Call apm.register_filter_value for each valid filter value.
Syntax |
|---|
apm.register_filter_value(value, description) |
Parameters:
Return Value:
This function does not return any value.
Usage Example |
|---|
apm.register_filter_value("Article ID", "Description for `Article ID` filter.") |
Call apm.create_context to create a new Software-Telemetry context. If the filter value matches a currently started session filter, logging is started for the current execution flow. Make sure to call apm.release_context when exiting the context.
Syntax |
|---|
apm.create_context(context_id, filter) |
Parameters:
Return Value:
Remarks:
Usage Example |
|---|
context_id = apm.create_context(None, "filter1") // ... proceed with application logic and fire events apm.release_context(context_id) |
Call apm.release_context to finish logging this request. Make sure to call apm.release_context for every request created with apm.create_context.
Syntax |
|---|
apm.release_context(context_id) |
Parameters:
Return Value:
This function does not return any value.
Remarks:
Usage Example |
|---|
context_id = apm.create_context(None, "filter") |
Call apm.get_context to get a context handle, which can be passed to another thread or process. This context information is used by the analysis components to track the control flow through the distributed environment.
The acquired context handle has to be submitted (either by transmitting over the network or in another way) to the thread/process being called which associates the calling thread with itself by passing the context to the apm.attach_context-method.
Syntax |
|---|
apm.get_context(context_id) |
Parameters:
Return Value:
Remarks:
Usage Example |
|---|
context_id = apm.create_context(None, "AJAX") // pass context_token to another function or another host //another function can use the token to asynchronously do some work apm.release_context(context_id) |
Call apm.attach_context to restore the context acquired through apm.get_context in another thread, process or execution flow.
Syntax |
|---|
apm.attach_context(context_id, token) |
Parameters:
Return Value:
Remarks:
Usage Example |
|---|
context_id = apm.attach_context(None, token) //proceed with application logic and fire events apm.release_context(context_id) |
Call apm.get_sync_mark to get a synchronization handle that can be passed to another thread or process to synchronize control flow.
Syntax |
|---|
apm.get_sync_mark(context_id) |
Parameters:
Return Value:
Remarks:
Usage Example |
|---|
context_id = apm.create_context(None, "Test") token = apm.get_sync_mark(context_id) |
Call apm.set_sync_mark to pass a synchronization handle you got from apm.get_sync_mark for synchronizing the sequence of events.
Syntax |
|---|
apm.set_sync_mark(context_id, token) |
Parameters:
Return Value:
This function does not return any value.
Remarks:
Usage Example |
|---|
// registration,... context = apm.create_context(None, "Test") token = apm.get_sync_mark(context) apm.set_sync_mark(context, token) module.event(context, 1, apm.LEVEL_DETAIL, apm.FLAG_NONE, "page loaded") //... apm.release_context(context) |
Call event to log events with any number of parameters.
Syntax |
|---|
<module-instance>.event(context_id, id, level, flags, params...) |
Parameters:
Return Value:
This function does not return any value.
Remarks:
Usage Example |
|---|
module = apm.register_module("AJAX Request") context = apm.create_context(None, "filter1") module.event(context, 7, apm.LEVEL_DEBUG, apm.FLAG_NONE, "param1", None, "param3", 4) apm.release_context(context) |
Call apm.report to create a new feedback report.
The filter value will be matched to the description using the registered filter values. Use the textual description of the feedback entered by the user or generated by the application to identify the report session later again.
Syntax |
|---|
apm.report(context_id, filter, report_key, description) |
Parameters:
Return Value:
This function does not return any value.
Usage Example |
|---|
import random module = apm.register_module("User Reaction") |
Call apm.report_value to add a key/value pair to an existing report.
Syntax |
|---|
apm.report_value(context_id, report_key, key, value) |
Parameters:
Return Value:
This function does not return any value.
Usage Example |
|---|
See “Method report (Python)“ |
Call apm.report_content to add content to an existing report.
Syntax |
|---|
apm.report_content(report_key, file_name, value, encoding, mime_type) |
Parameters:
Return Value:
This function does not return any value.
Usage Example |
|---|
module = apm.register_module("User Reaction") apm.report(context, "filter1", reportkey, "Example report_content") |
Remarks:
To allow applications to post random content, Fabasoft app.telemetry WebAPI supports posting content directly to the Fabasoft app.telemetry Web-API. Provide the report_key and the file_name as URL-parameters after the "?ReportContent" tag and the send the value as POST-data content.
Usage Example – ReportContent POST |
|---|
import requests from urlib.parse import quote url = apm.env.url + "?ReportContent" |
Call apm.has_active_context to test, if a software-telemetry session is active for some logging level. This information should be used to avoid costly operations preparing parameters for events that are currently not logged.
Syntax |
|---|
apm.has_active_context(context_id, level) |
Parameters:
Return Value:
Usage Example |
|---|
context = apm.create_context(None, "filter value") |
Call apm.is_connected to test, if the application has successfully registered to a Fabasoft app.telemetry agent/WebAPI. Your application must not make any assumptions based on the return value of this function as there are many reasons that may lead to a false being returned from this function even though the communication with the WebAPI be possible in general.
Syntax |
|---|
apm.is_connected() |
Parameters:
This function does not take any arguments.
Return Value:
Remarks:
Usage Example |
|---|
apm.register_application("Fabasoft app.telemetry", "", "Python", "") |