diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Unshipped.txt index 95461d9b80..a3c6cc40bf 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/.publicApi/PublicAPI.Unshipped.txt @@ -1,6 +1,6 @@ OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.ElasticsearchClientInstrumentationOptions() -> void -OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.Enrich.get -> System.Action +OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.Enrich.get -> System.Action? OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.Enrich.set -> void OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.MaxDbStatementLength.get -> int OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.MaxDbStatementLength.set -> void @@ -11,6 +11,6 @@ OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumenta OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.SuppressDownstreamInstrumentation.get -> bool OpenTelemetry.Instrumentation.ElasticsearchClient.ElasticsearchClientInstrumentationOptions.SuppressDownstreamInstrumentation.set -> void OpenTelemetry.Trace.TracerProviderBuilderExtensions -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddElasticsearchClientInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs index dcb91ef5c1..3c7e647ef4 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs @@ -41,5 +41,5 @@ public class ElasticsearchClientInstrumentationOptions /// object: the raw object from which additional information can be extracted to enrich the activity. /// The type of this object depends on the event, which is given by the above parameter. /// - public Action Enrich { get; set; } + public Action? Enrich { get; set; } } diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs index af907e627d..315c7a4e44 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs @@ -28,17 +28,17 @@ internal class ElasticsearchRequestPipelineDiagnosticListener : ListenerHandler internal static readonly string ActivitySourceName = AssemblyName.Name; internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Assembly.GetPackageVersion()); - private static readonly Regex ParseRequest = new Regex(@"\n# Request:\r?\n(\{.*)\n# Response", RegexOptions.Compiled | RegexOptions.Singleline); - private static readonly ConcurrentDictionary MethodNameCache = new ConcurrentDictionary(); + private static readonly Regex ParseRequest = new(@"\n# Request:\r?\n(\{.*)\n# Response", RegexOptions.Compiled | RegexOptions.Singleline); + private static readonly ConcurrentDictionary MethodNameCache = new(); private readonly ElasticsearchClientInstrumentationOptions options; - private readonly MultiTypePropertyFetcher uriFetcher = new MultiTypePropertyFetcher("Uri"); - private readonly MultiTypePropertyFetcher methodFetcher = new MultiTypePropertyFetcher("Method"); - private readonly MultiTypePropertyFetcher debugInformationFetcher = new MultiTypePropertyFetcher("DebugInformation"); - private readonly MultiTypePropertyFetcher httpStatusFetcher = new MultiTypePropertyFetcher("HttpStatusCode"); - private readonly MultiTypePropertyFetcher originalExceptionFetcher = new MultiTypePropertyFetcher("OriginalException"); - private readonly MultiTypePropertyFetcher failureReasonFetcher = new MultiTypePropertyFetcher("FailureReason"); - private readonly MultiTypePropertyFetcher responseBodyFetcher = new MultiTypePropertyFetcher("ResponseBodyInBytes"); + private readonly MultiTypePropertyFetcher uriFetcher = new("Uri"); + private readonly MultiTypePropertyFetcher methodFetcher = new("Method"); + private readonly MultiTypePropertyFetcher debugInformationFetcher = new("DebugInformation"); + private readonly MultiTypePropertyFetcher httpStatusFetcher = new("HttpStatusCode"); + private readonly MultiTypePropertyFetcher originalExceptionFetcher = new("OriginalException"); + private readonly MultiTypePropertyFetcher failureReasonFetcher = new("FailureReason"); + private readonly MultiTypePropertyFetcher responseBodyFetcher = new("ResponseBodyInBytes"); public ElasticsearchRequestPipelineDiagnosticListener(ElasticsearchClientInstrumentationOptions options) : base("Elasticsearch.Net.RequestPipeline") @@ -46,7 +46,7 @@ public ElasticsearchRequestPipelineDiagnosticListener(ElasticsearchClientInstrum this.options = options; } - public override void OnEventWritten(string name, object payload) + public override void OnEventWritten(string name, object? payload) { var activity = Activity.Current; Guard.ThrowIfNull(activity); @@ -61,7 +61,7 @@ public override void OnEventWritten(string name, object payload) } } - private static string GetDisplayName(Activity activity, object method, string elasticType = null) + private static string GetDisplayName(Activity activity, object? method, string? elasticType = null) { switch (activity.OperationName) { @@ -83,7 +83,7 @@ private static string GetDisplayName(Activity activity, object method, string el } } - private static string GetElasticIndex(Uri uri) + private static string? GetElasticIndex(Uri uri) { // first segment is always / if (uri.Segments.Length < 2) @@ -91,7 +91,7 @@ private static string GetElasticIndex(Uri uri) return null; } - // operations starting with _ are not indices (_cat, _search, etc) + // operations starting with _ are not indices (_cat, _search, etc.) if (uri.Segments[1].StartsWith("_", StringComparison.Ordinal)) { return null; @@ -123,7 +123,7 @@ private string ParseAndFormatRequest(string debugInformation) var request = ParseRequest.Match(debugInformation); if (request.Success) { - string body = request.Groups[1]?.Value?.Trim(); + string? body = request.Groups[1]?.Value?.Trim(); if (body == null) { return debugInformation; @@ -150,7 +150,7 @@ private string ParseAndFormatRequest(string debugInformation) return debugInformation; } - private void OnStartActivity(Activity activity, object payload) + private void OnStartActivity(Activity activity, object? payload) { // By this time, samplers have already run and // activity.IsAllDataRequested populated accordingly. @@ -226,7 +226,7 @@ private void OnStartActivity(Activity activity, object payload) } } - private void OnStopActivity(Activity activity, object payload) + private void OnStopActivity(Activity activity, object? payload) { if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj index 30383291e8..8bd24ba026 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj @@ -6,7 +6,6 @@ Elasticsearch instrumentation for OpenTelemetry .NET $(PackageTags);distributed-tracing Instrumentation.ElasticsearchClient- - disable $(SupportedNetTargets) $(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion) - disable