-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WCF] Fix WCF instrumentation initialization (#3650)
- Loading branch information
Showing
27 changed files
with
583 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/OpenTelemetry.AutoInstrumentation/Instrumentations/Wcf/WcfInstrumentationInitializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#if NETFRAMEWORK | ||
using System.Reflection; | ||
using OpenTelemetry.AutoInstrumentation.Instrumentations.AspNet; | ||
#endif | ||
using OpenTelemetry.Instrumentation.Wcf; | ||
|
||
namespace OpenTelemetry.AutoInstrumentation.Instrumentations.Wcf; | ||
|
||
internal static class WcfInstrumentationInitializer | ||
{ | ||
private static int _instrumentationOptionsInitialized; | ||
#if NETFRAMEWORK | ||
private static int _aspNetParentSpanCorrectorInitialized; | ||
#endif | ||
|
||
public static void TryInitializeOptions() | ||
{ | ||
if (Interlocked.Exchange(ref _instrumentationOptionsInitialized, value: 1) != default) | ||
{ | ||
return; | ||
} | ||
|
||
var options = new WcfInstrumentationOptions(); | ||
|
||
Instrumentation.PluginManager?.ConfigureTracesOptions(options); | ||
|
||
var instrumentationType = | ||
Type.GetType( | ||
"OpenTelemetry.Instrumentation.Wcf.WcfInstrumentationActivitySource, OpenTelemetry.Instrumentation.Wcf"); | ||
|
||
instrumentationType?.GetProperty("Options")?.SetValue(null, options); | ||
} | ||
|
||
#if NETFRAMEWORK | ||
public static void TryInitializeParentSpanCorrector() | ||
{ | ||
if (Interlocked.Exchange(ref _aspNetParentSpanCorrectorInitialized, value: 1) != default) | ||
{ | ||
return; | ||
} | ||
|
||
if (HttpModuleIntegration.IsInitialized) | ||
{ | ||
var aspNetParentSpanCorrectorType = Type.GetType("OpenTelemetry.Instrumentation.Wcf.Implementation.AspNetParentSpanCorrector, OpenTelemetry.Instrumentation.Wcf"); | ||
var methodInfo = aspNetParentSpanCorrectorType?.GetMethod("Register", BindingFlags.Static | BindingFlags.Public); | ||
methodInfo?.Invoke(null, null); | ||
} | ||
} | ||
#endif | ||
} |
45 changes: 0 additions & 45 deletions
45
src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/WcfInitializer.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.