Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pawel/nix_fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelchcki committed Jun 25, 2024
2 parents 4430ce0 + 81c2dad commit e04318f
Show file tree
Hide file tree
Showing 33 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pylint utils # pylint does not have a fix mode

# not py, as it's handled by black
INCLUDE_EXTENSIONS=("*.md" "*.yml" "*.yaml" "*.sh" "*.cs" "*.Dockerfile" "*.java" "*.sql" "*.ts" "*.js" "*.php")
EXCLUDE_DIRS=("logs*" "*/node_modules/*" "./venv/*" "./manifests/*" "./utils/build/*")
EXCLUDE_DIRS=("logs*" "*/node_modules/*" "./venv/*" "./manifests/*" "./utils/build/virtual_machine/*")

INCLUDE_ARGS=()
for ext in "${INCLUDE_EXTENSIONS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion tests/parametric/test_headers_b3.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_headers_b3_single_key_propagate_valid(self, test_agent, test_library):
@missing_feature(context.library == "nodejs", reason="Need to remove b3=b3multi alias")
@missing_feature(context.library == "php", reason="Need to remove b3=b3multi alias")
def test_headers_b3_migrated_extract_valid(self, test_agent, test_library):
self.test_headers_b3_extract_invalid(test_agent, test_library)
self.test_headers_b3_extract_valid(test_agent, test_library)

