-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/ottl] Parse uri string to url.* SemConv attributes #32433
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
@michalpristas I suspect this is doable via regular expression, and any converter would be doing regex internally. Can this be accomplished with |
removed my previous comment, as it was for other issue 🤦 it is surely possible to do so. but this would mean we require every user to use and compile regex on their own. |
I would be okay adding this. We can use the |
I see the value this provides to our end-users, but we don't have a good way right now to decide when a new function should be accepted vs an existing function should be used. We really need some criteria for how new functions get added. @michalpristas you've been really active in OTTL recently providing a lot of good feedback and ideas. Any willingness to try and right up those rules? It would really help with several of the function additions you've requested. |
Missing functionality is a For other cases I try to assume non technical user, so Example of improved UX is probably #32593 If UX is same but assumes less technical user (better naming, terminology...) I'd say it's a When UX is worse or performance is troublesome, this should be a Other way I can think about that is that this should be treated like a code. We should aim for readability first and performance second (meaning performant solution can be achieved by using more low level pieces) With readability same things as with code should be expected, few important that come to mind
|
@michalpristas can you open a PR with these suggestions in |
I opened a pr. I will be on pto for the next 10 days though so my response time may be slightly unresponsive |
A couple thoughts:
{
"url.path" : "/foo.gif",
"url.fragment" : "fragment",
"url.extension" : "gif",
"url.password" : "mypassword",
"url.original" : "http://myusername:[email protected]:80/foo.gif?key1=val1&key2=val2#fragment",
"url.scheme" : "http",
"url.port" : 80,
"url.user_info" : "myusername:mypassword",
"url.domain" : "www.example.com",
"url.query" : "key1=val1&key2=val2",
"url.username" : "myusername"
} |
I've been writing a lot of OTTL lately and I found myself wanting exactly this functionality as a user convenience. Fully-compliant URL parsing is definitely non-trivial, and IMO worth implementing centrally. |
**Description:** As discussed [here](#32433 (comment)) we should agree on some guidelines when it comes to creating proposals for new functions and converters cc @TylerHelmuth **Link to tracking Issue:** - **Testing:** - **Documentation:** - --------- Co-authored-by: Evan Bradley <[email protected]> Co-authored-by: Tyler Helmuth <[email protected]> Co-authored-by: Daniel Jaglowski <[email protected]>
**Description:** This ottl converter converts uri string into SemConv attributes. Instead of using regex it uses `uri.Parse` providing nicer shorthand. **Link to tracking Issue:** #32433 **Testing:** unit test added **Documentation:** readme updated with: ### Uri `Uri(uri_string)` Parses a Uniform Resource Identifier (URI) string and extracts its components as an object. This URI object includes properties for the URI’s domain, path, fragment, port, query, scheme, user info, username, and password. `original`, `domain`, `scheme` and `path` are always present, other are present only if they have corresponding values. `uri_string` is a `string`. - `Uri("http://www.example.com")` results in ``` "original": "http://www.example.com", "scheme": "http", "domain": "www.example.com", "path": "", ``` - `Uri("http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment")` results in ``` "path": "/foo.gif", "fragment": "fragment", "extension": "gif", "password": "mypassword", "original": "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment", "scheme": "http", "port": 80, "user_info": "myusername:mypassword", "domain": "www.example.com", "query": "key1=val1&key2=val2", "username": "myusername", ``` --------- Co-authored-by: Tiffany Hrabusa <[email protected]> Co-authored-by: Evan Bradley <[email protected]>
Closing. Addressed in #32906 |
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
parsing URI possible only using complex RegEx
Describe the solution you'd like
Intended converter parses a Uniform Resource Identifier (URI) string and extracts its components into URL SemConv attributes.
Example
input:
Result:
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: