Skip to content

otel.instrumentation.common.peer-service-mapping support glob #13434

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

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

Conversation

xiepuhuan
Copy link
Contributor

@xiepuhuan xiepuhuan commented Mar 1, 2025

Related to #13111.
The host portion of the URL supports glob patterns.

@xiepuhuan xiepuhuan requested a review from a team as a code owner March 1, 2025 17:40
Copy link

linux-foundation-easycla bot commented Mar 11, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@xiepuhuan xiepuhuan force-pushed the common-peer-service-mapping-support-glob branch from fe0a054 to 1bb8548 Compare March 11, 2025 11:38
String url = "https://" + entry.getKey();
String serviceName = entry.getValue();

String host = GlobUrlParser.getHost(url);
Copy link
Member

Choose a reason for hiding this comment

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

can we use the regular UrlParser and just add one method to it getPortAsString()?

(basically requiring that the entry still looks like a url, just maybe not with an integer port)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we use the regular UrlParser and just add one method to it getPortAsString()?

(basically requiring that the entry still looks like a url, just maybe not with an integer port)

Is the goal to let port support glob?

Copy link
Member

Choose a reason for hiding this comment

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

do you need it? if not maybe we can simplify and only support glob on address for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you need it? if not maybe we can simplify and only support glob on address for now

Yes, I don't think it's necessary.

String url = "https://" + entry.getKey();
String serviceName = entry.getValue();

String host = GlobUrlParser.getHost(url);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we use the regular UrlParser and just add one method to it getPortAsString()?

(basically requiring that the entry still looks like a url, just maybe not with an integer port)

Is the goal to let port support glob?

return matchers.entrySet().stream()
.filter(entry -> entry.getKey().matches(port, pathSupplier))
.max((o1, o2) -> matcherComparator.compare(o1.getKey(), o2.getKey()))
.findFirst()
.map(Map.Entry::getValue)
.orElse(null);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original code needs sorting to get the maximum result when there are multiple results after each filter. I think the time complexity is relatively high.
I modified the implementation to sort in the constructor. After each filter, there are multiple results. The first result found is the largest.

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.

2 participants