Skip to content

Conversation

@LikeTheSalad
Copy link
Contributor

Fixes elastic/kibana#216980

These changes aim to set transaction.type=mobile to all root spans coming from our mobile agents.

@LikeTheSalad LikeTheSalad requested a review from a team as a code owner April 24, 2025 07:53
@LikeTheSalad LikeTheSalad requested review from gregkalapos and hegerchr and removed request for a team April 24, 2025 07:53
@LikeTheSalad
Copy link
Contributor Author

Question

These changes set transaction.type to mobile based on the elastic-specific type attribute. Should we remove the type attribute from the span after we use it to set transaction.type?

@LikeTheSalad LikeTheSalad requested a review from bryce-b April 24, 2025 08:43
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. Thanks for the PR! 🎉

These changes set transaction.type to mobile based on the elastic-specific type attribute. Should we remove the type attribute from the span after we use it to set transaction.type?

I'd keep it. In this lib, we typically don't remove any attributes. We could save some storage if we remove it, on the other hand, it'd be very confusing if we start removing fields from incoming data. So my take is to keep it.

s.userAgentName = v.Str()
case semconv27.AttributeUserAgentVersion:
s.userAgentVersion = v.Str()
case "type":
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this attribute be set?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's set by the EDOT mobile SDKs specified here.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe also add elasticattr.TransactionType do this case so that if transaction.type is set already, it's not overridden?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe also add elasticattr.TransactionType do this case so that if transaction.type is set already, it's not overridden?

I'm ok with validating that transaction.type won't change if it's already present. It's a different use case though it seems like it'd be easy enough to add it in this PR. What do you think, @gregkalapos @lahsivjar ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also add elasticattr.TransactionType do this case so that if transaction.type is set already, it's not overridden?

I think overriding behaviour should be handled for other attributes too, but I am not sure if not overriding in all cases would be the correct option. I have created #185 to discuss it further.

Copy link
Contributor

@gregkalapos gregkalapos Apr 25, 2025

Choose a reason for hiding this comment

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

Ok by me to include it in this PR. update: @lahsivjar was faster - let's discuss in #185.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think overriding behaviour should be handled for other attributes too, but I am not sure if not overriding in all cases would be the correct option. I have created #185 to discuss it further.

Got it. Thanks, @lahsivjar. I won't add that change here then.

Copy link
Contributor

@lahsivjar lahsivjar Apr 25, 2025

Choose a reason for hiding this comment

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

I think we should do it in a separate PR since this concern might apply to other attributes too, but I don't have a strong opinion here. Does that makes sense @gregkalapos @felixbarny ? Or do we think only transaction.type needs to be handled this way?

NVM, let's discuss in #185

}

// Tests the enrichment logic for elastic's transaction definition with type.
func TestElasticTransactionEnrichWithType(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we need a new test? The contents feels like they will fit as a subtest for TestElasticTransactionEnrich

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I've just moved the test cases to existing tests.

LikeTheSalad and others added 3 commits April 25, 2025 12:18
Co-authored-by: Vishal Raj <vishal.raj@elastic.co>
Co-authored-by: Vishal Raj <vishal.raj@elastic.co>
Copy link
Contributor

@lahsivjar lahsivjar left a comment

Choose a reason for hiding this comment

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

Missed a couple of places to remove hasValue variable. Rest LGTM!

Copy link
Contributor

@lahsivjar lahsivjar left a comment

Choose a reason for hiding this comment

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

LGTM!

s.userAgentName = v.Str()
case semconv27.AttributeUserAgentVersion:
s.userAgentVersion = v.Str()
case "type":
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also add elasticattr.TransactionType do this case so that if transaction.type is set already, it's not overridden?

I think overriding behaviour should be handled for other attributes too, but I am not sure if not overriding in all cases would be the correct option. I have created #185 to discuss it further.

@LikeTheSalad LikeTheSalad merged commit 117e0a4 into elastic:main Apr 30, 2025
3 checks passed
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.

Some mobile APM transactions are not displayed in the dashboard

4 participants