Skip to content
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

[CI Visibility] Adding nullability checks #6374

Merged
merged 11 commits into from
Dec 5, 2024
80 changes: 0 additions & 80 deletions tracer/missing-nullability-files.csv
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ src/Datadog.Trace/AppSec/SecurityConstants.cs
src/Datadog.Trace/AppSec/SpanExtensions.cs
src/Datadog.Trace/AspNet/MimeTypes.cs
src/Datadog.Trace/AspNet/TracingHttpModule.cs
src/Datadog.Trace/Ci/CITracerManager.cs
src/Datadog.Trace/Ci/CITracerManagerFactory.cs
src/Datadog.Trace/Ci/CodeOwners.cs
src/Datadog.Trace/Ci/IEvent.cs
src/Datadog.Trace/ClrProfiler/AutomaticTracer.cs
src/Datadog.Trace/ClrProfiler/CallTargetKind.cs
src/Datadog.Trace/ClrProfiler/ClrNames.cs
Expand Down Expand Up @@ -151,7 +147,6 @@ src/Datadog.Trace/PlatformHelpers/ContainerMetadata.cs
src/Datadog.Trace/PlatformHelpers/PlatformStrategy.cs
src/Datadog.Trace/PlatformHelpers/ServiceFabric.cs
src/Datadog.Trace/Processors/ITagProcessor.cs
src/Datadog.Trace/Processors/ITraceProcessor.cs
src/Datadog.Trace/Processors/NormalizerTraceProcessor.cs
src/Datadog.Trace/Processors/ObfuscatorTagsProcessor.cs
src/Datadog.Trace/Processors/ObfuscatorTraceProcessor.cs
Expand Down Expand Up @@ -264,27 +259,6 @@ src/Datadog.Trace/Agent/Transports/MimeTypes.cs
src/Datadog.Trace/Agent/Transports/SocketHandlerRequestFactory.cs
src/Datadog.Trace/AppSec/Waf/WafConstants.cs
src/Datadog.Trace/AppSec/Waf/WafReturnCode.cs
src/Datadog.Trace/Ci/Agent/ApmAgentWriter.cs
src/Datadog.Trace/Ci/Agent/CIVisibilityProtocolWriter.cs
src/Datadog.Trace/Ci/Agent/CIWriterFileSender.cs
src/Datadog.Trace/Ci/Agent/CIWriterHttpSender.cs
src/Datadog.Trace/Ci/Agent/ICIVisibilityProtocolWriterSender.cs
src/Datadog.Trace/Ci/Agent/IEventWriter.cs
src/Datadog.Trace/Ci/Processors/OriginTagTraceProcessor.cs
src/Datadog.Trace/Ci/Processors/TestSuiteVisibilityProcessor.cs
src/Datadog.Trace/Ci/Sampling/CISampler.cs
src/Datadog.Trace/Ci/Tagging/TestModuleSpanTags.cs
src/Datadog.Trace/Ci/Tagging/TestSessionSpanTags.cs
src/Datadog.Trace/Ci/Tagging/TestSpanTags.cs
src/Datadog.Trace/Ci/Tagging/TestSuiteSpanTags.cs
src/Datadog.Trace/Ci/Tags/BenchmarkTestTags.cs
src/Datadog.Trace/Ci/Tags/BuildTags.cs
src/Datadog.Trace/Ci/Tags/CodeCoverageTags.cs
src/Datadog.Trace/Ci/Tags/CommonTags.cs
src/Datadog.Trace/Ci/Tags/IntelligentTestRunnerTags.cs
src/Datadog.Trace/Ci/Tags/TestTags.cs
src/Datadog.Trace/Ci/Telemetry/TelemetryHelper.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AutoInstrumentationExtensions.cs
src/Datadog.Trace/ClrProfiler/Helpers/HttpBypassHelper.cs
src/Datadog.Trace/ClrProfiler/Helpers/Interception.cs
src/Datadog.Trace/ClrProfiler/ServerlessInstrumentation/LambdaMetadata.cs
Expand Down Expand Up @@ -403,22 +377,6 @@ src/Datadog.Trace/AppSec/Waf/ReturnTypes.Managed/Rule.cs
src/Datadog.Trace/AppSec/Waf/ReturnTypes.Managed/RuleMatch.cs
src/Datadog.Trace/AppSec/Waf/ReturnTypes.Managed/Tags.cs
src/Datadog.Trace/AppSec/Waf/ReturnTypes.Managed/WafMatch.cs
src/Datadog.Trace/Ci/Agent/MessagePack/CIFormatterResolver.cs
src/Datadog.Trace/Ci/Agent/MessagePack/CIVisibilityEventMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/MessagePack/CoveragePayloadMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/MessagePack/EventMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/MessagePack/IEventMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/MessagePack/SpanMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/MessagePack/TestCoverageMessagePackFormatter.cs
src/Datadog.Trace/Ci/Agent/Payloads/CICodeCoveragePayload.cs
src/Datadog.Trace/Ci/Agent/Payloads/CITestCyclePayload.cs
src/Datadog.Trace/Ci/Agent/Payloads/CIVisibilityProtocolPayload.cs
src/Datadog.Trace/Ci/Agent/Payloads/EventPlatformPayload.cs
src/Datadog.Trace/Ci/Agent/Payloads/EventsBuffer.cs
src/Datadog.Trace/Ci/Agent/Payloads/MultipartPayload.cs
src/Datadog.Trace/Ci/Coverage/Attributes/AvoidCoverageAttribute.cs
src/Datadog.Trace/Ci/Coverage/Attributes/CoveredAssemblyAttribute.cs
src/Datadog.Trace/Ci/Coverage/Exceptions/PdbNotFoundException.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetClientInstrumentMethodsAttribute.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetConstants.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/AdoNetDefinitions.cs
Expand Down Expand Up @@ -551,7 +509,6 @@ src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Process/EnvironmentVariablesSc
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Process/ProcessStartIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Process/ProcessStartTags.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/RabbitMQ/RabbitMQConstants.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/Common.cs
src/Datadog.Trace/Debugger/Configurations/Models/Capture.cs
src/Datadog.Trace/Debugger/Configurations/Models/DebuggerExpression.cs
src/Datadog.Trace/Debugger/Configurations/Models/EvaluateAt.cs
Expand Down Expand Up @@ -589,7 +546,6 @@ src/Datadog.Trace/Util/Http/QueryStringObfuscation/NullObfuscator.cs
src/Datadog.Trace/Util/Http/QueryStringObfuscation/Obfuscator.cs
src/Datadog.Trace/Util/Http/QueryStringObfuscation/ObfuscatorBase.cs
src/Datadog.Trace/Util/Http/QueryStringObfuscation/ObfuscatorFactory.cs
src/Datadog.Trace/Ci/Coverage/Models/Tests/FileCoverage.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/MySql/MySqlDefinitions.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/Npgsql/NpgsqlDefinitions.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/AdoNet/Oracle/OracleDefinitions.cs
Expand Down Expand Up @@ -695,42 +651,6 @@ src/Datadog.Trace/ClrProfiler/AutoInstrumentation/MongoDb/BsonSerialization/Mong
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/IRedisNativeClient.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Redis/ServiceStack/RedisNativeClientSendReceiveIntegration_6_2_0.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestAssemblyInfo.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestClassInfo.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethod.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodInfo.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodOptions.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ITestMethodRunner.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/ItrSkipTestMethodExecutor.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/MsTestIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestAssemblyInfoExecuteAssemblyCleanupIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestAssemblyInfoRunAssemblyCleanupIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestAssemblyInfoRunAssemblyInitializeIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestCategoryAttributeStruct.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestClassInfoExecuteClassCleanupIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestClassInfoRunClassCleanupIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestClassInfoRunClassInitializeIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestContextStruct.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodContextStruct.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestMethodRunnerExecuteTestIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/TestPropertyAttributeStruct.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestOutcome.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultOutcome.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestResultStruct.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/MsTestV2/UnitTestRunnerRunCleanupIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/FailureSite.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ICompositeWorkItem.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IMethodInfo.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IPropertyBag.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IResultState.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITest.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestExecutionContext.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/ITestSuite.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/IWorkItem.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitWorkItemPerformWorkIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/NUnitWorkItemWorkItemCompleteIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/RunState.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Testing/NUnit/TestStatus.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Azure/Functions/Isolated/FunctionExecutionMiddlewareInvokeIntegration.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Grpc/GrpcLegacy/Client/CachedMetadataHelper.cs
src/Datadog.Trace/ClrProfiler/AutoInstrumentation/Grpc/GrpcLegacy/Client/TemporaryHeaders.cs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public IEnumerable<string> ExportToFiles(Summary summary, ILogger consoleLogger)

if (benchmarkCase.HasParameters)
{
var testParameters = new TestParameters { Arguments = new Dictionary<string, object>(), Metadata = new Dictionary<string, object>() };
var testParameters = new TestParameters { Arguments = new Dictionary<string, object>(), Metadata = new Dictionary<string, object?>() };
foreach (var parameter in benchmarkCase.Parameters.Items)
{
var parameterValue = ClrProfiler.AutoInstrumentation.Testing.Common.GetParametersValueData(parameter.Value);
Expand Down
100 changes: 50 additions & 50 deletions tracer/src/Datadog.Trace/Ci/Agent/ApmAgentWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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>
#nullable enable

using System;
using System.Collections.Generic;
Expand All @@ -11,70 +12,69 @@
using Datadog.Trace.Ci.EventModel;
using Datadog.Trace.Configuration;

namespace Datadog.Trace.Ci.Agent
namespace Datadog.Trace.Ci.Agent;

/// <summary>
/// APM Agent Writer for CI Visibility
/// </summary>
internal class ApmAgentWriter : IEventWriter
{
/// <summary>
/// APM Agent Writer for CI Visibility
/// </summary>
internal class ApmAgentWriter : IEventWriter
private const int DefaultMaxBufferSize = 1024 * 1024 * 10;

[ThreadStatic]
private static Span[]? _spanArray;
private readonly AgentWriter _agentWriter;

public ApmAgentWriter(ImmutableTracerSettings settings, Action<Dictionary<string, float>> updateSampleRates, IDiscoveryService discoveryService, int maxBufferSize = DefaultMaxBufferSize)
{
private const int DefaultMaxBufferSize = 1024 * 1024 * 10;
var partialFlushEnabled = settings.ExporterInternal.PartialFlushEnabledInternal;
var apiRequestFactory = TracesTransportStrategy.Get(settings.ExporterInternal);
var api = new Api(apiRequestFactory, null, updateSampleRates, partialFlushEnabled);
var statsAggregator = StatsAggregator.Create(api, settings, discoveryService);

[ThreadStatic]
private static Span[] _spanArray;
private readonly AgentWriter _agentWriter;
_agentWriter = new AgentWriter(api, statsAggregator, null, maxBufferSize: maxBufferSize, appsecStandaloneEnabled: settings.AppsecStandaloneEnabledInternal);
}

public ApmAgentWriter(ImmutableTracerSettings settings, Action<Dictionary<string, float>> updateSampleRates, IDiscoveryService discoveryService, int maxBufferSize = DefaultMaxBufferSize)
{
var partialFlushEnabled = settings.ExporterInternal.PartialFlushEnabledInternal;
var apiRequestFactory = TracesTransportStrategy.Get(settings.ExporterInternal);
var api = new Api(apiRequestFactory, null, updateSampleRates, partialFlushEnabled);
var statsAggregator = StatsAggregator.Create(api, settings, discoveryService);
public ApmAgentWriter(IApi api, int maxBufferSize = DefaultMaxBufferSize)
{
_agentWriter = new AgentWriter(api, null, null, maxBufferSize: maxBufferSize);
}

_agentWriter = new AgentWriter(api, statsAggregator, null, maxBufferSize: maxBufferSize, appsecStandaloneEnabled: settings.AppsecStandaloneEnabledInternal);
}
public void WriteEvent(IEvent @event)
{
// To keep compatibility with the agent version of the payload, any IEvent conversion to span
// goes here.

public ApmAgentWriter(IApi api, int maxBufferSize = DefaultMaxBufferSize)
if (_spanArray is not { } spanArray)
{
_agentWriter = new AgentWriter(api, null, null, maxBufferSize: maxBufferSize);
spanArray = new Span[1];
_spanArray = spanArray;
}

public void WriteEvent(IEvent @event)
if (CIVisibilityEventsFactory.GetSpan(@event) is { } span)
{
// To keep compatibility with the agent version of the payload, any IEvent conversion to span
// goes here.

if (_spanArray is not { } spanArray)
{
spanArray = new Span[1];
_spanArray = spanArray;
}

if (CIVisibilityEventsFactory.GetSpan(@event) is { } span)
{
spanArray[0] = span;
WriteTrace(new ArraySegment<Span>(spanArray));
}
spanArray[0] = span;
WriteTrace(new ArraySegment<Span>(spanArray));
}
}

public Task FlushAndCloseAsync()
{
return _agentWriter.FlushAndCloseAsync();
}
public Task FlushAndCloseAsync()
{
return _agentWriter.FlushAndCloseAsync();
}

public Task FlushTracesAsync()
{
return _agentWriter.FlushTracesAsync();
}
public Task FlushTracesAsync()
{
return _agentWriter.FlushTracesAsync();
}

public Task<bool> Ping()
{
return _agentWriter.Ping();
}
public Task<bool> Ping()
{
return _agentWriter.Ping();
}

public void WriteTrace(ArraySegment<Span> trace)
{
_agentWriter.WriteTrace(trace);
}
public void WriteTrace(ArraySegment<Span> trace)
{
_agentWriter.WriteTrace(trace);
}
}
Loading
Loading