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

(pkg/ottl) Add extracted OS info from UserAgent #35886

Closed

Conversation

ioandr
Copy link

@ioandr ioandr commented Oct 20, 2024

Description

Add OS attributes about name and version from the (parsed) User Agent string.

Link to tracking issue

Fixes #35458

Testing

Run TestUserAgentParser(), add new fields to expected map, add new testcases taken from https://github.com/ua-parser/uap-core/blob/master/tests/test_os.yaml.

Documentation

N/A

@ioandr ioandr force-pushed the feature-i-useragent-osinfo branch from fc52236 to dcdbd5b Compare October 20, 2024 18:13
@ioandr ioandr marked this pull request as ready for review October 20, 2024 19:14
@ioandr ioandr requested a review from a team as a code owner October 20, 2024 19:14
Comment on lines 46 to 47
semconv.AttributeOSName: parsedOS.Family,
semconv.AttributeOSVersion: parsedOS.ToVersionString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think those attributes should be in the UserAgent namespace instead, but unluckily they are not available in semconv yet (open-telemetry/semantic-conventions#1434).

Meanwhile, could we create them manually?

Suggested change
semconv.AttributeOSName: parsedOS.Family,
semconv.AttributeOSVersion: parsedOS.ToVersionString(),
"user_agent." + semconv.AttributeOSName: parsedOS.Family,
"user_agent." +semconv.AttributeOSVersion: parsedOS.ToVersionString(),

Copy link
Author

@ioandr ioandr Oct 25, 2024

Choose a reason for hiding this comment

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

Sure, this makes sense. Pushed a FIXUP for this with a comment to remove the hardcoded prefix once user agent OS attributes are added to semconv.

Feel free to resolve the conversation if the FIXUP covers this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @ioandr , FIXUP looks good to me. It seems I cannot "resolve the conversation" (no UI button), maybe because of the forced push? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Unless the semconv sig is waiting for proof-of-concept we should wait until the semconv sig as accepted them as experimental.

@ioandr ioandr force-pushed the feature-i-useragent-osinfo branch from 73d7a02 to a06577d Compare October 25, 2024 19:12
Copy link
Contributor

@rogercoll rogercoll left a comment

Choose a reason for hiding this comment

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

LGTM

@ioandr ioandr force-pushed the feature-i-useragent-osinfo branch from a06577d to 1dc8187 Compare October 28, 2024 12:25
return map[string]any{
semconv.AttributeUserAgentName: parsedUserAgent.Family,
semconv.AttributeUserAgentOriginal: userAgentString,
semconv.AttributeUserAgentVersion: parsedUserAgent.ToVersionString(),
// Remove hardcoded prefix when UserAgent OS attributes are added to semvconv
"user_agent" + semconv.AttributeOSName: parsedOS.Family,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't these attribute's names be separated by a dot? It currently generates names like user_agentos.name and user_agentos.version.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could also make them local constants so we wouldn't need to concatenate them in every execution/tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch! +1 to @edmocosta suggestions

@edmocosta
Copy link
Contributor

I think we also need to add a changelog entry and to update the UserAgent docs including the new attributes.

Add changelog entry and update docs as needed.

Signed-off-by: Ioannis Androulidakis <androulidakis.ioannis@gmail.com>
@ioandr ioandr force-pushed the feature-i-useragent-osinfo branch from 1dc8187 to 600cd7e Compare November 4, 2024 08:43
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/ottl] Support for extracting OS attributes from UserAgent
4 participants