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

Move user related fields to align with ECS schema. #1783

Merged
merged 9 commits into from
Jan 17, 2019

Conversation

simitt
Copy link
Contributor

@simitt simitt commented Jan 14, 2019

Move context.user.email to user.email
Move context.user.id to user.id
Move context.user.username to user.name
Move context.user.ip to client.ip
Move context.user.user-agent to user_agent

fixes #1782
depends on elastic/kibana#28678

@@ -63,6 +63,9 @@
"started": 43
},
"type": "request"
},
"user": {
"id": "123user"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

user information from the metadata is set if no transaction.context.user information was sent.

@@ -80,7 +80,10 @@ func (m *Metadata) Merge(fields common.MapStr) common.MapStr {
utility.Add(fields, "host", m.System.fields())
utility.Add(fields, "process", m.Process.fields())
utility.MergeAdd(fields, "service", m.Service.fields())
utility.MergeAdd(fields, "user", m.User.fields())
utility.AddIfNil(fields, "user", m.User.Fields())
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 don't think we should merge user information from metadata and context.user but overwrite it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@graphaelli the user_agent and the client.ip are set, even if the context.user information is set directly in an event, as they are nested under different root keys and not under user. So using AddIfNil seems proper here.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed on both counts. Think we need an integration test for this too?

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 MergeAdd was introduced long time ago, https://github.com/elastic/apm-server/pull/687/files.

I think it is a bug to mix two potential different user informations to one, that is why I changed it to AddIfNil, which basically first checks if there was a user sent with the specific event, and if not sets the one from the metadata.

The possibility to send a user in metadata and the event and if this makes sense or not is a completely different topic to discuss. Please raise any concerns about this in this issue #1255.

Move `context.user.email` to `user.email`
Move `context.user.id` to `user.id`
Move `context.user.username` to `user.name`
Move `context.user.ip` to `client.ip`
Move `context.user.user-agent` to `user_agent`

fixes elastic#1782
@simitt
Copy link
Contributor Author

simitt commented Jan 14, 2019

Kibana Index PR is up elastic/kibana#28678

@simitt simitt added the review label Jan 14, 2019
model/error/_meta/fields.yml Outdated Show resolved Hide resolved
_meta/kibana/6/dashboard/apm-dashboards.json Outdated Show resolved Hide resolved
ingest/pipeline/definition.json Show resolved Hide resolved
model/error/event.go Outdated Show resolved Hide resolved
model/metadata/user.go Outdated Show resolved Hide resolved
model/transaction/event.go Outdated Show resolved Hide resolved
@simitt
Copy link
Contributor Author

simitt commented Jan 16, 2019

@graphaelli @jalvz is there something left you require for this PR? Otherwise I'd appreciate an approval.

@simitt
Copy link
Contributor Author

simitt commented Jan 16, 2019

jenkins, retest this please.

@simitt
Copy link
Contributor Author

simitt commented Jan 16, 2019

jenkins, retest this

@simitt simitt closed this Jan 16, 2019
@simitt simitt reopened this Jan 16, 2019
@simitt
Copy link
Contributor Author

simitt commented Jan 16, 2019

jenkins, retest this please

@@ -80,7 +80,10 @@ func (m *Metadata) Merge(fields common.MapStr) common.MapStr {
utility.Add(fields, "host", m.System.fields())
utility.Add(fields, "process", m.Process.fields())
utility.MergeAdd(fields, "service", m.Service.fields())
utility.MergeAdd(fields, "user", m.User.fields())
utility.AddIfNil(fields, "user", m.User.Fields())
Copy link
Member

Choose a reason for hiding this comment

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

Agreed on both counts. Think we need an integration test for this too?

@jalvz
Copy link
Contributor

jalvz commented Jan 16, 2019

Great work! Really thorough testing 💯

@simitt
Copy link
Contributor Author

simitt commented Jan 17, 2019

Merging this in now as the failing test is a flaky, unrelated one.

@simitt simitt merged commit d6cfefc into elastic:master Jan 17, 2019
@simitt simitt deleted the ecs-change-user branch January 31, 2019 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move user related fields according to ECS schema
3 participants