-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: main
Are you sure you want to change the base?
Conversation
@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) |
Codecov ReportAttention: Patch coverage is
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. |
@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 |
Hi @SebastianSchildt, I have added the license and ran the pre-commit hooks. I ran |
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 |
There was a problem hiding this 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 👍
There was a problem hiding this 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())))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add broker_ prefix
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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())))] |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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(); | |||
} |
There was a problem hiding this comment.
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())))] |
There was a problem hiding this comment.
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())))] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
as suggested in pull request #97 this PR contains only the tracing functionality without the context transfer between clients and the databroker