Skip to content

Conversation

@tigroo
Copy link
Collaborator

@tigroo tigroo commented Jul 30, 2025

Changes

  • examples:
    • collector: add a new mqtt exporter

Close #331

Test

How to test

  1. Execute each example following the documentation into the README file.

@tigroo tigroo added this to the Sprint 13 milestone Jul 30, 2025
@tigroo tigroo requested a review from nbuffon July 30, 2025 17:19
@tigroo tigroo self-assigned this Jul 30, 2025
@tigroo tigroo added the Rust Rust code label Jul 30, 2025
@tigroo tigroo marked this pull request as draft July 30, 2025 17:20
@tigroo tigroo moved this to In Progress in its-client Jul 30, 2025
@tigroo tigroo force-pushed the add_collector_mqtt_exporter branch 5 times, most recently from dc33450 to 9709f0f Compare August 22, 2025 16:46
@tigroo tigroo force-pushed the add_collector_mqtt_exporter branch 4 times, most recently from 73728f1 to ceb2ace Compare September 1, 2025 14:13
@tigroo tigroo force-pushed the add_collector_mqtt_exporter branch from ceb2ace to a851f99 Compare September 30, 2025 09:20
@tigroo tigroo marked this pull request as ready for review September 30, 2025 09:32
Copy link
Member

@nbuffon nbuffon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description should definitely tell what's to be tested related to the changes and not only redirect to the README

let string_topic = self.topic.to_string();
let parts = string_topic.split('/').collect::<Vec<&str>>();
let mut new_parts = parts.clone();
if level as usize <= parts.len() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These might be included in StrTopic implementation

impl StrTopic {
    pub fn parts() -> &[&str] {...}

    pub fn len() { self.parts().len() }
}

} else {
let string_topic = self.topic.to_string();
// Use the specified number of levels
let parts: Vec<&str> = string_topic.split('/').collect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we could use an upper level len() and/or parts() method(s) on StrTopic

CollectorStrTopic::Level5(topic) => topic.as_route(),
CollectorStrTopic::Default(topic) => topic.as_route(),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a trait implementation, just put this code directly in the trait implementation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand : it's an enum implementation for me :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as_route comes from Topic trait which is implemented for this enum later in this file by just calling this method.
What I mean is that you don't need this method as all its content belongs to the impl

impl Topic for CollectorStrTopic {
    fn as_route() {
        // here
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tigroo Last point remaining as explained yesterday do you want to push it now so I can approve this PR ?

@nbuffon
Copy link
Member

nbuffon commented Oct 15, 2025

Just to mention, the collector example code need Rust 1.90 to work, it does not build under 1.85

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:208:32
    |
208 | ...                   if let Some(file_exporter) = &exporter.file
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:209:36
    |
209 | ...                   && let Some(ref mut current_log_file) = log_file
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:225:36
    |
225 | ...                   && let Some(ref mut current_publish_client) = publish_client
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `libits-client` (example "collector") due to 3 previous errors

Simplifying to not build artificial sections just for call.

Signed-off-by: Frédéric Gardes <[email protected]>
Signed-off-by: Frédéric Gardes <[email protected]>
This was referenced Oct 20, 2025
@tigroo
Copy link
Collaborator Author

tigroo commented Oct 20, 2025

Just to mention, the collector example code need Rust 1.90 to work, it does not build under 1.85

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:208:32
    |
208 | ...                   if let Some(file_exporter) = &exporter.file
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:209:36
    |
209 | ...                   && let Some(ref mut current_log_file) = log_file
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

error[E0658]: `let` expressions in this position are unstable
   --> examples/collector/main.rs:225:36
    |
225 | ...                   && let Some(ref mut current_publish_client) = publish_client
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `libits-client` (example "collector") due to 3 previous errors

#454

Signed-off-by: Frédéric Gardes <[email protected]>
Depending on a ROUTE_LEVEL,
the topic can be routed differently
(and not statically as the default str topic).

Signed-off-by: Frédéric Gardes <[email protected]>
Add a getter to a list.


Signed-off-by: Frédéric Gardes <[email protected]>
Fix minor comments.
Create a collector str topic allowing
5 levels of routed str topic.

Signed-off-by: Frédéric Gardes <[email protected]>
@tigroo tigroo force-pushed the add_collector_mqtt_exporter branch from a851f99 to 3df7326 Compare October 20, 2025 15:02
@tigroo
Copy link
Collaborator Author

tigroo commented Oct 20, 2025

And in parallell, I try : #452

@tigroo tigroo requested a review from nbuffon October 20, 2025 15:38
@nbuffon nbuffon modified the milestones: Sprint 13, Sprint 15 Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Rust code

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

add collector mqtt exporter

2 participants