Skip to content

Read sourcemap content and fill context lines - #972

Merged
jalvz merged 2 commits into
elastic:masterfrom
jalvz:add-smap-content
May 29, 2018
Merged

jalvz merged 2 commits into
elastic:masterfrom
jalvz:add-smap-content

Conversation

@jalvz

@jalvz jalvz commented May 29, 2018

Copy link
Copy Markdown
Contributor

fixes #457

@simitt simitt left a comment

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.

great to get this in!

Comment thread sourcemap/mapper.go
"github.com/elastic/beats/libbeat/logp"
)

const sourcemapContentSnippetSize = 5

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.

This could have a huge impact on the used storage so I suggest to make this configurable.

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.

you think so? this is in errors - not spans... and only for frontend with sources in uploaded sourcemaps
i didn't want to bloat more the configuration space, but i can make it configurable if you prefer

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.

Sourcemapping is generally enabled for frontend endpoints, so it will also be enabled for transactions, not only for errors.
If we don't add the config option, it will be hard to give advice to customers in case they want to use sourcemapping but reduce storage.

Comment thread sourcemap/mapper.go

func subSlice(from, to int, content []string) []string {
if from > len(content) {
return content

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.

If I read correct, then in this case we would store the whole content. I suggest to return an empty array and to log an error.

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.

this is for when source content is not available, will rewrite to if len(content) == 0 to make it clear; sorry for that.
not sure about logging an error, sourcemap content is optional (as per spec); i think some tools include it by default and others don't, users can choose.
you still think should be logged?

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.

Oh ok. I agree that there is no need for logging when you check if len(content) == 0 { return content }, as this reflects something different than checking that from is not an overflow of the content array.

reads content from sourcemaps if available, and adds a code snippet to the stacktrace
fixes elastic#457
@jalvz
jalvz force-pushed the add-smap-content branch from f50ba20 to 4dcabe4 Compare May 29, 2018 12:11
@jalvz
jalvz merged commit 4dc8ba0 into elastic:master May 29, 2018
jalvz added a commit to jalvz/apm-server that referenced this pull request May 29, 2018
jalvz added a commit that referenced this pull request May 30, 2018
@roncohen

roncohen commented Jun 7, 2018

Copy link
Copy Markdown
Contributor

Awesome to have this in! We should probably add a changelog entry?

roncohen pushed a commit to roncohen/apm-server that referenced this pull request Jun 25, 2018
roncohen added a commit that referenced this pull request Jun 25, 2018
roncohen added a commit to roncohen/apm-server that referenced this pull request Jun 25, 2018
simitt pushed a commit to simitt/apm-server that referenced this pull request Jul 4, 2018
@simitt simitt mentioned this pull request Jul 4, 2018
simitt pushed a commit to simitt/apm-server that referenced this pull request Jul 4, 2018
simitt pushed a commit that referenced this pull request Jul 4, 2018
@jalvz
jalvz deleted the add-smap-content branch November 5, 2018 12:21
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.

Add actual source to stacktrace frame when applying sourcemapping

3 participants