Skip to content

Commit d28bfcd

Browse files
authored
Merge branch 'master' into sabrenner/llmobs-tool-definitions
2 parents d999248 + e910ab5 commit d28bfcd

100 files changed

Lines changed: 3958 additions & 912 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/json/src/main/java/datadog/json/JsonWriter.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public final class JsonWriter implements Flushable, AutoCloseable {
1919
private final JsonStructure structure;
2020

2121
private boolean requireComma;
22+
private int bytesWritten;
2223

2324
/** Creates a writer with structure check. */
2425
public JsonWriter() {
@@ -245,6 +246,11 @@ public void flush() {
245246
}
246247
}
247248

249+
/** Approximate number of bytes written so far. */
250+
public int sizeInBytes() {
251+
return this.bytesWritten;
252+
}
253+
248254
@Override
249255
public void close() {
250256
try {
@@ -268,13 +274,15 @@ private void endsValue() {
268274
private void write(char ch) {
269275
try {
270276
this.writer.write(ch);
277+
this.bytesWritten++;
271278
} catch (IOException ignored) {
272279
}
273280
}
274281

275282
private void writeStringLiteral(String str) {
276283
try {
277284
this.writer.write('"');
285+
int count = 1;
278286

279287
for (int i = 0; i < str.length(); ++i) {
280288
char c = str.charAt(i);
@@ -286,33 +294,40 @@ private void writeStringLiteral(String str) {
286294
this.writer.write(HEX_DIGITS[(c >>> 8) & 0xF]);
287295
this.writer.write(HEX_DIGITS[(c >>> 4) & 0xF]);
288296
this.writer.write(HEX_DIGITS[c & 0xF]);
297+
count += 6;
289298
} else {
290299
switch (c) {
291300
case '"': // Quotation mark
292301
case '\\': // Reverse solidus
293302
case '/': // Solidus
294303
this.writer.write('\\');
295304
this.writer.write(c);
305+
count += 2;
296306
break;
297307
case '\b': // Backspace
298308
this.writer.write('\\');
299309
this.writer.write('b');
310+
count += 2;
300311
break;
301312
case '\f': // Form feed
302313
this.writer.write('\\');
303314
this.writer.write('f');
315+
count += 2;
304316
break;
305317
case '\n': // Line feed
306318
this.writer.write('\\');
307319
this.writer.write('n');
320+
count += 2;
308321
break;
309322
case '\r': // Carriage return
310323
this.writer.write('\\');
311324
this.writer.write('r');
325+
count += 2;
312326
break;
313327
case '\t': // Horizontal tab
314328
this.writer.write('\\');
315329
this.writer.write('t');
330+
count += 2;
316331
break;
317332
default:
318333
if (c < 0x20) {
@@ -322,22 +337,28 @@ private void writeStringLiteral(String str) {
322337
this.writer.write('0');
323338
this.writer.write(HEX_DIGITS[(c >>> 4) & 0xF]);
324339
this.writer.write(HEX_DIGITS[c & 0xF]);
340+
count += 6;
325341
} else {
326342
this.writer.write(c);
343+
count += 1;
327344
}
328345
break;
329346
}
330347
}
331348
}
332349

333350
this.writer.write('"');
351+
count += 1;
352+
353+
this.bytesWritten += count;
334354
} catch (IOException ignored) {
335355
}
336356
}
337357

338358
private void writeStringRaw(String str) {
339359
try {
340360
this.writer.write(str);
361+
this.bytesWritten += str.length(); // exact if ASCII, estimate otherwise
341362
} catch (IOException ignored) {
342363
}
343364
}

components/json/src/test/java/datadog/json/JsonWriterTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,54 @@ void testCompleteObject() {
165165
}
166166
}
167167

168+
@Test
169+
void testSizeInBytes() {
170+
try (JsonWriter writer = new JsonWriter()) {
171+
assertEquals(0, writer.sizeInBytes(), "Check empty writer size");
172+
173+
writer.beginArray();
174+
assertSizeInBytes(writer, "Check size after plain ASCII string");
175+
writer.value("bar");
176+
177+
assertSizeInBytes(writer, "Check size after escaped characters");
178+
writer.value("\"\\/");
179+
180+
assertSizeInBytes(writer, "Check size after named escapes");
181+
writer.value("\b\f\n\r\t");
182+
183+
assertSizeInBytes(writer, "Check size after control character escape");
184+
writer.value("\u0001");
185+
186+
assertSizeInBytes(writer, "Check size after non-ASCII character escape");
187+
writer.value("café");
188+
189+
assertSizeInBytes(writer, "Check size after int value");
190+
writer.value(3);
191+
192+
assertSizeInBytes(writer, "Check size after long value");
193+
writer.value(3456789123L);
194+
195+
assertSizeInBytes(writer, "Check size after float value");
196+
writer.value(3.142f);
197+
198+
assertSizeInBytes(writer, "Check size after double value");
199+
writer.value(PI);
200+
201+
assertSizeInBytes(writer, "Check size after boolean value");
202+
writer.value(true);
203+
204+
assertSizeInBytes(writer, "Check size after null value");
205+
writer.nullValue();
206+
207+
writer.endArray();
208+
assertSizeInBytes(writer, "Check final size matches written bytes");
209+
}
210+
}
211+
212+
private static void assertSizeInBytes(JsonWriter writer, String message) {
213+
assertEquals(writer.toByteArray().length, writer.sizeInBytes(), message);
214+
}
215+
168216
@Test
169217
void testCompleteArray() {
170218
try (JsonWriter writer = new JsonWriter()) {

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/BuildkiteInfo.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class BuildkiteInfo implements CIProviderInfo {
2323
public static final String BUILDKITE = "BUILDKITE";
2424
public static final String BUILDKITE_PROVIDER_NAME = "buildkite";
2525
public static final String BUILDKITE_PIPELINE_ID = "BUILDKITE_BUILD_ID";
26-
public static final String BUILDKITE_PIPELINE_NAME = "BUILDKITE_PIPELINE_SLUG";
26+
public static final String BUILDKITE_PIPELINE_SLUG = "BUILDKITE_PIPELINE_SLUG";
27+
public static final String BUILDKITE_PIPELINE_DISPLAY_NAME = "BUILDKITE_PIPELINE_NAME";
2728
public static final String BUILDKITE_PIPELINE_NUMBER = "BUILDKITE_BUILD_NUMBER";
2829
public static final String BUILDKITE_BUILD_URL = "BUILDKITE_BUILD_URL";
2930
public static final String BUILDKITE_JOB_ID = "BUILDKITE_JOB_ID";
@@ -67,7 +68,8 @@ public CIInfo buildCIInfo() {
6768
return CIInfo.builder(environment)
6869
.ciProviderName(BUILDKITE_PROVIDER_NAME)
6970
.ciPipelineId(environment.get(BUILDKITE_PIPELINE_ID))
70-
.ciPipelineName(environment.get(BUILDKITE_PIPELINE_NAME))
71+
.ciPipelineName(environment.get(BUILDKITE_PIPELINE_SLUG))
72+
.ciPipelineDisplayName(environment.get(BUILDKITE_PIPELINE_DISPLAY_NAME))
7173
.ciPipelineNumber(environment.get(BUILDKITE_PIPELINE_NUMBER))
7274
.ciPipelineUrl(ciPipelineUrl)
7375
.ciJobId(environment.get(BUILDKITE_JOB_ID))

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/CIInfo.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static final class Builder {
2222
private String ciProviderName;
2323
private String ciPipelineId;
2424
private String ciPipelineName;
25+
private String ciPipelineDisplayName;
2526
private String ciStageName;
2627
private String ciJobId;
2728
private String ciJobName;
@@ -53,6 +54,11 @@ public Builder ciPipelineName(String ciPipelineName) {
5354
return this;
5455
}
5556

57+
public Builder ciPipelineDisplayName(String ciPipelineDisplayName) {
58+
this.ciPipelineDisplayName = ciPipelineDisplayName;
59+
return this;
60+
}
61+
5662
public Builder ciStageName(String ciStageName) {
5763
this.ciStageName = ciStageName;
5864
return this;
@@ -123,6 +129,7 @@ public CIInfo build() {
123129
ciProviderName,
124130
ciPipelineId,
125131
ciPipelineName,
132+
ciPipelineDisplayName,
126133
ciStageName,
127134
ciJobId,
128135
ciJobName,
@@ -140,6 +147,7 @@ public CIInfo build() {
140147
private final String ciProviderName;
141148
private final String ciPipelineId;
142149
private final String ciPipelineName;
150+
private final String ciPipelineDisplayName;
143151
private final String ciStageName;
144152
private final String ciJobId;
145153
private final String ciJobName;
@@ -153,13 +161,14 @@ public CIInfo build() {
153161
private final Map<String, String> additionalTags;
154162

155163
public CIInfo() {
156-
this(null, null, null, null, null, null, null, null, null, null, null, null, null, null);
164+
this(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
157165
}
158166

159167
public CIInfo(
160168
String ciProviderName,
161169
String ciPipelineId,
162170
String ciPipelineName,
171+
String ciPipelineDisplayName,
163172
String ciStageName,
164173
String ciJobId,
165174
String ciJobName,
@@ -174,6 +183,7 @@ public CIInfo(
174183
this.ciProviderName = ciProviderName;
175184
this.ciPipelineId = ciPipelineId;
176185
this.ciPipelineName = ciPipelineName;
186+
this.ciPipelineDisplayName = ciPipelineDisplayName;
177187
this.ciStageName = ciStageName;
178188
this.ciJobId = ciJobId;
179189
this.ciJobName = ciJobName;
@@ -199,6 +209,10 @@ public String getCiPipelineName() {
199209
return ciPipelineName;
200210
}
201211

212+
public String getCiPipelineDisplayName() {
213+
return ciPipelineDisplayName;
214+
}
215+
202216
public String getCiStageName() {
203217
return ciStageName;
204218
}
@@ -267,6 +281,7 @@ public boolean equals(Object o) {
267281
return Objects.equals(ciProviderName, ciInfo.ciProviderName)
268282
&& Objects.equals(ciPipelineId, ciInfo.ciPipelineId)
269283
&& Objects.equals(ciPipelineName, ciInfo.ciPipelineName)
284+
&& Objects.equals(ciPipelineDisplayName, ciInfo.ciPipelineDisplayName)
270285
&& Objects.equals(ciStageName, ciInfo.ciStageName)
271286
&& Objects.equals(ciJobId, ciInfo.ciJobId)
272287
&& Objects.equals(ciJobName, ciInfo.ciJobName)
@@ -286,6 +301,7 @@ public int hashCode() {
286301
hash = 31 * hash + (ciProviderName == null ? 0 : ciProviderName.hashCode());
287302
hash = 31 * hash + (ciPipelineId == null ? 0 : ciPipelineId.hashCode());
288303
hash = 31 * hash + (ciPipelineName == null ? 0 : ciPipelineName.hashCode());
304+
hash = 31 * hash + (ciPipelineDisplayName == null ? 0 : ciPipelineDisplayName.hashCode());
289305
hash = 31 * hash + (ciStageName == null ? 0 : ciStageName.hashCode());
290306
hash = 31 * hash + (ciJobId == null ? 0 : ciJobId.hashCode());
291307
hash = 31 * hash + (ciJobName == null ? 0 : ciJobName.hashCode());
@@ -312,6 +328,9 @@ public String toString() {
312328
+ ", ciPipelineName='"
313329
+ ciPipelineName
314330
+ '\''
331+
+ ", ciPipelineDisplayName='"
332+
+ ciPipelineDisplayName
333+
+ '\''
315334
+ ", ciStageName='"
316335
+ ciStageName
317336
+ '\''

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/ci/CITagsProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public Map<String, String> getCiTags(CIInfo ciInfo, PullRequestInfo pullRequestI
2929
.withCiProviderName(ciInfo.getCiProviderName())
3030
.withCiPipelineId(ciInfo.getCiPipelineId())
3131
.withCiPipelineName(ciInfo.getCiPipelineName())
32+
.withCiPipelineDisplayName(ciInfo.getCiPipelineDisplayName())
3233
.withCiStageName(ciInfo.getCiStageName())
3334
.withCiJobName(ciInfo.getCiJobName())
3435
.withCiJobId(ciInfo.getCiJobId())
@@ -82,6 +83,10 @@ public CITagsBuilder withCiPipelineName(final String ciPipelineName) {
8283
return putTagValue(Tags.CI_PIPELINE_NAME, ciPipelineName);
8384
}
8485

86+
public CITagsBuilder withCiPipelineDisplayName(final String ciPipelineDisplayName) {
87+
return putTagValue(Tags.CI_PIPELINE_DISPLAY_NAME, ciPipelineDisplayName);
88+
}
89+
8590
public CITagsBuilder withCiPipelineNumber(final String ciPipelineNumber) {
8691
return putTagValue(Tags.CI_PIPELINE_NUMBER, ciPipelineNumber);
8792
}

dd-java-agent/agent-ci-visibility/src/test/resources/ci/buildkite.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,46 @@
730730
"git.tag": "0.0.2"
731731
}
732732
],
733+
[
734+
{
735+
"BUILDKITE": "true",
736+
"BUILDKITE_BRANCH": "master",
737+
"BUILDKITE_BUILD_AUTHOR": "buildkite-git-commit-author-name",
738+
"BUILDKITE_BUILD_AUTHOR_EMAIL": "buildkite-git-commit-author-email@datadoghq.com",
739+
"BUILDKITE_BUILD_CHECKOUT_PATH": "/foo/bar",
740+
"BUILDKITE_BUILD_ID": "buildkite-pipeline-id",
741+
"BUILDKITE_BUILD_NUMBER": "buildkite-pipeline-number",
742+
"BUILDKITE_BUILD_URL": "https://buildkite-build-url.com",
743+
"BUILDKITE_COMMIT": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
744+
"BUILDKITE_JOB_ID": "buildkite-job-id",
745+
"BUILDKITE_MESSAGE": "buildkite-git-commit-message",
746+
"BUILDKITE_PIPELINE_NAME": "Buildkite Pipeline Display Name",
747+
"BUILDKITE_PIPELINE_SLUG": "buildkite-pipeline-name",
748+
"BUILDKITE_PULL_REQUEST": "false",
749+
"BUILDKITE_PULL_REQUEST_BASE_BRANCH": "",
750+
"BUILDKITE_REPO": "http://hostname.com/repo.git",
751+
"BUILDKITE_TAG": "",
752+
"DD_TEST_CASE_NAME": "pipeline-display-name-from-buildkite-pipeline-name"
753+
},
754+
{
755+
"_dd.ci.env_vars": "{\"BUILDKITE_BUILD_ID\":\"buildkite-pipeline-id\",\"BUILDKITE_JOB_ID\":\"buildkite-job-id\"}",
756+
"ci.job.id": "buildkite-job-id",
757+
"ci.job.url": "https://buildkite-build-url.com#buildkite-job-id",
758+
"ci.pipeline.display_name": "Buildkite Pipeline Display Name",
759+
"ci.pipeline.id": "buildkite-pipeline-id",
760+
"ci.pipeline.name": "buildkite-pipeline-name",
761+
"ci.pipeline.number": "buildkite-pipeline-number",
762+
"ci.pipeline.url": "https://buildkite-build-url.com",
763+
"ci.provider.name": "buildkite",
764+
"ci.workspace_path": "/foo/bar",
765+
"git.branch": "master",
766+
"git.commit.author.email": "buildkite-git-commit-author-email@datadoghq.com",
767+
"git.commit.author.name": "buildkite-git-commit-author-name",
768+
"git.commit.message": "buildkite-git-commit-message",
769+
"git.commit.sha": "b9f0fb3fdbb94c9d24b2c75b49663122a529e123",
770+
"git.repository_url": "http://hostname.com/repo.git"
771+
}
772+
],
733773
[
734774
{
735775
"BUILDKITE": "true",

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,6 @@ public void sourceFileProbeGroovy() throws IOException, URISyntaxException {
662662
}
663663

664664
@Test
665-
@EnabledForJreRange(
666-
max = JRE.JAVA_25) // TODO: Fix for Java 26. Delete once Java 26 is officially released.
667665
@DisabledIf(
668666
value = "datadog.environment.JavaVirtualMachine#isJ9",
669667
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -696,8 +694,6 @@ public void sourceFileProbeKotlin() throws IOException, URISyntaxException {
696694
}
697695

698696
@Test
699-
@EnabledForJreRange(
700-
max = JRE.JAVA_25) // TODO: Fix for Java 26. Delete once Java 26 is officially released.
701697
@DisabledIf(
702698
value = "datadog.environment.JavaVirtualMachine#isJ9",
703699
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -725,8 +721,6 @@ public void suspendKotlin() throws IOException, URISyntaxException {
725721
}
726722

727723
@Test
728-
@EnabledForJreRange(
729-
max = JRE.JAVA_25) // TODO: Fix for Java 26. Delete once Java 26 is officially released.
730724
@DisabledIf(
731725
value = "datadog.environment.JavaVirtualMachine#isJ9",
732726
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -760,8 +754,6 @@ public void suspendMethodKotlin() {
760754
}
761755

762756
@Test
763-
@EnabledForJreRange(
764-
max = JRE.JAVA_25) // TODO: Fix for Java 26. Delete once Java 26 is officially released.
765757
@DisabledIf(
766758
value = "datadog.environment.JavaVirtualMachine#isJ9",
767759
disabledReason = "Issue with J9 when compiling Kotlin code")

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/muzzle/ReferenceCreatorTest.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package datadog.trace.agent.tooling.muzzle
22

33
import datadog.trace.test.util.DDSpecification
4-
import spock.lang.Ignore
54

65
import static TestAdviceClasses.InstanceofAdvice
76
import static TestAdviceClasses.LdcAdvice
@@ -114,8 +113,6 @@ class ReferenceCreatorTest extends DDSpecification {
114113
references.get('datadog.trace.agent.tooling.muzzle.TestAdviceClasses$MethodBodyAdvice$A') != null
115114
}
116115

117-
// TODO: remove ignore when we drop java 7 support.
118-
@Ignore
119116
def "invokedynamic creates references"() {
120117
setup:
121118
Map<String, Reference> references = ReferenceCreator.createReferencesFrom(TestAdviceClasses.InDyAdvice.name, this.class.classLoader)

0 commit comments

Comments
 (0)