Skip to content

Small IPC changes #7352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@
<type fullname="System.Runtime.Serialization.StreamingContext" />
<type fullname="System.Runtime.Serialization.StreamingContextStates" />
<type fullname="System.Runtime.Versioning.TargetFrameworkAttribute" />
<type fullname="System.Runtime.Versioning.UnsupportedOSPlatformAttribute" />
<type fullname="System.RuntimeFieldHandle" />
<type fullname="System.RuntimeMethodHandle" />
<type fullname="System.RuntimeTypeHandle" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,41 @@ internal TracerSettings InitializeTracerSettings(CompositeConfigurationSource so
var newSource = new CompositeConfigurationSource([new DictionaryObjectConfigurationSource(additionalSource), source]);
return new TracerSettings(newSource, telemetry, new OverrideErrorLog());
}

public override string ToString()
{
var sb = StringBuilderCache.Acquire(StringBuilderCache.MaxBuilderSize);
sb.AppendFormat(
"{{ Enabled={0}, Agentless={1}, Site={2}, ApiKey={3}, AgentlessUrl={4}, MaximumAgentlessPayloadSize={5}, ProxyHttps={6}, ProxyNoProxy={7}, Logs={8}, CodeCoverageEnabled={9}, CodeCoverageSnkFilePath={10}, CodeCoveragePath={11}, CodeCoverageEnableJitOptimizations={12}, CodeCoverageMode={13}, GitUploadEnabled={14}, TestsSkippingEnabled={15}, IntelligentTestRunnerEnabled={16}, ForceAgentsEvpProxy={17}, InstallDatadogTraceInGac={18}, EarlyFlakeDetectionEnabled={19}, KnownTestsEnabled={20}, RumFlushWaitMillis={21}, TestSessionName='{22}', FlakyRetryEnabled={23}, FlakyRetryCount={24}, TotalFlakyRetryCount={25}, ImpactedTestsDetectionEnabled={26}, TestManagementEnabled={27} }}",
Enabled,
Agentless,
Site,
!string.IsNullOrEmpty(ApiKey) ? "<redacted>" : "null",
AgentlessUrl,
MaximumAgentlessPayloadSize,
ProxyHttps,
string.Join(", ", ProxyNoProxy ?? []),
Logs,
CodeCoverageEnabled,
CodeCoverageSnkFilePath,
CodeCoveragePath,
CodeCoverageEnableJitOptimizations,
CodeCoverageMode,
GitUploadEnabled,
TestsSkippingEnabled,
IntelligentTestRunnerEnabled,
ForceAgentsEvpProxy,
InstallDatadogTraceInGac,
EarlyFlakeDetectionEnabled,
KnownTestsEnabled,
RumFlushWaitMillis,
TestSessionName,
FlakyRetryEnabled,
FlakyRetryCount,
TotalFlakyRetryCount,
ImpactedTestsDetectionEnabled,
TestManagementEnabled);
return StringBuilderCache.GetStringAndRelease(sb);
}
}
}
15 changes: 11 additions & 4 deletions tracer/src/Datadog.Trace/Ci/Ipc/CircularChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal partial class CircularChannel : IChannel
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(CircularChannel));

private readonly MemoryMappedFile _mmf;
private readonly Mutex _mutex;
private readonly CrossPlatformLock _mutex;
private readonly CircularChannelSettings _settings;

private long _disposed;
Expand Down Expand Up @@ -72,9 +72,16 @@ public CircularChannel(string fileName, CircularChannelSettings settings)
}

_disposed = 0;
_mutex = new Mutex(
initiallyOwned: false,
FrameworkDescription.Instance.IsWindows() ? @$"Global\{Path.GetFileNameWithoutExtension(fileName)}" : $"{Path.GetFileNameWithoutExtension(fileName)}");
var lockName = Path.GetFileNameWithoutExtension(fileName);
Log.Debug("CircularChannel: Initializing with file {FileName} and lock name {LockName}", fileName, lockName);
if (CrossPlatformLock.TryOpenExisting(lockName, out var existingLock) && existingLock != null)
{
_mutex = existingLock;
}
else
{
_mutex = new CrossPlatformLock(lockName);
}

var hasHandle = _mutex.WaitOne(_settings.MutexTimeout);
if (!hasHandle)
Expand Down
Loading
Loading