-
Notifications
You must be signed in to change notification settings - Fork 322
Inferred Routes and Resource Renaming: new APM trace metrics tag #9553
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
Open
sezen-datadog
wants to merge
13
commits into
master
Choose a base branch
from
sezen.leblay/apm-metrics-tag
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.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5ff30b6
Inferred Routes and Resource Renaming: new APM trace metrics tag
sezen-datadog c4bff6f
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog e6b468d
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog feab335
build issue
sezen-datadog 1c2c74a
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog 3f778ee
comments
sezen-datadog 03603b2
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog 95703db
test ko
sezen-datadog 97ee9c3
test ko
sezen-datadog a13e396
comments
sezen-datadog 2dedc95
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog 3afb7df
jacoco
sezen-datadog f10792d
Merge branch 'master' into sezen.leblay/apm-metrics-tag
sezen-datadog 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
252 changes: 252 additions & 0 deletions
252
...ke-tests/springboot/src/test/groovy/datadog/smoketest/HttpEndpointTaggingSmokeTest.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,252 @@ | ||
| package datadog.smoketest | ||
|
|
||
| import okhttp3.Request | ||
| import java.util.concurrent.atomic.AtomicInteger | ||
| import java.util.regex.Pattern | ||
|
|
||
| class HttpEndpointTaggingSmokeTest extends AbstractServerSmokeTest { | ||
|
|
||
| @Override | ||
| ProcessBuilder createProcessBuilder() { | ||
| String springBootShadowJar = System.getProperty("datadog.smoketest.springboot.shadowJar.path") | ||
|
|
||
| List<String> command = new ArrayList<>() | ||
| command.add(javaPath()) | ||
| command.addAll(defaultJavaProperties) | ||
| command.addAll((String[]) [ | ||
| "-Ddd.writer.type=MultiWriter:TraceStructureWriter:${output.getAbsolutePath()}:includeResource,DDAgentWriter", | ||
| "-Ddd.trace.resource.renaming.enabled=true", | ||
| "-jar", | ||
| springBootShadowJar, | ||
| "--server.port=${httpPort}" | ||
| ]) | ||
| ProcessBuilder processBuilder = new ProcessBuilder(command) | ||
| processBuilder.directory(new File(buildDirectory)) | ||
| } | ||
|
|
||
| @Override | ||
| File createTemporaryFile() { | ||
| return File.createTempFile("http-endpoint-tagging-trace", "out") | ||
| } | ||
|
|
||
| @Override | ||
| protected Set<String> expectedTraces() { | ||
| return [ | ||
| Pattern.quote("[servlet.request:GET /greeting[spring.handler:IastWebController.greeting]]") | ||
| ] | ||
| } | ||
|
|
||
| @Override | ||
| protected Set<String> assertTraceCounts(Set<String> expected, Map<String, AtomicInteger> traceCounts) { | ||
| List<Pattern> remaining = expected.collect { Pattern.compile(it) }.toList() | ||
| for (def i = remaining.size() - 1; i >= 0; i--) { | ||
| for (Map.Entry<String, AtomicInteger> entry : traceCounts.entrySet()) { | ||
| if (entry.getValue() > 0 && remaining.get(i).matcher(entry.getKey()).matches()) { | ||
| remaining.remove(i) | ||
| break | ||
| } | ||
| } | ||
| } | ||
| return remaining.collect { it.pattern() }.toSet() | ||
| } | ||
|
|
||
| def "test basic HTTP endpoint tagging"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/greeting" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| def responseBodyStr = response.body().string() | ||
| responseBodyStr != null | ||
| responseBodyStr.contains("Sup Dawg") | ||
| response.code() == 200 | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test URL parameterization for numeric IDs"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/users/123" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| // May return 404 since endpoint doesn't exist, but span should still be created | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test URL parameterization for hex patterns"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/session/abc123def456" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| // May return 404 since endpoint doesn't exist, but span should still be created | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test int_id pattern parameterization"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/versions/12.34.56" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test hex_id pattern parameterization"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/tokens/550e8400-e29b-41d4-a716-446655440000" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test str pattern parameterization for long strings"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/files/very-long-filename-that-exceeds-twenty-characters.pdf" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test str pattern parameterization for special characters"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/search/query%20with%20spaces" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test mixed URL patterns with multiple segments"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/users/123/orders/abc456def/items/789" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test URL with query parameters"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/users/123?filter=active&limit=10" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test URL with trailing slash"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/users/456/" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test static paths are preserved"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/health" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test root path handling"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test pattern precedence - int pattern wins over int_id"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/items/12345" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test pattern precedence - hex pattern wins over hex_id"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/hashes/abc123def" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
|
|
||
| def "test edge case - short segments not parameterized"() { | ||
| setup: | ||
| String url = "http://localhost:${httpPort}/api/x/y" | ||
| def request = new Request.Builder().url(url).get().build() | ||
|
|
||
| when: | ||
| def response = client.newCall(request).execute() | ||
|
|
||
| then: | ||
| response.code() in [200, 404] | ||
| waitForTraceCount(1) | ||
| } | ||
| } |
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
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
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
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.
Question: are they mandatory in the payload? if not they should be nullified here and not sent in the msgpack payload later on
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.
@jandro996 can i let you guys take over please?