@enable_migrated_b3()
@missing_feature(context.library == "cpp", reason="format of DD_TRACE_PROPAGATION_STYLE_EXTRACT not supported")
Expand Down
8 changes: 4 additions & 4 deletions utils/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ print_usage() {
echo -e " Build images for Java and Spring Boot:"
echo -e " ${SCRIPT_NAME} --library java --weblog-variant spring-boot"
echo -e " Build default images for Dotnet with binary path:"
echo -e " ${SCRIPT_NAME} dotnet --binary-path "/mnt/c/dev/dd-trace-dotnet-linux/tmp/linux-x64""
echo -e " ${SCRIPT_NAME} dotnet --binary-path "/mnt/c/dev/dd-trace-dotnet-linux/tmp/linux-x64""
echo -e " Build default images for Dotnet with binary url:"
echo -e " ${SCRIPT_NAME} ./build.sh dotnet --binary-url "https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.27.0/datadog-dotnet-apm-2.27.0.tar.gz""
echo -e " List libraries:"
Expand Down Expand Up @@ -191,21 +191,21 @@ build() {
find . ! -name 'README.md' -type f -exec rm -f {} +
}

if ! [[ -z "$BINARY_URL" ]]; then
if ! [[ -z "$BINARY_URL" ]]; then
cd binaries
clean-binaries
curl -L -O $BINARY_URL
cd ..
fi

if ! [[ -z "$BINARY_PATH" ]]; then
if ! [[ -z "$BINARY_PATH" ]]; then
cd binaries
clean-binaries
cp -r $BINARY_PATH/* ./
cd ..
fi

DOCKERFILE=utils/build/docker/${TEST_LIBRARY}/${WEBLOG_VARIANT}.Dockerfile
DOCKERFILE=utils/build/docker/${TEST_LIBRARY}/${WEBLOG_VARIANT}.Dockerfile

docker buildx build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
Expand Down
2 changes: 1 addition & 1 deletion utils/build/build_python_base_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docker buildx build --load --progress=plain -f utils/build/docker/python/flask-p
docker buildx build --load --progress=plain -f utils/build/docker/python/uwsgi-poc.base.Dockerfile -t datadog/system-tests:uwsgi-poc.base-v2 .

if [ "$1" = "--push" ]; then
docker push datadog/system-tests:fastapi.base-v0
docker push datadog/system-tests:fastapi.base-v0
docker push datadog/system-tests:python3.12.base-v2
docker push datadog/system-tests:django-poc.base-v1
docker push datadog/system-tests:flask-poc.base-v4
Expand Down
2 changes: 1 addition & 1 deletion utils/build/build_tracer_buddies.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# buddies are weblog app in another lang
# they are used in the CROSSED_TRACING_LIBRARIES scenario, where we can tests data propagation between different languages
# they are used in the CROSSED_TRACING_LIBRARIES scenario, where we can tests data propagation between different languages

docker buildx build --load --progress=plain -f utils/build/docker/python/flask-poc.Dockerfile -t datadog/system-tests:python_buddy-v0 .
docker buildx build --load --progress=plain -f utils/build/docker/nodejs/express4.Dockerfile -t datadog/system-tests:nodejs_buddy-v0 .
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/cpp/nginx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY utils/build/docker/cpp/ binaries* /builds/

WORKDIR /builds

# NGINX Plugin setup
# NGINX Plugin setup
RUN ./install_ddtrace.sh

# Profiling setup
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/cpp/nginx/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ FILENAME=ngx_http_datadog_module-appsec-$ARCH-$NGINX_VERSION.so
if [ -f "$FILENAME" ]; then
echo "Install NGINX plugin from binaries/$FILENAME"
cp $FILENAME /usr/lib/nginx/modules/ngx_http_datadog_module.so
NGINX_DATADOG_VERSION="6.6.6" # TODO : get the version from the file ?
NGINX_DATADOG_VERSION="6.6.6" # TODO : get the version from the file ?
else
NGINX_DATADOG_VERSION="$(get_latest_release DataDog/nginx-datadog)"
TARBALL="$FILENAME.tgz"
Expand Down
4 changes: 2 additions & 2 deletions utils/build/docker/cpp/parametric/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ git_clone_latest_release (){
url_to_clone="https://github.com/DataDog/dd-trace-cpp"
latest_release=$(curl -s https://api.github.com/repos/DataDog/dd-trace-cpp/releases/latest | jq '.tag_name'| tr -d '"')
echo "$latest_release" > SYSTEM_TESTS_LIBRARY_VERSION
git_clone "$url_to_clone" "$latest_release"
git_clone "$url_to_clone" "$latest_release"
}

get_version_from_binaries() {
Expand All @@ -29,7 +29,7 @@ cd /usr/app

if [ -e /binaries/cpp-load-from-git ]; then
echo "install from file cpp-load-from-git"
target=$(cat /binaries/cpp-load-from-git)
target=$(cat /binaries/cpp-load-from-git)
url=$(echo "$target" | cut -d "@" -f 1)
branch=$(echo "$target" | cut -d "@" -f 2)
#Clone from git, get version from file version.cpp and configure make to use binaries/dd-trace-cpp folder
Expand Down
4 changes: 2 additions & 2 deletions utils/build/docker/dotnet/Controllers/TagValueController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public IActionResult ApiSecurityForm([FromRoute(Name = "tag_value")] int tagValu
Response.Headers["x-option"] = xOption;
return Content("Ok");
}

[HttpPost("api_match_AS00{tag_value}/{status_code}")]
[Consumes("application/json")]
// ReSharper disable once InconsistentNaming, system tests demand it
Expand Down Expand Up @@ -116,7 +116,7 @@ public IActionResult ApiSecurityRcJson([FromRoute(Name = "element")] string elem
HttpContext.Response.StatusCode = statusCode;
return Content("Ok");
}

[HttpPost("api_rc_{element}/{status_code}")]
[Consumes("application/x-www-form-urlencoded")]
public IActionResult ApiSecurityRc([FromRoute(Name = "element")] string elementValue,
Expand Down
6 changes: 3 additions & 3 deletions utils/build/docker/dotnet/Dependencies/MongoDbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public MongoDbHelper(string connectionString, string databaseName)
_client = new MongoClient(connectionString);
_database = _client.GetDatabase(databaseName);
}

public BsonDocument Find(string collectionName, string json)
{
var collection = _database.GetCollection<BsonDocument>(collectionName);
return collection.Find(json).FirstOrDefault();
}

public BsonDocument Find(string collectionName, BsonDocument filter)
{
var collection = _database.GetCollection<BsonDocument>(collectionName);
return collection.Find(filter).FirstOrDefault();
}

public static BsonDocument CreateSimpleDocument(string key, string value)
{
return new BsonDocument(key, value);
Expand Down
12 changes: 6 additions & 6 deletions utils/build/docker/dotnet/Endpoints/DbmEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Register(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routeBui
{
var integration = context.Request.Query["integration"];
if (integration == "npgsql")
if (integration == "npgsql")
{
await using (var connection = new NpgsqlConnection(Constants.NpgSqlConnectionString))
{
Expand All @@ -27,10 +27,10 @@ public void Register(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routeBui
}
await context.Response.WriteAsync("NpgSql query executed.");
}
else if (integration == "mysql")
}
else if (integration == "mysql")
{
await using (var connection = new MySqlConnection(Constants.MySqlConnectionString))
await using (var connection = new MySqlConnection(Constants.MySqlConnectionString))
{
var command = new MySqlCommand("SELECT version()", connection);
connection.Open();
Expand All @@ -39,8 +39,8 @@ public void Register(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder routeBui
}
await context.Response.WriteAsync("MySql query executed.");
}
else if (integration == "sqlclient")
}
else if (integration == "sqlclient")
{
await using (var connection = new SqlConnection(Constants.SqlClientConnectionString))
{
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/dotnet/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void ConfigureServices(IServiceCollection services)
{
options.ModelBinderProviders.Insert(0, new ModelBinderSwitcherProvider());
}).AddXmlSerializerFormatters();

var identityBuilder = services.AddIdentity<IdentityUser, IdentityRole>(
o =>
{
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/dotnet/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ "${UDS_WEBLOG:-0}" = "1" ]; then
fi

if ( ! dotnet app.dll); then
echo recovering dump to /var/log/system-tests/dumps
echo recovering dump to /var/log/system-tests/dumps
mkdir -p /var/log/system-tests/dumps
find /tmp -name 'coredump*' -exec cp '{}' /var/log/system-tests/dumps \;
chmod -R 644 /var/log/system-tests/dumps/* || true
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/dotnet/install_ddtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else
artifact=datadog-dotnet-apm-${DDTRACE_VERSION}.arm64.tar.gz
else
artifact=datadog-dotnet-apm-${DDTRACE_VERSION}.tar.gz
fi
fi

echo "Using artifact ${artifact}"
curl -L https://github.com/DataDog/dd-trace-dotnet/releases/download/v${DDTRACE_VERSION}/${artifact} --output ${artifact}
Expand Down
38 changes: 19 additions & 19 deletions utils/build/docker/dotnet/parametric/Endpoints/ApmTestApiOtel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public abstract class ApmTestApiOtel : ApmTestApi
{
internal static readonly ActivitySource ApmTestApiActivitySource = new("ApmTestApi");
internal static readonly Dictionary<ulong, Activity> Activities = new();

public static void MapApmOtelEndpoints(WebApplication app)
{
app.MapPost("/trace/otel/start_span", OtelStartSpan);
Expand Down Expand Up @@ -38,7 +38,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
if (requestBodyObject!.TryGetValue("parent_id", out var parentId))
{
var stringParentId = parentId.ToString();

if (stringParentId is not "0")
{
var parentActivity = FindActivity(parentId);
Expand All @@ -52,7 +52,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
var extractedContext = _spanContextExtractor.Extract(
((Newtonsoft.Json.Linq.JArray)headersList).ToObject<string[][]>(),
getter: GetHeaderValues!);

_logger.LogInformation("Extracted SpanContext: {ExtractedContext}", extractedContext);

if (extractedContext is not null)
Expand Down Expand Up @@ -112,7 +112,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
break;
}
}

var linksList = new List<ActivityLink>();

if (requestBodyObject.TryGetValue("links", out var links))
Expand All @@ -133,7 +133,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
{
contextToLink = FindActivity(parentSpanLink).Context;
}
else
else
{
var extractedContext = _spanContextExtractor.Extract(
((Newtonsoft.Json.Linq.JArray)spanLink["http_headers"]).ToObject<string[][]>(),
Expand Down Expand Up @@ -164,7 +164,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
tags: null,
links: linksList,
startTime);

if (activity is null)
{
throw new ApplicationException("Failed to start activity. Make sure there are listeners registered.");
Expand Down Expand Up @@ -193,7 +193,7 @@ private static async Task<string> OtelStartSpan(HttpRequest request)
trace_id = traceId,
span_id = spanId,
});

_logger.LogInformation("OtelStartSpanReturn: {Result}", result);
return result;
}
Expand All @@ -211,12 +211,12 @@ private static async Task OtelEndSpan(HttpRequest request)
DateTimeOffset convertedTimestamp = new DateTime(1970, 1, 1) + TimeSpan.FromMicroseconds(Convert.ToInt64(requestBodyObject["timestamp"]));
activity.SetEndTime(convertedTimestamp.UtcDateTime);
}

activity.Stop();

_logger.LogInformation("OtelEndSpanReturn");
}
}

private static async Task<string> OtelIsRecording(HttpRequest request)
{
var requestBodyObject = await DeserializeRequestObjectAsync(request.Body);
Expand All @@ -229,9 +229,9 @@ private static async Task<string> OtelIsRecording(HttpRequest request)
{
is_recording = activity.IsAllDataRequested
});

_logger.LogInformation("OtelIsRecordingReturn: {Result}", result);

return result;
}

Expand All @@ -242,7 +242,7 @@ private static async Task<string> OtelSpanContext(HttpRequest request)
_logger.LogInformation("OtelSpanContext: {RequestBodyObject}", requestBodyObject);

var activity = FindActivity(requestBodyObject["span_id"]);

var result = JsonConvert.SerializeObject(new
{
trace_id = activity.TraceId.ToString(),
Expand Down Expand Up @@ -291,7 +291,7 @@ private static async Task OtelSetName(HttpRequest request)

_logger.LogInformation("OtelSetName");
}

private static async Task OtelSetAttributes(HttpRequest request)
{
var requestBodyObject = await DeserializeRequestObjectAsync(request.Body);
Expand Down Expand Up @@ -379,9 +379,9 @@ private static async Task<string> OtelFlushSpans(HttpRequest request)
var requestBodyObject = await DeserializeRequestObjectAsync(request.Body);

_logger.LogInformation("OtelFlushSpans: {RequestBodyObject}", requestBodyObject);

await FlushSpans();

var result = JsonConvert.SerializeObject(new
{
success = true,
Expand All @@ -401,14 +401,14 @@ private static async Task OtelFlushTraceStats(HttpRequest request)

_logger.LogInformation("OtelFlushTraceStatsReturn");
}

// Helper methods:
private static async Task<Dictionary<string, object>> DeserializeRequestObjectAsync(Stream requestBody)
{
var headerRequestBody = await new StreamReader(requestBody).ReadToEndAsync();
return JsonConvert.DeserializeObject<Dictionary<string, object>>(headerRequestBody)!;
}

private static Activity FindActivity(object activityId)
{
if (Activities.TryGetValue(Convert.ToUInt64(activityId.ToString()), out var activity))
Expand All @@ -418,7 +418,7 @@ private static Activity FindActivity(object activityId)

throw new ApplicationException($"Activity not found with span id {activityId}.");
}

private static void SetTag(Activity activity, Dictionary<string,object>? attributes)
{
if (attributes is null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.9-eclipse-temurin-11
FROM maven:3.9-eclipse-temurin-11

COPY ./utils/build/docker/java/install_ddtrace.sh binaries* /binaries/
RUN /binaries/install_ddtrace.sh
Expand Down
2 changes: 1 addition & 1 deletion utils/build/docker/java/spring-boot-3-native.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WORKDIR /app

# Copy application sources and cache dependencies
COPY ./utils/build/docker/java/spring-boot-3-native/pom.xml .
RUN /opt/apache-maven-3.8.6/bin/mvn -P native -B dependency:go-offline
RUN /opt/apache-maven-3.8.6/bin/mvn -P native -B dependency:go-offline
COPY ./utils/build/docker/java/spring-boot-3-native/src ./src

# Copy tracer
Expand Down
Loading

0 comments on commit e04318f

Please sign in to comment.