Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ jobs:
needs:
- build
# If you change the following comment, update the pattern in the update_system_test_reference.sh script to match.
uses: DataDog/system-tests/.github/workflows/system-tests.yml@main # system tests are pinned on release branches only
uses: DataDog/system-tests/.github/workflows/system-tests.yml@20ec39676051d9eedf2fdcea17f716e7b89d3c10 # system tests are pinned on release branches only
permissions:
contents: read
id-token: write
packages: write
with:
library: java
# If you change the following comment, update the pattern in the update_system_test_reference.sh script to match.
ref: "main" # system tests are pinned on release branches only
ref: "20ec39676051d9eedf2fdcea17f716e7b89d3c10" # system tests are pinned on release branches only
binaries_artifact: binaries
desired_execution_time: 900 # 15 minutes
scenarios_groups: tracer-release
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ publishing-gate:

configure_system_tests:
variables:
SYSTEM_TESTS_REF: "main" # system tests are pinned on release branches only
SYSTEM_TESTS_REF: "20ec39676051d9eedf2fdcea17f716e7b89d3c10" # system tests are pinned on release branches only
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,simple_onboarding_appsec,docker-ssi,lib-injection"

create_key:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/one-pipeline.locked.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE MANUALLY
# This file is auto-generated by automation.
include:
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/versions/1.1.0/one-pipeline.yml
- remote: https://gitlab-templates.ddbuild.io/libdatadog/include/versions/1.2.0/one-pipeline.yml
2 changes: 1 addition & 1 deletion dd-java-agent/ddprof-lib/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:ddprof:1.48.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.datadoghq:ddprof:1.49.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.javaparser:javaparser-core:3.25.6=codenarc
com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,spotbugs
com.github.spotbugs:spotbugs:4.9.8=spotbugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,40 @@ muzzle {
'7.5.14-ccs',
'7.5.15-ce',
'7.5.15-ccs',
'7.5.16-ce',
'7.5.16-ccs',
'7.6.10-ce',
'7.6.10-ccs',
'7.6.11-ce',
'7.6.11-ccs',
'7.6.12-ce',
'7.6.12-ccs',
'7.6.13-ce',
'7.6.13-ccs',
'7.7.8-ce',
'7.7.8-ccs',
'7.7.9-ce',
'7.7.9-ccs',
'7.7.10-ce',
'7.7.10-ccs',
'7.7.11-ce',
'7.7.11-ccs',
'7.8.7-ce',
'7.8.7-ccs',
'7.8.8-ce',
'7.8.8-ccs',
'7.8.9-ce',
'7.8.9-ccs',
'7.8.10-ce',
'7.8.10-ccs',
'7.9.6-ce',
'7.9.6-ccs',
'7.9.7-ce',
'7.9.7-ccs',
'7.9.8-ce',
'7.9.8-ccs'
'7.9.8-ccs',
'7.9.9-ce',
'7.9.9-ccs'
]
excludeDependency "io.confluent.cloud:*"
excludeDependency "io.confluent.observability:*"
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ shadow = "9.4.2"
spotbugs_annotations = "4.9.8"

# DataDog libs and forks
ddprof = "1.48.1"
ddprof = "1.49.0"
dogstatsd = "4.4.5"
okhttp = "3.12.15" # Datadog fork to support Java 7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.util.AbstractMap;
import java.util.Date;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -125,7 +125,7 @@ public <T> ProviderEvaluation<T> evaluate(
return error(defaultValue, ErrorCode.GENERAL, "Missing allocations for flag " + key);
}

final Date now = new Date();
final Instant now = Instant.now();
final String targetingKey = context.getTargetingKey();

