Skip to content

Commit

Permalink
Merge branch 'master' into joey/pr-4535-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyzhao2018 authored Oct 24, 2023
2 parents 21e71cc + d5e0ea1 commit 4fdf13a
Show file tree
Hide file tree
Showing 83 changed files with 724 additions and 6,074 deletions.
14 changes: 14 additions & 0 deletions Datadog.Trace.sln
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Datadog.Trace.Tools.dd_dotn
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AWS.DynamoDBv2", "tracer\test\test-applications\integrations\Samples.AWS.DynamoDBv2\Samples.AWS.DynamoDBv2.csproj", "{D59C5649-BE0E-4A33-B868-B652D8614534}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.Tools.Shared", "tracer\src\Datadog.Trace.Tools.Shared\Datadog.Trace.Tools.Shared.csproj", "{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Datadog.Trace.Tools.dd_dotnet.Tests", "tracer\test\Datadog.Trace.Tools.dd_dotnet.Tests\Datadog.Trace.Tools.dd_dotnet.Tests.csproj", "{4E9535E2-C918-4C39-9F1B-F182C185DE64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Amazon.Lambda.RuntimeSupport", "tracer\test\test-applications\integrations\Samples.Amazon.Lambda.RuntimeSupport\Samples.Amazon.Lambda.RuntimeSupport.csproj", "{18A6904A-5AFD-4816-AC3F-9F5E433720B5}"
EndProject
Global
Expand Down Expand Up @@ -1304,6 +1308,14 @@ Global
{D59C5649-BE0E-4A33-B868-B652D8614534}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D59C5649-BE0E-4A33-B868-B652D8614534}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D59C5649-BE0E-4A33-B868-B652D8614534}.Release|Any CPU.Build.0 = Release|Any CPU
{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0}.Release|Any CPU.Build.0 = Release|Any CPU
{4E9535E2-C918-4C39-9F1B-F182C185DE64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E9535E2-C918-4C39-9F1B-F182C185DE64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E9535E2-C918-4C39-9F1B-F182C185DE64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E9535E2-C918-4C39-9F1B-F182C185DE64}.Release|Any CPU.Build.0 = Release|Any CPU
{18A6904A-5AFD-4816-AC3F-9F5E433720B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18A6904A-5AFD-4816-AC3F-9F5E433720B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18A6904A-5AFD-4816-AC3F-9F5E433720B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -1520,6 +1532,8 @@ Global
{A9632530-0FB8-4156-BD3C-DD432527768E} = {8CEC2042-F11C-49F5-A674-2355793B600A}
{F594BFBE-1F71-4B3A-BBDA-C4372A6501E9} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{D59C5649-BE0E-4A33-B868-B652D8614534} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{7A1B9BFE-052D-435E-B27F-72AF3DDCC0A0} = {9E5F0022-0A50-40BF-AC6A-C3078585ECAB}
{4E9535E2-C918-4C39-9F1B-F182C185DE64} = {8CEC2042-F11C-49F5-A674-2355793B600A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Datadog.InstrumentedAssemblyGenerator;
using Datadog.InstrumentedAssemblyVerification;
using Datadog.Trace.Configuration.Telemetry;
using Datadog.Trace.Tools.Runner.Checks;
using Spectre.Console;

namespace Datadog.Trace.Tools.Runner;
Expand Down Expand Up @@ -174,8 +173,7 @@ private string GetLogDirectory(int? pid)
string logDirectory = null;
if (pid != null)
{
var process = ProcessInfo.GetProcessInfo(pid.Value);
logDirectory = process?.GetProcessLogDirectory();
logDirectory = ProcessConfiguration.GetProcessLogDirectory(pid.Value);
}

return logDirectory ?? Logging.DatadogLoggingFactory.GetLogDirectory(NullConfigurationTelemetry.Instance);
Expand Down
79 changes: 0 additions & 79 deletions tracer/src/Datadog.Trace.Tools.Runner/CheckAgentCommand.cs

This file was deleted.

75 changes: 75 additions & 0 deletions tracer/src/Datadog.Trace.Tools.Runner/CheckCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// <copyright file="CheckCommand.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Spectre.Console;

namespace Datadog.Trace.Tools.Runner
{
internal class CheckCommand : Command
{
private readonly ApplicationContext _applicationContext;

public CheckCommand(ApplicationContext applicationContext)
: base("check")
{
_applicationContext = applicationContext;

AddArgument(Command);

this.SetHandler(Execute);
}

public Argument<string[]> Command { get; } = new("command", CommandLineHelpers.ParseArrayArgument, isDefault: true);

private void Execute(InvocationContext context)
{
var tracerHome = Utils.GetHomePath(_applicationContext.RunnerFolder);

// pick the right one depending on the platform
var ddDotnet = (platform: _applicationContext.Platform, arch: RuntimeInformation.OSArchitecture, musl: Utils.IsAlpine()) switch
{
(Platform.Windows, Architecture.X64, _) => Path.Combine(tracerHome, "win-x64", "dd-dotnet.exe"),
(Platform.Windows, Architecture.X86, _) => Path.Combine(tracerHome, "win-x64", "dd-dotnet.exe"),
(Platform.Linux, Architecture.X64, false) => Path.Combine(tracerHome, "linux-x64", "dd-dotnet"),
(Platform.Linux, Architecture.X64, true) => Path.Combine(tracerHome, "linux-musl-x64", "dd-dotnet"),
(Platform.Linux, Architecture.Arm64, false) => Path.Combine(tracerHome, "linux-arm64", "dd-dotnet"),
(Platform.Linux, Architecture.Arm64, true) => Path.Combine(tracerHome, "linux-musl-arm64", "dd-dotnet"),
var other => throw new NotSupportedException(
$"Unsupported platform/architecture combination: ({other.platform}{(other.musl ? " musl" : string.Empty)}/{other.arch})")
};

var commandLine = string.Join(' ', Environment.GetCommandLineArgs().Skip(1));

if (!File.Exists(ddDotnet))
{
Utils.WriteError($"dd-dotnet not found at {ddDotnet}");
context.ExitCode = 1;
return;
}

if (_applicationContext.Platform == Platform.Linux)
{
// Make sure the dd-dotnet binary is executable
Process.Start("chmod", $"+x {ddDotnet}")!.WaitForExit();
}

var startInfo = new ProcessStartInfo(ddDotnet, commandLine) { UseShellExecute = false };

startInfo.EnvironmentVariables["DD_INTERNAL_OVERRIDE_COMMAND"] = "dd-trace";

var process = Process.Start(startInfo);
process.WaitForExit();

context.ExitCode = process.ExitCode;
}
}
}
Loading

0 comments on commit 4fdf13a

Please sign in to comment.