Skip to content

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

Merged
simitt merged 9 commits into
elastic:masterfrom
simitt:ecs-change-user
Jan 17, 2019
Merged

simitt merged 9 commits into
elastic:masterfrom
simitt:ecs-change-user

Conversation

@simitt

@simitt simitt commented Jan 14, 2019 •

Copy link
Copy Markdown
Contributor

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

"type": "request"
},
"user": {
"id": "123user"

Copy link
Copy Markdown
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.

Comment thread ingest/pipeline/definition.json
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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

simitt commented Jan 14, 2019

Copy link
Copy Markdown
Contributor Author

Kibana Index PR is up elastic/kibana#28678

@simitt simitt added the review label Jan 14, 2019
Comment thread model/error/_meta/fields.yml Outdated
Comment thread _meta/kibana/6/dashboard/apm-dashboards.json Outdated
Comment thread ingest/pipeline/definition.json
Comment thread model/error/event.go Outdated
Comment thread model/metadata/user.go Outdated
Comment thread model/transaction/event.go Outdated
@simitt

simitt commented Jan 16, 2019

Copy link
Copy Markdown
Contributor Author

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

@simitt

simitt commented Jan 16, 2019

Copy link
Copy Markdown
Contributor Author

jenkins, retest this please.

@simitt

simitt commented Jan 16, 2019

Copy link
Copy Markdown
Contributor Author

jenkins, retest this

@simitt simitt closed this Jan 16, 2019
@simitt simitt reopened this Jan 16, 2019
@simitt

simitt commented Jan 16, 2019

Copy link
Copy Markdown
Contributor Author

jenkins, retest this please

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
Copy Markdown
Contributor

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

jalvz commented Jan 16, 2019

Copy link
Copy Markdown
Contributor

Great work! Really thorough testing 💯

@simitt

simitt commented Jan 17, 2019

Copy link
Copy Markdown
Contributor Author

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