Skip to content

Migrate dd-trace-core groovy files to java part 7#11374

Open
jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-core-pt7
Open

Migrate dd-trace-core groovy files to java part 7#11374
jpbempel wants to merge 2 commits into
masterfrom
jpbempel/g2j-core-pt7

Conversation

@jpbempel
Copy link
Copy Markdown
Member

What Does This Do

we migrate 9 tests:

  • BaggagePropagatorTest
  • ServiceDiscoveryTest
  • TagInterceptorTest
  • LatencyTraceInterceptorTest
  • GlobPatternTest
  • LRUCacheTest
  • MatchersTest
  • SimpleRateLimiterTest
  • SystemAccessTest

Motivation

this is part of the effort to migrate groovy tests to Java/JUnit
part1: #11053
part2: #11062
part3: #11085
part4: #11146
part5: #11217
part6: #11362

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

we migrate 9 tests:
 - BaggagePropagatorTest
 - ServiceDiscoveryTest
 - TagInterceptorTest
 - LatencyTraceInterceptorTest
 - GlobPatternTest
 - LRUCacheTest
 - MatchersTest
 - SimpleRateLimiterTest
 - SystemAccessTest
@jpbempel jpbempel requested review from a team as code owners May 15, 2026 13:25
@jpbempel jpbempel requested review from mhlidd and removed request for a team May 15, 2026 13:25
@jpbempel jpbempel added comp: testing Testing tag: no release notes Changes to exclude from release notes labels May 15, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 15, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2f76adddb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

throw new ArgumentConversionException("Cannot convert " + source);
}
}
return source.toString();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve non-string table values in DDTagsConverter

The fallback return source.toString() coerces every non-symbol literal to String, including numeric/boolean map values. In this migration that means rows like Tags.HTTP_STATUS: 404 in TagInterceptorTest are now passed as "404", so tests no longer cover the statusCode instanceof Number branch in TagInterceptor.interceptHttpStatusCode. This silently weakens regression coverage for type-sensitive tag handling; the converter should return source unchanged when it is not a DDTags.*/Tags.* token.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD left a comment

Choose a reason for hiding this comment

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

LGTM in general, left several minor comments.
I see a lot of tests started with test prefix and a lot of tests without.
Let's be consistent and use test everywhere?

",,",
"="
})
void extractInvalidBaggageHeaders(String baggageHeader) {
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.

nit: looks like a missing prefix test ?

Comment on lines +141 to +150
@ValueSource(
strings = {
"no-equal-sign,foo=gets-dropped-because-previous-pair-is-malformed",
"foo=gets-dropped-because-subsequent-pair-is-malformed,=",
"=no-key",
"no-value=",
"",
",,",
"="
})
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.

nit: can this be a TableTest with named scenarios for human readability?

Comment on lines +196 to +198
// creating a new instance after injecting config
propagator = new BaggagePropagator(true, true, DEFAULT_TRACE_BAGGAGE_MAX_ITEMS, 20);
Map<String, String> headers = singletonMap(BAGGAGE_KEY, baggageHeader);
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.

nit: This comment and code looks like repeating... maybe extract to a function with self documented name?

import org.msgpack.core.MessagePack;
import org.msgpack.value.MapValue;

@Timeout(value = 10, unit = TimeUnit.SECONDS)
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.

nit: I would put a comment why we need timeout here and other similar places.

Comment on lines +42 to +44
assertEquals(
"{\"schema_version\":2,\"tracer_language\":\"java\",\"tracer_version\":\"1.2.3\",\"hostname\":\"test-host\",\"logs_collected\":true,\"runtime_id\":\"rid-123\",\"service_name\":\"orders\",\"service_env\":\"prod\",\"service_version\":\"1.1.1\",\"process_tags\":\"key1:val1,key2:val2\",\"container_id\":\"containerID\"}",
map.toString());
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.

nit: a bit ugly code... any ideas how this can be better?

Comment on lines +573 to +575
static Stream<Arguments> treat1ValueAsTrueForBooleanTagValuesArguments() {
return Stream.of(
arguments("manual.drop / true", DDTags.MANUAL_DROP, true, (int) PrioritySampling.USER_DROP),
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.

TableTest?

Comment on lines +20 to +21
@NullSource
@ValueSource(strings = {"*", "**"})
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.

nit, I do believe that TableTest with named scenarios would be better.

@ParameterizedTest
@NullSource
@ValueSource(strings = {"*", "**"})
void matchAllScenariosMustReturnAnAnyMatcher(String glob) {
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.

nit: again missing test prefix?

Comment on lines +44 to +47
static Stream<Arguments> aPatternMatcherTestArguments() {
return Stream.of(
arguments("fo? matches Foo", "fo?", "Foo", true),
arguments("Fo? matches Foo", "Fo?", "Foo", true),
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.

TableTest? StringBuilder can be tested as arguments.

Comment on lines +13 to +14
implementation(project(":dd-trace-api"))
implementation(project(":internal-api"))
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.

Just curious how tests refactoring needs this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: testing Testing tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants