Skip to content

Commit

Permalink
additional removals
Browse files Browse the repository at this point in the history
  • Loading branch information
lachmatt committed Jan 5, 2024
1 parent dee3f56 commit 664bcd1
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 1,290 deletions.
6 changes: 0 additions & 6 deletions docs/internal/internal-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ These settings should be never used by the users.
|-|-|-|
| `SIGNALFX_AGENT_HOST` | The Agent host where the tracer can send traces. | |
| `SIGNALFX_APM_RECEIVER_PORT` | The port for Trace Agent binding. | `8126` |
| `SIGNALFX_CIVISIBILITY_AGENTLESS_ENABLED` | Enable to activate Agentless in CI Visibility. | `false` |
| `SIGNALFX_CIVISIBILITY_AGENTLESS_URL` | Configuration key for setting the agentless url endpoint. | |
| `SIGNALFX_CIVISIBILITY_CODE_COVERAGE_ENABLED` | Configuration key for enabling or disabling Code Coverage in CI Visibility. | `false` |
| `SIGNALFX_CIVISIBILITY_CODE_COVERAGE_SNK_FILEPATH` | Configuration key for re-signing assemblies after the Code Coverage modification. | |
| `SIGNALFX_CIVISIBILITY_ENABLED` | Enable to activate CI Visibility. | `false` |
| `SIGNALFX_CIVISIBILITY_LOGS_ENABLED` | Enable to activate Logs direct submission. | `false` |
| `SIGNALFX_DOGSTATSD_ARGS` | Comma-separated list of arguments to be passed to the DogStatsD process. | |
| `SIGNALFX_DOGSTATSD_PATH` | The DogStatsD path for when a standalone instance needs to be started. | |
| `SIGNALFX_DOGSTATSD_PIPE_NAME` | The named pipe that DogStatsD binds to. | |
Expand Down
12 changes: 0 additions & 12 deletions tracer/src/Datadog.Trace.BenchmarkDotNet/DatadogExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ public class DatadogExporter : IExporter

private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DatadogExporter));

static DatadogExporter()
{
try
{
Environment.SetEnvironmentVariable(Configuration.ConfigurationKeys.CIVisibility.Enabled, "1", EnvironmentVariableTarget.Process);
}
catch
{
// .
}
}

/// <inheritdoc />
public string Name => nameof(DatadogExporter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public void Process()
}
else if (tracerTarget == TracerTarget.Net461)
{
_logger.Debug($"Assembly: {FilePath}, is a net461 signed assembly, a .snk file is required ({Configuration.ConfigurationKeys.CIVisibility.CodeCoverageSnkFile} environment variable).");
return;
}
}
Expand Down
9 changes: 0 additions & 9 deletions tracer/src/Datadog.Trace.MSBuild/DatadogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ public class DatadogLogger : INodeLogger

static DatadogLogger()
{
try
{
Environment.SetEnvironmentVariable(Configuration.ConfigurationKeys.CIVisibility.Enabled, "1", EnvironmentVariableTarget.Process);
}
catch
{
// .
}

CIVisibility.Initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ public CICodeCoveragePayload(int maxItemsPerPayload = DefaultMaxItemsPerPayload,
if (!string.IsNullOrWhiteSpace(agentlessUrl))
{
var builder = new UriBuilder(agentlessUrl);
builder.Path = "api/v2/citestcov";
Url = builder.Uri;
}
else
{
Url = new UriBuilder(
scheme: "https",
host: "event-platform-intake." + CIVisibility.Settings.Site,
port: 443,
pathValue: "api/v2/citestcov").Uri;
host: CIVisibility.Settings.Site,
portNumber: 443).Uri;
}

// We call reset here to add the dummy event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ public CITestCyclePayload(IFormatterResolver formatterResolver = null)
if (!string.IsNullOrWhiteSpace(agentlessUrl))
{
var builder = new UriBuilder(agentlessUrl);
builder.Path = "api/v2/citestcycle";
Url = builder.Uri;
}
else
{
Url = new UriBuilder(
scheme: "https",
host: "citestcycle-intake." + CIVisibility.Settings.Site,
port: 443,
pathValue: "api/v2/citestcycle").Uri;
host: CIVisibility.Settings.Site,
portNumber: 443)
.Uri;
}
}

Expand Down
59 changes: 1 addition & 58 deletions tracer/src/Datadog.Trace/Ci/CIVisibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
using Datadog.Trace.Configuration;
using Datadog.Trace.Logging;
using Datadog.Trace.Pdb;
using Datadog.Trace.Util;

namespace Datadog.Trace.Ci
{
internal class CIVisibility
{
private static readonly CIVisibilitySettings _settings = CIVisibilitySettings.FromDefaultSources();
private static int _firstInitialization = 1;
private static Lazy<bool> _enabledLazy = new Lazy<bool>(() => InternalEnabled(), true);
internal static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(CIVisibility));

public static bool Enabled => _enabledLazy.Value;
public static bool Enabled => false;

public static bool IsRunning => Interlocked.CompareExchange(ref _firstInitialization, 0, 0) == 0;

Expand Down Expand Up @@ -156,60 +154,5 @@ private static async Task ShutdownAsync()
await InternalFlushAsync().ConfigureAwait(false);
MethodSymbolResolver.Instance.Clear();
}

private static bool InternalEnabled()
{
var processName = ProcessHelpers.GetCurrentProcessName() ?? string.Empty;

// By configuration
if (_settings.Enabled)
{
// When is enabled by configuration we only enable it to the testhost child process if the process name is dotnet.
if (processName.Equals("dotnet", StringComparison.OrdinalIgnoreCase) && Environment.CommandLine.IndexOf("testhost.dll", StringComparison.OrdinalIgnoreCase) == -1)
{
Log.Information("CI Visibility disabled because the process name is 'dotnet' but the commandline doesn't contain 'testhost.dll': {cmdline}", Environment.CommandLine);
return false;
}

Log.Information("CI Visibility Enabled by Configuration");
return true;
}

// Try to autodetect based in the domain name.
var domainName = AppDomain.CurrentDomain.FriendlyName ?? string.Empty;
if (domainName.StartsWith("testhost", StringComparison.Ordinal) ||
domainName.StartsWith("vstest", StringComparison.Ordinal) ||
domainName.StartsWith("xunit", StringComparison.Ordinal) ||
domainName.StartsWith("nunit", StringComparison.Ordinal) ||
domainName.StartsWith("MSBuild", StringComparison.Ordinal))
{
Log.Information("CI Visibility Enabled by Domain name whitelist");
PropagateCiVisibilityEnvironmentVariable();
return true;
}

// Try to autodetect based in the process name.
if (processName.StartsWith("testhost.", StringComparison.Ordinal))
{
Log.Information("CI Visibility Enabled by Process name whitelist");
PropagateCiVisibilityEnvironmentVariable();
return true;
}

return false;

static void PropagateCiVisibilityEnvironmentVariable()
{
try
{
// Set the configuration key to propagate the configuration to child processes.
Environment.SetEnvironmentVariable(ConfigurationKeys.CIVisibility.Enabled, "1", EnvironmentVariableTarget.Process);
}
catch
{
// .
}
}
}
}
}
30 changes: 12 additions & 18 deletions tracer/src/Datadog.Trace/Ci/Configuration/CIVisibilitySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

// Modified by Splunk Inc.

using System;
using Datadog.Trace.Configuration;

Expand All @@ -12,32 +14,24 @@ internal class CIVisibilitySettings
{
public CIVisibilitySettings(IConfigurationSource source)
{
Enabled = source?.GetBool(ConfigurationKeys.CIVisibility.Enabled) ?? false;
Agentless = source?.GetBool(ConfigurationKeys.CIVisibility.AgentlessEnabled) ?? false;
Logs = source?.GetBool(ConfigurationKeys.CIVisibility.Logs) ?? false;
ApiKey = source?.GetString(ConfigurationKeys.ApiKey);
Site = source?.GetString(ConfigurationKeys.Site) ?? "datadoghq.com";
AgentlessUrl = source?.GetString(ConfigurationKeys.CIVisibility.AgentlessUrl);
Enabled = false;
Agentless = false;
Logs = false;
ApiKey = string.Empty;
Site = "localhost";
AgentlessUrl = string.Empty;

// By default intake payloads has a 5MB limit
MaximumAgentlessPayloadSize = 5 * 1024 * 1024;

ProxyHttps = source?.GetString(ConfigurationKeys.Proxy.ProxyHttps);
var proxyNoProxy = source?.GetString(ConfigurationKeys.Proxy.ProxyNoProxy) ?? string.Empty;
ProxyNoProxy = proxyNoProxy.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
ProxyHttps = string.Empty;
ProxyNoProxy = Array.Empty<string>();

TracerSettings = new TracerSettings(source);

if (Logs)
{
// Enable the direct log submission
TracerSettings.LogSubmissionSettings.DirectLogSubmissionEnabledIntegrations.Add("XUnit");
TracerSettings.LogSubmissionSettings.DirectLogSubmissionBatchPeriod = TimeSpan.FromSeconds(1);
}

// Code coverage
CodeCoverageEnabled = source?.GetBool(ConfigurationKeys.CIVisibility.CodeCoverage) ?? false;
CodeCoverageSnkFilePath = source?.GetString(ConfigurationKeys.CIVisibility.CodeCoverageSnkFile);
CodeCoverageEnabled = false;
CodeCoverageSnkFilePath = string.Empty;
}

/// <summary>
Expand Down
40 changes: 0 additions & 40 deletions tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,46 +429,6 @@ internal static partial class ConfigurationKeys
/// <seealso cref="TracerSettings.QueryStringReportingEnabled"/>
public const string QueryStringReportingEnabled = "SIGNALFX_HTTP_SERVER_TAG_QUERY_STRING";

/// <summary>
/// String constants for CI Visibility configuration keys.
/// </summary>
public static class CIVisibility
{
/// <summary>
/// Configuration key for enabling or disabling CI Visibility.
/// Default value is false (disabled).
/// </summary>
public const string Enabled = "SIGNALFX_CIVISIBILITY_ENABLED";

/// <summary>
/// Configuration key for enabling or disabling Agentless in CI Visibility.
/// Default value is false (disabled).
/// </summary>
public const string AgentlessEnabled = "SIGNALFX_CIVISIBILITY_AGENTLESS_ENABLED";

/// <summary>
/// Configuration key for setting the agentless url endpoint
/// </summary>
public const string AgentlessUrl = "SIGNALFX_CIVISIBILITY_AGENTLESS_URL";

/// <summary>
/// Configuration key for enabling or disabling Logs direct submission.
/// Default value is false (disabled).
/// </summary>
public const string Logs = "SIGNALFX_CIVISIBILITY_LOGS_ENABLED";

/// <summary>
/// Configuration key for enabling or disabling Code Coverage in CI Visibility.
/// Default value is false (disabled).
/// </summary>
public const string CodeCoverage = "SIGNALFX_CIVISIBILITY_CODE_COVERAGE_ENABLED";

/// <summary>
/// Configuration key for re-signing assemblies after the Code Coverage modification.
/// </summary>
public const string CodeCoverageSnkFile = "SIGNALFX_CIVISIBILITY_CODE_COVERAGE_SNK_FILEPATH";
}

/// <summary>
/// String constants for proxy configuration keys.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using Datadog.Trace.Configuration;
using Datadog.Trace.PlatformHelpers;

namespace Datadog.Trace.Logging.DirectSubmission
{
Expand All @@ -20,92 +16,11 @@ namespace Datadog.Trace.Logging.DirectSubmission
/// </summary>
internal class DirectLogSubmissionSettings
{
private const string DefaultSource = "csharp";
private const DirectSubmissionLogLevel DefaultMinimumLevel = DirectSubmissionLogLevel.Information;
private const int DefaultBatchSizeLimit = 1000;
private const int DefaultQueueSizeLimit = 100_000;
private const int DefaultBatchPeriodSeconds = 2;

public DirectLogSubmissionSettings()
: this(source: null)
{
}

public DirectLogSubmissionSettings(IConfigurationSource? source)
{
DirectLogSubmissionHost = string.Empty;
DirectLogSubmissionSource = DefaultSource;

DirectLogSubmissionUrl = string.Empty;

DirectLogSubmissionMinimumLevel = DefaultMinimumLevel;

DirectLogSubmissionGlobalTags = new Dictionary<string, string>();

DirectLogSubmissionEnabledIntegrations = new HashSet<string>();

DirectLogSubmissionBatchSizeLimit = DefaultBatchSizeLimit;

DirectLogSubmissionQueueSizeLimit = DefaultQueueSizeLimit;

DirectLogSubmissionBatchPeriod = TimeSpan.FromSeconds(DefaultBatchPeriodSeconds);

SignalFxAccessToken = string.Empty;

LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled);
}

/// <summary>
/// Gets or Sets the integrations enabled for direct log submission
/// </summary>
internal HashSet<string> DirectLogSubmissionEnabledIntegrations { get; set; }

/// <summary>
/// Gets or Sets the originating host name for direct logs submission
/// </summary>
internal string DirectLogSubmissionHost { get; set; }

/// <summary>
/// Gets or Sets the originating source for direct logs submission
/// </summary>
internal string DirectLogSubmissionSource { get; set; }

/// <summary>
/// Gets or sets the global tags, which are applied to all directly submitted logs. If not provided,
/// <see cref="TracerSettings.GlobalTags"/> are used instead
/// </summary>
internal IDictionary<string, string> DirectLogSubmissionGlobalTags { get; set; }

/// <summary>
/// Gets or sets the url to send logs to
/// </summary>
internal string? DirectLogSubmissionUrl { get; set; }

/// <summary>
/// Gets or sets the minimum level logs should have to be sent to the intake.
/// </summary>
internal DirectSubmissionLogLevel DirectLogSubmissionMinimumLevel { get; set; }

/// <summary>
/// Gets or sets the maximum number of logs to send at one time
/// </summary>
internal int DirectLogSubmissionBatchSizeLimit { get; set; }

/// <summary>
/// Gets or sets the maximum number of logs to hold in internal queue at any one time
/// </summary>
internal int DirectLogSubmissionQueueSizeLimit { get; set; }

/// <summary>
/// Gets or sets the time to wait between checking for batches
/// </summary>
internal TimeSpan DirectLogSubmissionBatchPeriod { get; set; }

/// <summary>
/// Gets or sets the SignalFx Access Token
/// </summary>
internal string? SignalFxAccessToken { get; set; }

/// <summary>
/// Gets or sets whether logs injection has been explicitly enabled or disabled
/// </summary>
Expand Down
Loading

0 comments on commit 664bcd1

Please sign in to comment.