Skip to content

Conversation

@lahsivjar
Copy link
Contributor

Adds enrichment for user_agent.{name, version} if it is missing. The attributes are derived from user_agent.original.

Closes: #172

@lahsivjar lahsivjar requested review from a team as code owners March 21, 2025 11:54
Comment on lines +557 to +562
if s.userAgentName == "" && s.inferredUserAgentName != "" {
span.Attributes().PutStr(semconv27.AttributeUserAgentName, s.inferredUserAgentName)
}
if s.userAgentVersion == "" && s.inferredUserAgentVersion != "" {
span.Attributes().PutStr(semconv27.AttributeUserAgentVersion, s.inferredUserAgentVersion)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[For reviewers] I am setting the user_agent.{name, version} only if it is not already set.

@lahsivjar lahsivjar requested a review from gregkalapos March 21, 2025 14:14
Copy link
Contributor

@gregkalapos gregkalapos left a comment

Choose a reason for hiding this comment

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

lgtm

}(),
},
{
name: "user_agent_parse_name_version",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd postfix these with something like _span and _transaction. So e.g. user_agent_parse_name_version_transaction here and user_agent_parse_name_version_span below, instead of having them with the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They would be reported as TestElastic{Transaction, Span}Enrich/user_agent_parse_name_version, is that not enough or is it for when looking at the tests individually without the context of the main test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, you are right. It's good enough. It just took me a few seconds to realize what's actually the difference is in these new tests with the same name. But yeah, this is ok - if the test fails, the output is clear.

Copy link
Contributor Author

@lahsivjar lahsivjar Mar 21, 2025

Choose a reason for hiding this comment

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

Cool, I am thinking to simplify these tests with a method for default enrichments... currently the tests are getting a bit hard to read an unnecessarily verbose. Will do it later as a followup.

@lahsivjar lahsivjar merged commit 072809a into elastic:main Mar 21, 2025
3 checks passed
@lahsivjar lahsivjar deleted the useragent-172 branch March 21, 2025 16:51
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.

[enrichments] Add enrichment logic for user_agent.*

2 participants