-
Notifications
You must be signed in to change notification settings - Fork 120
WIP core:services/libs: Add standard events #3695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
joaomariolago
wants to merge
2
commits into
bluerobotics:master
Choose a base branch
from
joaomariolago:add-standard-services-log-events
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WIP core:services/libs: Add standard events #3695
joaomariolago
wants to merge
2
commits into
bluerobotics:master
from
joaomariolago:add-standard-services-log-events
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reviewer's GuideIntroduce a reusable event publishing utility that emits structured Foxglove events over Zenoh, integrate it with logging and settings managers, and instrument core services to emit standardized lifecycle and health events, while slightly relaxing MAVLinkServer log-path requirements and updating some defaults. Sequence diagram for service lifecycle and health eventssequenceDiagram
actor ServiceProcess
participant LogsModule as logs
participant EventPublisher as events
participant ZenohSession
participant ZenohSessionImpl as zenohSession
ServiceProcess->>logs: init_logger(service_name)
logs->>events: initialize(service_name)
events->>ProcessName as process_utils: get_process_name()
ProcessName-->>events: process_name
events->>ZenohSession: ZenohSession(service_name)
ZenohSession-->>events: instance
events->>ZenohSessionImpl: create zenoh.Session
ZenohSessionImpl-->>ZenohSession: session
ServiceProcess->>events: publish_start()
events->>events: _timestamp_payload()
events->>ZenohSession: format_source_name(process_name)
ZenohSession->>ZenohSessionImpl: get_session_id via info()
ZenohSessionImpl-->>ZenohSession: info
ZenohSession-->>events: source_name
events->>ZenohSessionImpl: put(topic, foxgloveLog)
ServiceProcess->>events: publish_running()
events->>events: _timestamp_payload()
events->>ZenohSessionImpl: put(topic, foxgloveLog)
events->>events: publish_health("ready")
events->>ZenohSessionImpl: put(topic, foxgloveLog)
ServiceProcess-->>events: process exit
events->>events: atexit _handle_process_exit()
events->>events: publish_stop()
events->>ZenohSessionImpl: put(topic, foxgloveLog)
Sequence diagram for settings snapshot eventssequenceDiagram
participant Service as service
participant SettingsMgr as PydanticManager
participant EventPublisher as events
participant ZenohSession as zenohSession
participant ZenohSessionImpl as zenohSessionImpl
service->>SettingsMgr: load()
SettingsMgr->>SettingsMgr: _load_from_files()
alt valid_settings_file
SettingsMgr->>SettingsMgr: _settings = load_from_file()
SettingsMgr->>SettingsMgr: _emit_initial_settings_event()
else no_valid_settings
SettingsMgr->>SettingsMgr: _settings = default()
SettingsMgr->>SettingsMgr: save()
SettingsMgr->>SettingsMgr: _emit_initial_settings_event()
end
SettingsMgr->>SettingsMgr: _publish_settings_snapshot("initial-load")
SettingsMgr->>SettingsMgr: _serialize_settings()
SettingsMgr->>events: publish_settings(settings, metadata)
events->>events: _timestamp_payload()
events->>zenohSession: format_source_name(process_name)
zenohSession->>zenohSessionImpl: get_session_id via info()
zenohSessionImpl-->>zenohSession: info
zenohSession-->>events: source_name
events->>zenohSessionImpl: put(topic, foxgloveLog)
service->>SettingsMgr: save()
SettingsMgr->>SettingsMgr: settings.save()
SettingsMgr->>SettingsMgr: _publish_settings_snapshot("save")
SettingsMgr->>events: publish_settings(settings, metadata)
events->>zenohSessionImpl: put(topic, foxgloveLog)
Class diagram for EventPublisher, ZenohSession, and settings managersclassDiagram
class EventPublisher {
- ZenohSession _zenoh_session
- str _service_name
- str _process_name
- str _topic
- bool _initialized
- bool _stop_emitted
- bool _atexit_registered
- bool _excepthook_installed
- _previous_excepthook
- bool _asyncio_handler_installed
- _previous_asyncio_handler
+ initialize(service_name str) void
+ publish(event_type str, payload dict) void
+ publish_start(additional_payload dict) void
+ publish_settings(settings dict, metadata dict) void
+ publish_running(additional_payload dict) void
+ publish_health(status str, details dict) void
+ publish_error(message str, details dict) void
+ publish_stop(additional_payload dict) void
- _foxglove_timestamp() dict
- _serialize_event_message(event_type str, payload dict) str
- _publish_event(event_type str, payload dict) void
- _timestamp_payload(base dict) dict
- _register_exit_handlers() void
- _handle_process_exit() void
- _handle_unhandled_exception(exc_type, exc_value, exc_traceback) void
- _handle_async_exception(loop, context dict) void
}
class ZenohSession {
+ zenoh.Session session
+ zenoh.Config config
+ ThreadPoolExecutor _executor
+ str _session_id
+ get_session_id() str
+ format_source_name(process_name str) str
+ zenoh_config(service_name str) void
+ close() void
+ publish(topic str, data) void
+ subscribe(topic str, callback) void
+ _extract_session_id(info) str
+ _parse_session_id_string(data str) str
}
class PydanticManager {
+ str project_name
+ Path config_folder
+ Type settings_type
+ PydanticSettings _settings
+ bool _initial_event_emitted
+ save() void
+ load() void
+ _clear_temp_files() void
+ _serialize_settings() dict
+ _publish_settings_snapshot(reason str) void
+ _emit_initial_settings_event() void
}
class PyksonManager {
+ str project_name
+ Path config_folder
+ Type settings_type
+ PyksonSettings _settings
+ bool _initial_event_emitted
+ save() void
+ load() void
+ _clear_temp_files() void
+ _serialize_settings() dict
+ _publish_settings_snapshot(reason str) void
+ _emit_initial_settings_event() void
}
class ProcessUtils {
+ get_process_name() str
}
class zenohSession
EventPublisher --> ZenohSession : uses
EventPublisher --> ProcessUtils : calls
PydanticManager --> EventPublisher : publishes settings
PyksonManager --> EventPublisher : publishes settings
ZenohSession --> zenohSession : wraps zenoh.Session
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
17cc2d0 to
e15b90d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Introduce a shared event publishing utility and integrate structured lifecycle and health events across core services, while enriching logging metadata with process and session identifiers.
New Features:
<zid>/<process>source identifiers for telemetry.Enhancements: