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

Change kafka to use Statement instead of Othernamespace #1306

Merged
merged 4 commits into from
Nov 1, 2024

Conversation

grcevski
Copy link
Contributor

@grcevski grcevski commented Oct 31, 2024

We needed an extra field for the Kafka clientID in our span struct and we ended up using Othernamespace, which is wrong. That field is re-written by the nameresolver. We can use statement instead.

This is a follow-up of #1247. I refactored the code a bit so I can reuse the logic in the metrics and I added some unit tests.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.37%. Comparing base (eb0a8c4) to head (7e303f4).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1306      +/-   ##
==========================================
+ Coverage   81.25%   81.37%   +0.12%     
==========================================
  Files         142      142              
  Lines       14294    14295       +1     
==========================================
+ Hits        11614    11633      +19     
+ Misses       2116     2102      -14     
+ Partials      564      560       -4     
Flag Coverage Δ
integration-test 58.72% <18.57%> (-0.20%) ⬇️
k8s-integration-test 59.65% <28.57%> (+0.24%) ⬆️
oats-test 35.02% <80.00%> (-0.04%) ⬇️
unittests 52.40% <58.57%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@grcevski
Copy link
Contributor Author

grcevski commented Oct 31, 2024

@esara I made a follow-up with the fix for Kafka and some refactoring so the names are the same across traces and metrics. It would be great to get your review.

Copy link
Contributor

@esara esara left a comment

Choose a reason for hiding this comment

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

thanks, it is a bit cleaner to factor our as a method! I think functionally the same as before

func HostAsServer(span *Span) string {
if span.OtherNamespace != "" && span.OtherNamespace != span.ServiceID.Namespace {
if span.IsClientSpan() {
return SpanHost(span) + "." + span.OtherNamespace
Copy link
Contributor

Choose a reason for hiding this comment

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

one minor comment, if the span.Hostname == "" this would return span.Host+span.OtherNamespace - where the span.Host is an ip address
although you can assume if that the span.OtherNamespace k8s lookup worked, the span.Hostname should also be populated, in which case the span.Host would not be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah true, we probably don't want to do IP.namespace. I'll add a check for span.HostName existing. Thanks for catching this!


func PeerAsClient(span *Span) string {
if span.OtherNamespace != "" && span.OtherNamespace != span.ServiceID.Namespace {
if !span.IsClientSpan() {
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

@grcevski grcevski merged commit 65955ba into grafana:main Nov 1, 2024
13 checks passed
@grcevski grcevski deleted the fix_kafka_field branch November 1, 2024 19:38
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