Skip to content
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

otel feature with tracing functionality only #119

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

LikhithST
Copy link

as suggested in pull request #97 this PR contains only the tracing functionality without the context transfer between clients and the databroker

@SebastianSchildt
Copy link
Contributor

@lukasmittag or @argerus please check if this is acceptable/non-invasive enough and if so approve. Would be nice to have basic OTEL support (we can still think about how to do the context transfer "nicer" in a follow up PR)

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 54.94505% with 41 lines in your changes missing coverage. Please review.

Project coverage is 59.55%. Comparing base (2159d18) to head (74bab0d).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
databroker/src/lib.rs 0.00% 23 Missing ⚠️
databroker/src/open_telemetry.rs 0.00% 15 Missing ⚠️
databroker/src/grpc/kuksa_val_v1/val.rs 81.81% 2 Missing ⚠️
databroker/src/grpc/kuksa_val_v1/conversions.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   59.49%   59.55%   +0.06%     
==========================================
  Files          33       34       +1     
  Lines       16070    15168     -902     
==========================================
- Hits         9561     9034     -527     
+ Misses       6509     6134     -375     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SebastianSchildt
Copy link
Contributor

@LikhithST some minor mechanical linting issues: cargo fmt or clippy not happy, missing license identifier in otel.rs and some newline issue that can be fixed with the setting up pre-commit locally as described here https://github.com/eclipse-kuksa/kuksa-databroker/blob/main/CONTRIBUTING.md#pre-commit-set-up

@LikhithST
Copy link
Author

LikhithST commented Jan 9, 2025

Hi @SebastianSchildt, I have added the license and ran the pre-commit hooks. I ran cargo clippy and cargo fmt to fix linting issues. The cargo fmt command modified a few files.

@SebastianSchildt
Copy link
Contributor

Hi @LikhithST Thank you! From my side looks good. I will keep it open until next week when @lukasmittag is back to check whether has some additional comments. If not I will merge

Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me 👍

Copy link
Contributor

@rafaeling rafaeling left a comment

Choose a reason for hiding this comment

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

Thanks for adding this great feature to databroker.

One important thing: at some point otel will also be added to kuksa.val.v2. Could you please review and add the kuksa_val_v1 prefix to otel name variables under kuksa_val_v1 folder, and ensure also that the correct file name prefix is present in all the name variables?

Pattern example:
name="class_name_+method_name"

Pattern example for files under kuksa_val_v1
name="api_+class_name_+method_name"

Thanks again.

@@ -706,6 +711,7 @@ impl Entry {
}
}

#[cfg_attr(feature="otel", tracing::instrument(name="apply_lag_after_execute", skip(self), fields(timestamp=chrono::Utc::now().to_string())))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Add broker_ prefix

Copy link
Author

@LikhithST LikhithST Jan 14, 2025

Choose a reason for hiding this comment

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

Thanks for the feedback,

Do I have to follow this pattern name="class_name_+method_name" strictly, because previously I have used this pattern only if more than one class have same method name.

Example:
for the method validate of class Entry, name="broker_validate", I have followed name=file_name+method_name.

Whereas for method notify of class ChangeSubscription, name=broker_change_subscription_notify here I have followed name=file_name+class_name+method_name

similarly for method notify of class QuerySubscription, name="broker_query_subscription_notify"

Copy link
Contributor

Choose a reason for hiding this comment

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

The best approach from my point of view is to use the pattern name="class_name_+method_name".

That way we can keep it short and concise so we can identify to which class belongs the method.

Also, find it too long the pattern:
name=file_name+class_name+method_name

pub fn add_change_subscription(&mut self, subscription: ChangeSubscription) {
self.change_subscriptions.push(subscription)
}

#[cfg_attr(
feature = "otel",
tracing::instrument(name = "broker_Subscriptions_notify", skip(self, changed, db))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use lower case pattern and remove blank space between name and it value.

@@ -749,10 +755,15 @@ impl Subscriptions {
self.query_subscriptions.push(subscription)
}

#[cfg_attr(feature="otel", tracing::instrument(name = "broker_add_change_subscription",skip(self, subscription), fields(timestamp=chrono::Utc::now().to_string())))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove blank space between name and its value.

@@ -835,6 +847,10 @@ impl Subscriptions {
}

impl ChangeSubscription {
#[cfg_attr(
feature = "otel",
tracing::instrument(name = "broker_ChangeSubscription_notify", skip(self, changed, db))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use lower case pattern and remove blank space between name and its value.

@@ -706,6 +711,7 @@ impl Entry {
}
}

#[cfg_attr(feature="otel", tracing::instrument(name="apply_lag_after_execute", skip(self), fields(timestamp=chrono::Utc::now().to_string())))]
pub fn apply_lag_after_execute(&mut self) {
self.lag_datapoint = self.datapoint.clone();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add otel to the apply method https://github.com/eclipse-kuksa/kuksa-databroker/blob/main/databroker/src/broker.rs#L713
It would be also revelant to know how long does it take to initialize the hashset in the heap.

@@ -256,11 +256,20 @@ impl proto::val_server::Val for broker::DataBroker {
}
}

#[cfg_attr(feature="otel",tracing::instrument(name="val_set",skip(self, request), fields(trace_id, timestamp= chrono::Utc::now().to_string())))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add kuksa_val_v1 as prefix to the name so it is clear to which val file belongs? Kuksa.val.v2 also contain val.rs file

@@ -472,6 +481,7 @@ impl proto::val_server::Val for broker::DataBroker {
>,
>;

#[cfg_attr(feature="otel", tracing::instrument(name="subscribe", skip(self, request), fields(trace_id, timestamp=chrono::Utc::now().to_string())))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do you get trace_id here from?
Please also add kuksa_val_v1_val_ as prefix.

Copy link
Author

Choose a reason for hiding this comment

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

trace_id is not being used here, I will remove it.

Some(entry) => match &entry.metadata {
Some(metadata) => match &metadata.description {
Some(description) => {
trace_id = String::from(description);
Copy link
Contributor

@rafaeling rafaeling Jan 13, 2025

Choose a reason for hiding this comment

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

Why is it used here description as trace_id instead of path?

Copy link
Author

@LikhithST LikhithST Jan 14, 2025

Choose a reason for hiding this comment

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

Apologies for using description to handle trace_id, could comment in proto file be used for this purpose?

trace_id is introduced as an effort to identify the request with its corresponding otel tracing result. could I use comment that is a member of message Metadata.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about cloning the path from the entry request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants