From 9c963925d56951abf1e7f07ec166a890eb1d6a69 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Tue, 7 Feb 2023 22:52:22 +0000 Subject: [PATCH 1/7] [Instrumentation.AWSLambda] Fix analysis warnings (#959) --- .../AWSLambdaWrapper.cs | 30 +++++++++++-------- .../Implementation/AWSLambdaHttpUtils.cs | 2 +- .../SampleLambdaContext.cs | 14 ++++----- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs b/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs index 9359fc17b5..ba62e517cc 100644 --- a/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs +++ b/src/OpenTelemetry.Instrumentation.AWSLambda/AWSLambdaWrapper.cs @@ -22,6 +22,7 @@ using System.Threading.Tasks; using Amazon.Lambda.Core; using OpenTelemetry.Instrumentation.AWSLambda.Implementation; +using OpenTelemetry.Internal; using OpenTelemetry.Trace; namespace OpenTelemetry.Instrumentation.AWSLambda; @@ -69,6 +70,7 @@ public static TResult Trace( ILambdaContext context, ActivityContext parentContext = default) { + Guard.ThrowIfNull(lambdaHandler); return TraceInternal(tracerProvider, lambdaHandler, input, context, parentContext); } @@ -93,12 +95,15 @@ public static void Trace( ILambdaContext context, ActivityContext parentContext = default) { - Func func = (input, context) => + Guard.ThrowIfNull(lambdaHandler); + + object Handler(TInput input, ILambdaContext context) { lambdaHandler(input, context); return null; - }; - TraceInternal(tracerProvider, func, input, context, parentContext); + } + + TraceInternal(tracerProvider, Handler, input, context, parentContext); } /// @@ -123,12 +128,15 @@ public static Task TraceAsync( ILambdaContext context, ActivityContext parentContext = default) { - Func> func = async (input, context) => + Guard.ThrowIfNull(lambdaHandler); + + async Task Handler(TInput input, ILambdaContext context) { - await lambdaHandler(input, context); + await lambdaHandler(input, context).ConfigureAwait(false); return null; - }; - return TraceInternalAsync(tracerProvider, func, input, context, parentContext); + } + + return TraceInternalAsync(tracerProvider, Handler, input, context, parentContext); } /// @@ -154,6 +162,7 @@ public static Task TraceAsync( ILambdaContext context, ActivityContext parentContext = default) { + Guard.ThrowIfNull(lambdaHandler); return TraceInternalAsync(tracerProvider, lambdaHandler, input, context, parentContext); } @@ -182,10 +191,7 @@ internal static Activity OnFunctionStart(TInput input, ILambdaContext co private static void OnFunctionStop(Activity activity, TracerProvider tracerProvider) { - if (activity != null) - { - activity.Stop(); - } + activity?.Stop(); // force flush before function quit in case of Lambda freeze. tracerProvider?.ForceFlush(); @@ -239,7 +245,7 @@ private static async Task TraceInternalAsync( var activity = OnFunctionStart(input, context, parentContext); try { - var result = await handlerAsync(input, context); + var result = await handlerAsync(input, context).ConfigureAwait(false); AWSLambdaHttpUtils.SetHttpTagsFromResult(activity, result); return result; } diff --git a/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs b/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs index 94742e8fd8..0982d20c9b 100644 --- a/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs +++ b/src/OpenTelemetry.Instrumentation.AWSLambda/Implementation/AWSLambdaHttpUtils.cs @@ -97,7 +97,7 @@ internal static string GetQueryString(APIGatewayProxyRequest request) { queryString.Append(separator) .Append(HttpUtility.UrlEncode(parameterKvp.Key)) - .Append("=") + .Append('=') .Append(HttpUtility.UrlEncode(value)); separator = '&'; } diff --git a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/SampleLambdaContext.cs b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/SampleLambdaContext.cs index bc36ca20d8..8b77918a75 100644 --- a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/SampleLambdaContext.cs +++ b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/SampleLambdaContext.cs @@ -23,23 +23,23 @@ public class SampleLambdaContext : ILambdaContext { public string AwsRequestId { get; } = "testrequestid"; - public IClientContext ClientContext { get; } = null; + public IClientContext ClientContext { get; } public string FunctionName { get; } = "testfunction"; public string FunctionVersion { get; } = "latest"; - public ICognitoIdentity Identity { get; } = null; + public ICognitoIdentity Identity { get; } public string InvokedFunctionArn { get; } = "arn:aws:lambda:us-east-1:111111111111:function:testfunction"; - public ILambdaLogger Logger { get; } = null; + public ILambdaLogger Logger { get; } - public string LogGroupName { get; } = null; + public string LogGroupName { get; } - public string LogStreamName { get; } = null; + public string LogStreamName { get; } - public int MemoryLimitInMB { get; } = 0; + public int MemoryLimitInMB { get; } - public TimeSpan RemainingTime { get; } = default; + public TimeSpan RemainingTime { get; } } From 0c64c7495a83c375feb1a6c6ce1fad9ebc5024d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Wed, 8 Feb 2023 00:15:00 +0100 Subject: [PATCH 2/7] [Instrumentation.Owin] Remove AddOwinInstrumentation with default parameter (#929) Co-authored-by: Cijo Thomas --- .../.publicApi/net462/PublicAPI.Unshipped.txt | 3 ++- .../CHANGELOG.md | 2 ++ .../TracerProviderBuilderExtensions.cs | 14 +++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt index 028f956bd4..23c619652b 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.Owin/.publicApi/net462/PublicAPI.Unshipped.txt @@ -11,5 +11,6 @@ OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.ge OpenTelemetry.Instrumentation.Owin.OwinInstrumentationOptions.RecordException.set -> void OpenTelemetry.Trace.TracerProviderBuilderExtensions Owin.AppBuilderExtensions -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureOwinInstrumentationOptions = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddOwinInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder static Owin.AppBuilderExtensions.UseOpenTelemetry(this Owin.IAppBuilder appBuilder) -> Owin.IAppBuilder \ No newline at end of file diff --git a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md index 28f40866da..38e529310c 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md @@ -4,6 +4,8 @@ * Updated OpenTelemetry SDK to 1.3.2 ([#917](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/917)) +* Removes `AddOwinInstrumentation` method with default configure parameter. + ([#929](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/929)) ## 1.0.0-rc.3 diff --git a/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs index c2b26c796e..9a3e39835f 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.Owin/TracerProviderBuilderExtensions.cs @@ -29,16 +29,24 @@ public static class TracerProviderBuilderExtensions /// Enables the incoming requests automatic data collection for OWIN. /// /// being configured. - /// OWIN Request configuration options. + /// The instance of to chain the calls. + public static TracerProviderBuilder AddOwinInstrumentation(this TracerProviderBuilder builder) => + AddOwinInstrumentation(builder, configure: null); + + /// + /// Enables the incoming requests automatic data collection for OWIN. + /// + /// being configured. + /// OWIN Request configuration options. /// The instance of to chain the calls. public static TracerProviderBuilder AddOwinInstrumentation( this TracerProviderBuilder builder, - Action configureOwinInstrumentationOptions = null) + Action configure) { Guard.ThrowIfNull(builder); var owinOptions = new OwinInstrumentationOptions(); - configureOwinInstrumentationOptions?.Invoke(owinOptions); + configure?.Invoke(owinOptions); OwinInstrumentationActivitySource.Options = owinOptions; From a2960dc2e07a4539fc0d98b484d7b32404e11926 Mon Sep 17 00:00:00 2001 From: Yun-Ting Lin Date: Tue, 7 Feb 2023 16:45:35 -0800 Subject: [PATCH 3/7] [Instrumentation.Process] Cleanup public APIs. (#973) --- .../netstandard2.0/PublicAPI.Unshipped.txt | 3 --- .../CHANGELOG.md | 6 ++++++ .../MeterProviderBuilderExtensions.cs | 17 ++--------------- .../ProcessInstrumentationOptions.cs | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.Process/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.Process/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 1b9d855189..63ab8f1974 100644 --- a/src/OpenTelemetry.Instrumentation.Process/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.Process/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,5 +1,2 @@ -OpenTelemetry.Instrumentation.Process.ProcessInstrumentationOptions -OpenTelemetry.Instrumentation.Process.ProcessInstrumentationOptions.ProcessInstrumentationOptions() -> void OpenTelemetry.Metrics.MeterProviderBuilderExtensions static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddProcessInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddProcessInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, System.Action? configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md index 6e9571be36..2e88c2ec1d 100644 --- a/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +* Removed `ProcessInstrumentationOptions` and + `AddProcessInstrumentation(this MeterProviderBuilder builder,` + `Action? configure)` + from the public APIs. + ([#973](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/973)) + ## 1.0.0-alpha.5 Released 2023-Feb-02 diff --git a/src/OpenTelemetry.Instrumentation.Process/MeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.Process/MeterProviderBuilderExtensions.cs index b3ec572477..11ce49531a 100644 --- a/src/OpenTelemetry.Instrumentation.Process/MeterProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.Process/MeterProviderBuilderExtensions.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using System; using OpenTelemetry.Instrumentation.Process; using OpenTelemetry.Internal; @@ -26,29 +25,17 @@ namespace OpenTelemetry.Metrics; public static class MeterProviderBuilderExtensions { /// - /// Enables runtime instrumentation. + /// Enables process instrumentation. /// /// being configured. /// The instance of to chain the calls. - public static MeterProviderBuilder AddProcessInstrumentation(this MeterProviderBuilder builder) => AddProcessInstrumentation(builder, configure: null); - - /// - /// Enables runtime instrumentation. - /// - /// being configured. - /// Runtime metrics options. - /// The instance of to chain the calls. public static MeterProviderBuilder AddProcessInstrumentation( - this MeterProviderBuilder builder, - Action? configure) + this MeterProviderBuilder builder) { Guard.ThrowIfNull(builder); var options = new ProcessInstrumentationOptions(); - configure?.Invoke(options); - builder.AddMeter(ProcessMetrics.MeterName); - return builder.AddInstrumentation(() => new ProcessMetrics(options)); } } diff --git a/src/OpenTelemetry.Instrumentation.Process/ProcessInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.Process/ProcessInstrumentationOptions.cs index bc5b7ddef8..f5d5fd1a7a 100644 --- a/src/OpenTelemetry.Instrumentation.Process/ProcessInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.Process/ProcessInstrumentationOptions.cs @@ -19,6 +19,6 @@ namespace OpenTelemetry.Instrumentation.Process; /// /// Options to define the process metrics. /// -public class ProcessInstrumentationOptions +internal class ProcessInstrumentationOptions { } From 429fdbb8703faad752e960442d24df17fab94016 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Wed, 8 Feb 2023 00:59:33 +0000 Subject: [PATCH 4/7] [Instrumentation.ElasticsearchClient] Fix analysis warnings (#961) --- ...asticsearchClientInstrumentationOptions.cs | 2 +- ...searchRequestPipelineDiagnosticListener.cs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs index 43d42bc6d0..6030bc4a80 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/ElasticsearchClientInstrumentationOptions.cs @@ -32,7 +32,7 @@ public class ElasticsearchClientInstrumentationOptions /// /// Gets or sets a value indicating whether the JSON request body should be parsed out of the request debug information and formatted as indented JSON. /// - public bool ParseAndFormatRequest { get; set; } = false; + public bool ParseAndFormatRequest { get; set; } /// /// Gets or sets a value indicating whether or not the OpenTelemetry.Instrumentation.ElasticsearchClient diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs index c2c8414ff2..75a2803600 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/Implementation/ElasticsearchRequestPipelineDiagnosticListener.cs @@ -87,8 +87,8 @@ public override void OnStartActivity(Activity activity, object payload) SuppressInstrumentationScope.Enter(); } - var elasticIndex = this.GetElasticIndex(uri); - activity.DisplayName = this.GetDisplayName(activity, method, elasticIndex); + var elasticIndex = GetElasticIndex(uri); + activity.DisplayName = GetDisplayName(activity, method, elasticIndex); activity.SetTag(SemanticConventions.AttributeDbSystem, DatabaseSystemName); if (elasticIndex != null) @@ -144,7 +144,7 @@ public override void OnStopActivity(Activity activity, object payload) var debugInformation = this.debugInformationFetcher.Fetch(payload); if (debugInformation != null && this.options.SetDbStatementForRequest) { - var dbStatement = this.ParseAndFormatRequest(activity, debugInformation); + var dbStatement = this.ParseAndFormatRequest(debugInformation); if (this.options.MaxDbStatementLength > 0 && dbStatement.Length > this.options.MaxDbStatementLength) { dbStatement = dbStatement.Substring(0, this.options.MaxDbStatementLength); @@ -201,7 +201,7 @@ public override void OnStopActivity(Activity activity, object payload) } } - private string GetDisplayName(Activity activity, object method, string elasticType = null) + private static string GetDisplayName(Activity activity, object method, string elasticType = null) { switch (activity.OperationName) { @@ -223,7 +223,7 @@ private string GetDisplayName(Activity activity, object method, string elasticTy } } - private string GetElasticIndex(Uri uri) + private static string GetElasticIndex(Uri uri) { // first segment is always / if (uri.Segments.Length < 2) @@ -232,7 +232,7 @@ private string GetElasticIndex(Uri uri) } // operations starting with _ are not indices (_cat, _search, etc) - if (uri.Segments[1].StartsWith("_")) + if (uri.Segments[1].StartsWith("_", StringComparison.Ordinal)) { return null; } @@ -245,7 +245,7 @@ private string GetElasticIndex(Uri uri) return null; } - if (elasticType.EndsWith("/")) + if (elasticType.EndsWith("/", StringComparison.Ordinal)) { elasticType = elasticType.Substring(0, elasticType.Length - 1); } @@ -253,7 +253,7 @@ private string GetElasticIndex(Uri uri) return elasticType; } - private string ParseAndFormatRequest(Activity activity, string debugInformation) + private string ParseAndFormatRequest(string debugInformation) { if (!this.options.ParseAndFormatRequest) { @@ -275,9 +275,10 @@ private string ParseAndFormatRequest(Activity activity, string debugInformation) return debugInformation; } + using (doc) using (var stream = new MemoryStream()) { - var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true }); + using var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true }); doc.WriteTo(writer); writer.Flush(); body = Encoding.UTF8.GetString(stream.ToArray()); From 9877a3220a3977dce2fb29d7dc2742dee553a0a8 Mon Sep 17 00:00:00 2001 From: ernesto1596 Date: Wed, 8 Feb 2023 07:20:23 -0800 Subject: [PATCH 5/7] [OpenTelemetry.Exporter.Geneva] Release 1.4.0-rc.3 (#978) --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index aebf999ce0..e8d7203281 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.4.0-rc.3 + +Released 2023-Feb-08 + * Update OpenTelemetry to 1.4.0-rc.3 ([#944](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/944)) From f46ca2b63fb659291724d836d13cab83b58afaa3 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Wed, 8 Feb 2023 16:21:15 +0000 Subject: [PATCH 6/7] [Instrumentation.Wcf] Fix analysis warnings (#967) --- .../TelemetryClientMessageInspector.cs | 14 ++++++++++---- .../TelemetryContractBehaviorAttribute.cs | 3 +++ .../TelemetryDispatchMessageInspector.cs | 3 +++ .../TelemetryEndpointBehavior.cs | 3 +++ .../TelemetryServiceBehavior.cs | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryClientMessageInspector.cs b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryClientMessageInspector.cs index 2830e78c91..f34646629f 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryClientMessageInspector.cs +++ b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryClientMessageInspector.cs @@ -44,6 +44,9 @@ internal TelemetryClientMessageInspector(IDictionary act /// public object BeforeSendRequest(ref Message request, IClientChannel channel) { + Guard.ThrowIfNull(request); + Guard.ThrowIfNull(channel); + try { if (WcfInstrumentationActivitySource.Options == null || WcfInstrumentationActivitySource.Options.OutgoingRequestFilter?.Invoke(request) == false) @@ -51,7 +54,7 @@ public object BeforeSendRequest(ref Message request, IClientChannel channel) WcfInstrumentationEventSource.Log.RequestIsFilteredOut(); return new State { - SuppressionScope = this.SuppressDownstreamInstrumentation(), + SuppressionScope = SuppressDownstreamInstrumentation(), }; } } @@ -60,14 +63,14 @@ public object BeforeSendRequest(ref Message request, IClientChannel channel) WcfInstrumentationEventSource.Log.RequestFilterException(ex); return new State { - SuppressionScope = this.SuppressDownstreamInstrumentation(), + SuppressionScope = SuppressDownstreamInstrumentation(), }; } Activity activity = WcfInstrumentationActivitySource.ActivitySource.StartActivity( WcfInstrumentationActivitySource.OutgoingRequestActivityName, ActivityKind.Client); - IDisposable suppressionScope = this.SuppressDownstreamInstrumentation(); + IDisposable suppressionScope = SuppressDownstreamInstrumentation(); if (activity != null) { @@ -143,6 +146,9 @@ public object BeforeSendRequest(ref Message request, IClientChannel channel) /// public void AfterReceiveReply(ref Message reply, object correlationState) { + Guard.ThrowIfNull(reply); + Guard.ThrowIfNull(correlationState); + State state = (State)correlationState; state.SuppressionScope?.Dispose(); @@ -171,7 +177,7 @@ public void AfterReceiveReply(ref Message reply, object correlationState) } } - private IDisposable SuppressDownstreamInstrumentation() + private static IDisposable SuppressDownstreamInstrumentation() { return WcfInstrumentationActivitySource.Options?.SuppressDownstreamInstrumentation ?? false ? SuppressInstrumentationScope.Begin() diff --git a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs index 522dfc9ec3..7669d457b6 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs +++ b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryContractBehaviorAttribute.cs @@ -18,6 +18,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; +using OpenTelemetry.Internal; namespace OpenTelemetry.Instrumentation.Wcf; #if NETFRAMEWORK @@ -45,6 +46,7 @@ public void AddBindingParameters(ContractDescription contractDescription, Servic /// public void ApplyClientBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, ClientRuntime clientRuntime) { + Guard.ThrowIfNull(clientRuntime); TelemetryEndpointBehavior.ApplyClientBehaviorToClientRuntime(clientRuntime); } @@ -52,6 +54,7 @@ public void ApplyClientBehavior(ContractDescription contractDescription, Service public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime) { #if NETFRAMEWORK + Guard.ThrowIfNull(dispatchRuntime); TelemetryEndpointBehavior.ApplyDispatchBehaviorToEndpoint(dispatchRuntime.EndpointDispatcher); #endif } diff --git a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs index 26e109eaa9..476676a534 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs +++ b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryDispatchMessageInspector.cs @@ -45,6 +45,9 @@ internal TelemetryDispatchMessageInspector(IDictionary a /// public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { + Guard.ThrowIfNull(request); + Guard.ThrowIfNull(channel); + try { if (WcfInstrumentationActivitySource.Options == null || WcfInstrumentationActivitySource.Options.IncomingRequestFilter?.Invoke(request) == false) diff --git a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs index 73417ff793..7b13fb0c93 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs +++ b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs @@ -19,6 +19,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; +using OpenTelemetry.Internal; namespace OpenTelemetry.Instrumentation.Wcf; #if NETFRAMEWORK @@ -43,6 +44,7 @@ public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterColle /// public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) { + Guard.ThrowIfNull(clientRuntime); ApplyClientBehaviorToClientRuntime(clientRuntime); } @@ -50,6 +52,7 @@ public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRu public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { #if NETFRAMEWORK + Guard.ThrowIfNull(endpointDispatcher); ApplyDispatchBehaviorToEndpoint(endpointDispatcher); #endif } diff --git a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryServiceBehavior.cs b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryServiceBehavior.cs index c9cb943025..4a63fc87c3 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/TelemetryServiceBehavior.cs +++ b/src/OpenTelemetry.Instrumentation.Wcf/TelemetryServiceBehavior.cs @@ -18,6 +18,7 @@ using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; +using OpenTelemetry.Internal; namespace OpenTelemetry.Instrumentation.Wcf; @@ -35,6 +36,8 @@ public void AddBindingParameters(ServiceDescription serviceDescription, ServiceH /// public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { + Guard.ThrowIfNull(serviceHostBase); + foreach (var channelDispatcherBase in serviceHostBase.ChannelDispatchers) { var channelDispatcher = (ChannelDispatcher)channelDispatcherBase; From 047cd058f01abbf61de8274164a901526c545869 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Wed, 8 Feb 2023 11:15:47 -0800 Subject: [PATCH 7/7] update pr template to include api review check (#980) Co-authored-by: Cijo Thomas --- .github/PULL_REQUEST_TEMPLATE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b5fc738afc..e5ef779df5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,3 +8,4 @@ For significant contributions please make sure you have completed the following * [ ] Appropriate `CHANGELOG.md` updated for non-trivial changes * [ ] Design discussion issue # +* [ ] Changes in public API reviewed