diff --git a/Cargo.lock b/Cargo.lock index 469234f..e448ac2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1545,7 +1545,7 @@ dependencies = [ [[package]] name = "modality-trace-recorder-plugin" -version = "0.27.2" +version = "0.28.0" dependencies = [ "async-trait", "auxon-sdk", diff --git a/Cargo.toml b/Cargo.toml index 11a25af..92ac285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modality-trace-recorder-plugin" -version = "0.27.2" +version = "0.28.0" edition = "2021" authors = ["Jon Lamb "] description = "A Modality reflector plugin suite and ingest adapter library for Percepio's TraceRecorder data" diff --git a/README.md b/README.md index 4bbce42..f8122bd 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ These sections are the same for each of the plugins. - `ignored-object-classes` — Array of object classes to ignore processing during ingest (e.g. `[queue, semaphore]`) - `user-event-channel` — Instead of `USER_EVENT @ `, use the user event channel as the event name (` @ `). - `user-event-format-string` — Instead of `USER_EVENT @ `, use the user event format string as the event name (` @ `). + - `user-event-format-string-channels` — Same as `user-event-format-string` but for a specific set of channels. - `[[user-event-channel-name]]` — Use a custom event name whenever a user event with a matching channel is processed. * `channel`— The input channel name to match on. * `event-name`— The Modality event name to use. @@ -301,7 +302,7 @@ reflector configuration file, e.g. `[plugins.ingest.collectors.trace-recorder-tc - `disable-control-plane` — Disable sending control plane commands to the target. By default, `CMD_SET_ACTIVE` is sent on startup and shutdown to start and stop tracing on the target. - `restart` — Send a stop command before a start command to reset tracing on the target. - `connect-timeout` — Specify a connection timeout. Accepts durations like "10ms" or "1minute 2seconds 22ms". - - `remote` — The remote address and port to connect to. The default is `127.0.0.1:8888`. + - `remote` — The remote TCP server URL or `address:port` to connect to. The default is `127.0.0.1:8888`. ### ITM Collector Section diff --git a/src/config.rs b/src/config.rs index 0818f28..482e2b1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,6 +11,7 @@ use auxon_sdk::{ }; use derive_more::{Deref, From, Into}; use serde::Deserialize; +use std::collections::HashSet; use std::env; use std::path::{Path, PathBuf}; use std::str::FromStr; @@ -46,6 +47,7 @@ pub struct PluginConfig { pub ignored_object_classes: IgnoredObjectClasses, pub user_event_channel: bool, pub user_event_format_string: bool, + pub user_event_format_string_channels: HashSet, pub user_event_channel_rename_map: RenameMap, pub user_event_formatted_string_rename_map: RenameMap, pub user_event_fmt_arg_attr_keys: FormatArgAttributeKeysSet, @@ -291,6 +293,17 @@ impl TraceRecorderConfig { } else { cfg_plugin.user_event_channel }, + user_event_format_string_channels: if !tr_opts + .user_event_format_string_channel + .is_empty() + { + tr_opts + .user_event_format_string_channel + .into_iter() + .collect() + } else { + cfg_plugin.user_event_format_string_channels + }, user_event_format_string: if tr_opts.user_event_format_string { true } else { @@ -385,6 +398,7 @@ mod internal { pub ignored_object_classes: IgnoredObjectClasses, pub user_event_channel: bool, pub user_event_format_string: bool, + pub user_event_format_string_channels: Vec, #[serde(rename = "user-event-channel-name")] pub user_event_channel_rename_map: RenameMap, #[serde(rename = "user-event-formatted-string-name")] @@ -409,6 +423,10 @@ mod internal { ignored_object_classes: c.ignored_object_classes, user_event_channel: c.user_event_channel, user_event_format_string: c.user_event_format_string, + user_event_format_string_channels: c + .user_event_format_string_channels + .into_iter() + .collect(), user_event_channel_rename_map: c.user_event_channel_rename_map, user_event_formatted_string_rename_map: c.user_event_formatted_string_rename_map, user_event_fmt_arg_attr_keys: c.user_event_fmt_arg_attr_keys, @@ -560,6 +578,7 @@ run-id = 'a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d1' time-domain = 'a1a2a3a4b1b2c1c2d1d2d3d4d5d6d7d1' startup-task-name = 'm3' user-event-channel = true +user-event-format-string-channels = ['info', 'err'] user-event-format-string = true interaction-mode = "ipc" single-task-timeline = true @@ -798,6 +817,10 @@ breakpoint = "main" ignored_object_classes: Default::default(), user_event_channel: true, user_event_format_string: true, + user_event_format_string_channels: ["info", "err"] + .into_iter() + .map(|s| s.to_string()) + .collect(), user_event_channel_rename_map: vec![RenameMapItem { input: "act-cmd".to_owned(), event_name: "MY_EVENT".to_owned() @@ -894,6 +917,7 @@ breakpoint = "main" ignored_object_classes: Default::default(), user_event_channel: true, user_event_format_string: true, + user_event_format_string_channels: Default::default(), user_event_channel_rename_map: vec![RenameMapItem { input: "act-cmd".to_owned(), event_name: "MY_EVENT".to_owned() @@ -992,6 +1016,7 @@ breakpoint = "main" .collect(), user_event_channel: true, user_event_format_string: true, + user_event_format_string_channels: Default::default(), user_event_channel_rename_map: vec![RenameMapItem { input: "act-cmd".to_owned(), event_name: "MY_EVENT".to_owned() @@ -1101,6 +1126,7 @@ breakpoint = "main" .collect(), user_event_channel: true, user_event_format_string: true, + user_event_format_string_channels: Default::default(), user_event_channel_rename_map: vec![RenameMapItem { input: "act-cmd".to_owned(), event_name: "MY_EVENT".to_owned() diff --git a/src/opts.rs b/src/opts.rs index 74b5f38..7dc7f1b 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -83,6 +83,17 @@ pub struct TraceRecorderOpts { )] pub user_event_format_string: bool, + /// Instead of `USER_EVENT @ `, use the user event format string + /// as the event name (` @ `) for the given channel. + /// Can be supplied multiple times. + #[clap( + long, + name = "user-event-format-string-channel", + conflicts_with = "user-event-format-string", + help_heading = "TRACE RECORDER CONFIGURATION" + )] + pub user_event_format_string_channel: Vec, + /// Use a custom event name whenever a user event with a matching /// channel is processed. /// Can be supplied multiple times. diff --git a/src/recorder_data.rs b/src/recorder_data.rs index cae37bf..180f40e 100644 --- a/src/recorder_data.rs +++ b/src/recorder_data.rs @@ -530,7 +530,13 @@ impl RecorderDataExt for RecorderData { } Event::User(ev) => { - if cfg.user_event_channel { + if cfg + .user_event_format_string_channels + .contains(ev.channel.as_str()) + { + // Use the formatted string as the event name + attrs.insert(EventAttrKey::Name, ev.formatted_string.to_string().into()); + } else if cfg.user_event_channel { // Use the channel as the event name attrs.insert(EventAttrKey::Name, ev.channel.to_string().into()); } else if cfg.user_event_format_string {