-
Notifications
You must be signed in to change notification settings - Fork 330
add limits to the view name size in spring #10873
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
Draft
vandonr
wants to merge
2
commits into
master
Choose a base branch
from
vandonr-patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...st/groovy/datadog/trace/instrumentation/springweb/SpringWebHttpServerDecoratorTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package datadog.trace.instrumentation.springweb | ||
|
|
||
| import datadog.trace.agent.test.InstrumentationSpecification | ||
| import org.springframework.web.servlet.ModelAndView | ||
|
|
||
| class SpringWebHttpServerDecoratorTest extends InstrumentationSpecification { | ||
|
|
||
| def "onRender truncates long view name for tag and resource"() { | ||
| given: | ||
| def viewName = "a" * (SpringWebHttpServerDecorator.VIEW_NAME_TAG_LIMIT + 12) | ||
| def modelAndView = Stub(ModelAndView) { | ||
| getViewName() >> viewName | ||
| getView() >> null | ||
| } | ||
| def span = TEST_TRACER.buildSpan("testInstrumentation", "my operation").start() | ||
|
|
||
| when: | ||
| SpringWebHttpServerDecorator.DECORATE_RENDER.onRender(span, modelAndView) | ||
| span.finish() | ||
|
|
||
| then: | ||
| span.getTag("view.name").toString().length() == SpringWebHttpServerDecorator.VIEW_NAME_TAG_LIMIT | ||
| span.getResourceName().length() == SpringWebHttpServerDecorator.VIEW_NAME_RESOURCE_LIMIT | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...t/groovy/datadog/trace/instrumentation/springweb6/SpringWebHttpServerDecoratorTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package datadog.trace.instrumentation.springweb6 | ||
|
|
||
| import datadog.trace.agent.test.InstrumentationSpecification | ||
| import org.springframework.web.servlet.ModelAndView | ||
|
|
||
| class SpringWebHttpServerDecoratorTest extends InstrumentationSpecification { | ||
|
|
||
| def "onRender truncates long view name for tag and resource"() { | ||
| given: | ||
| def viewName = "a" * (SpringWebHttpServerDecorator.VIEW_NAME_TAG_LIMIT + 12) | ||
| def modelAndView = Stub(ModelAndView) { | ||
| getViewName() >> viewName | ||
| getView() >> null | ||
| } | ||
| def span = TEST_TRACER.buildSpan("testInstrumentation", "my operation").start() | ||
|
|
||
| when: | ||
| SpringWebHttpServerDecorator.DECORATE_RENDER.onRender(span, modelAndView) | ||
| span.finish() | ||
|
|
||
| then: | ||
| span.getTag("view.name").toString().length() == SpringWebHttpServerDecorator.VIEW_NAME_TAG_LIMIT | ||
| span.getResourceName().length() == SpringWebHttpServerDecorator.VIEW_NAME_RESOURCE_LIMIT | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this realistically happen in practice (e.g., do we have a support case)? This is a breaking change and the PR should be labeled accordingly. Moreover, the same reasoning applies to all tags and the resource name, so it would be better to address this holistically rather than focusing on the view name, which seems unlikely to be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sorry I didn't link it, but in https://datadoghq.atlassian.net/browse/APMS-18977 the customer has view names that reach 4 million characters.
It's due to a bad loop in their code, but the idea is that we shouldn't crash even bad code if it doesn't crash by itself.
And we discussed in the TEE sync the idea of truncating at the
setTaglevel, but @dougqh said that there is some cases where we want the truncation to happen later, for instance if an SQL request gets truncated it might prevent the agent from properly parsing it, and then applying the relevant obfuscation algo.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn’t have implemented this kind of fix, and I don’t think it’s the right approach. The error looks like a cyclic dispatch, and the logs seem to support this, as spans appear to be closed multiple times and the resource name growing similarly. I would instead focus on ensuring that, if possible, in the case of cyclic calls, we do not repeatedly open spans or set the resource name multiple times. While this is a hypothesis I haven’t fully verified.
wrt resource names, we’ve encountered similar issues before (e.g., with Redis and Mongo resource names). This could be an opportunity to enforce such safeguards globally, potentially behind a feature flag, or to introduce a shared utility to handle it consistently.