for (final Allocation allocation : flag.allocations) {
Expand Down Expand Up @@ -208,14 +208,14 @@ private static boolean isEmpty(final List<?> list) {
return list == null || list.isEmpty();
}

private static boolean isAllocationActive(final Allocation allocation, final Date now) {
final Date startDate = allocation.startAt;
if (startDate != null && now.before(startDate)) {
static boolean isAllocationActive(final Allocation allocation, final Instant now) {
final Instant startDate = allocation.startAtInstant();
if (startDate != null && now.isBefore(startDate)) {
return false;
}

final Date endDate = allocation.endAt;
if (endDate != null && now.after(endDate)) {
final Instant endDate = allocation.endAtInstant();
if (endDate != null && now.isAfter(endDate)) {
return false;
}

Expand Down Expand Up @@ -546,7 +546,9 @@ static AbstractMap<String, Object> flattenContext(final EvaluationContext contex
new FlattenEntry(entry.key + "." + property, structure.getValue(property)));
}
} else {
result.put(entry.key, context.convertValue(value));
result.put(
entry.key,
value.isInstant() ? value.asInstant().toString() : context.convertValue(value));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
import datadog.trace.api.featureflag.FeatureFlaggingGateway;
import datadog.trace.api.featureflag.ufc.v1.Allocation;
import datadog.trace.api.featureflag.ufc.v1.Flag;
import datadog.trace.api.featureflag.ufc.v1.ServerConfiguration;
import dev.openfeature.sdk.ErrorCode;
Expand All @@ -37,7 +38,8 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.OffsetDateTime;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -123,7 +125,7 @@ private static Arguments[] valueMappingTestCases() {
Arguments.of(Value.class, null, null),

// Unsupported
Arguments.of(Date.class, "21-12-2023", IllegalArgumentException.class),
Arguments.of(Long.class, 42L, IllegalArgumentException.class),
};
}

Expand Down Expand Up @@ -212,6 +214,33 @@ public void testNoAllocations() {
assertThat(details.getErrorCode(), nullValue());
}

@Test
public void testAllocationDateAbiAndInstantAccessors() throws Exception {
final Date startAt = Date.from(Instant.parse("2024-01-01T00:00:00Z"));
final Date endAt = Date.from(Instant.parse("2024-12-31T23:59:59Z"));
final Allocation allocation =
new Allocation("allocation", emptyList(), startAt, endAt, emptyList(), true);

assertThat(Allocation.class.getField("startAt").getType(), equalTo(Date.class));
assertThat(Allocation.class.getField("endAt").getType(), equalTo(Date.class));
assertThat(allocation.startAtInstant(), equalTo(startAt.toInstant()));
assertThat(allocation.endAtInstant(), equalTo(endAt.toInstant()));
}

@Test
public void testAllocationWindowHonorsMicrosecondPrecision() {
final Instant startAt = Instant.parse("2024-01-01T00:00:00.123456Z");
final Instant endAt = Instant.parse("2024-01-01T00:00:00.987654Z");
final Allocation allocation =
Allocation.fromInstants("allocation", emptyList(), startAt, endAt, emptyList(), true);

assertThat(
DDEvaluator.isAllocationActive(allocation, startAt.minusNanos(1_000)), equalTo(false));
assertThat(DDEvaluator.isAllocationActive(allocation, startAt), equalTo(true));
assertThat(DDEvaluator.isAllocationActive(allocation, endAt), equalTo(true));
assertThat(DDEvaluator.isAllocationActive(allocation, endAt.plusNanos(1_000)), equalTo(false));
}

private static Arguments[] flatteningTestCases() {
final List<Arguments> arguments = new ArrayList<>();
arguments.add(Arguments.of(emptyMap(), emptyMap()));
Expand All @@ -227,6 +256,8 @@ private static Arguments[] flatteningTestCases() {
Arguments.of(
mapOf("map", mapOf("key1", 1, "key2", 2, "key3", mapOf("key4", 4))),
mapOf("map.key1", 1, "map.key2", 2, "map.key3.key4", 4)));
final Instant instant = Instant.parse("2026-07-10T12:34:56Z");
arguments.add(Arguments.of(mapOf("instant", instant), mapOf("instant", instant.toString())));
return arguments.toArray(new Arguments[0]);
}

Expand Down Expand Up @@ -410,7 +441,8 @@ public Date fromJson(final JsonReader reader) throws IOException {
return reader.nextNull();
}
try {
return Date.from(OffsetDateTime.parse(reader.nextString()).toInstant());
return Date.from(
DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(reader.nextString(), Instant::from));
} catch (final Exception ignored) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.api.featureflag.ufc.v1;

import java.time.Instant;
import java.util.Date;
import java.util.List;

Expand All @@ -11,18 +12,69 @@ public class Allocation {
public final List<Split> splits;
public final Boolean doLog;

private final transient Instant preciseStartAt;
private final transient Instant preciseEndAt;

public Allocation(
final String key,
final List<Rule> rules,
final Date startAt,
final Date endAt,
final List<Split> splits,
final Boolean doLog) {
this(
key,
rules,
startAt,
endAt,
splits,
doLog,
startAt == null ? null : startAt.toInstant(),
endAt == null ? null : endAt.toInstant());
}

private Allocation(
final String key,
final List<Rule> rules,
final Date startAt,
final Date endAt,
final List<Split> splits,
final Boolean doLog,
final Instant preciseStartAt,
final Instant preciseEndAt) {
this.key = key;
this.rules = rules;
this.startAt = startAt;
this.endAt = endAt;
this.splits = splits;
this.doLog = doLog;
this.preciseStartAt = preciseStartAt;
this.preciseEndAt = preciseEndAt;
}

public static Allocation fromInstants(
final String key,
final List<Rule> rules,
final Instant startAt,
final Instant endAt,
final List<Split> splits,
final Boolean doLog) {
return new Allocation(
key,
rules,
startAt == null ? null : Date.from(startAt),
endAt == null ? null : Date.from(endAt),
splits,
doLog,
startAt,
endAt);
}

public Instant startAtInstant() {
return preciseStartAt != null ? preciseStartAt : startAt == null ? null : startAt.toInstant();
}

public Instant endAtInstant() {
return preciseEndAt != null ? preciseEndAt : endAt == null ? null : endAt.toInstant();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.datadog.featureflag;

import static datadog.trace.api.telemetry.LogCollector.EXCLUDE_TELEMETRY;
import static datadog.trace.util.AgentThreadFactory.AgentThread.FEATURE_FLAG_EXPOSURE_PROCESSOR;
import static datadog.trace.util.AgentThreadFactory.newAgentThread;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down Expand Up @@ -178,15 +179,22 @@ protected void flushIfNecessary() {
return;
}
if (shouldFlush()) {
final String requestBodyJson;
try {
final ExposuresRequest exposures = new ExposuresRequest(this.context, this.buffer);
final String reqBod = jsonAdapter.toJson(exposures);
requestBodyJson = jsonAdapter.toJson(exposures);
} catch (RuntimeException e) {
LOGGER.error(EXCLUDE_TELEMETRY, "Could not serialize exposures; dropping batch", e);
this.buffer.clear();
return;
}
try {
final RequestBody requestBody =
RequestBody.create(okhttp3.MediaType.parse("application/json"), reqBod);
RequestBody.create(okhttp3.MediaType.parse("application/json"), requestBodyJson);
evp.post("exposures", requestBody, stream -> null, null, false);
this.buffer.clear();
} catch (Exception e) {
LOGGER.error("Could not submit exposures", e);
LOGGER.debug("Could not submit exposures", e);
}
}
}
Expand Down
Loading
Loading