* Add OpenTracingShim to SDK initialization * Add OpenTracingShim as option to ConsoleApp * Change wrapper method to async * Match casing of other poc variables * Change log message to "tracer initialized" * Make OT span default on ConsoleApp * Fixes .vcxproj file for latest msbuild version. (#1495) Co-authored-by: Tony Redondo <tony.redondo@datadoghq.com> |
||
|---|---|---|
| .devcontainer.example | ||
| .github | ||
| .vscode.example | ||
| dev | ||
| docs | ||
| samples | ||
| src | ||
| .clang-format | ||
| .dockerignore | ||
| .editorconfig | ||
| .env | ||
| .gitattributes | ||
| .gitignore | ||
| Datadog.Trace.proj | ||
| Datadog.Trace.sln | ||
| Datadog.Trace.sln.DotSettings | ||
| Directory.Build.props | ||
| GlobalSuppressions.cs | ||
| LICENSE | ||
| LICENSE-3rdparty.csv | ||
| NOTICE | ||
| OpenTelemetry.AutoInstrumentation.snk | ||
| README.md | ||
| build.sh | ||
| defaults.env | ||
| devenv.bat | ||
| git-clean.cmd | ||
| integrations.json | ||
| nuget.config | ||
| opentelemetry-logo-64x64.png | ||
| opentelemetry-logo-256x256.png | ||
| poc.sh | ||
| pre-build-events-cpp.bat | ||
| stylecop.json | ||
README.md
PoC - Reuse OpenTelemetry .NET API and SDK
Vision
Use OpenTelemetry .NET API and SDK instead Datadog tracer model.
Use Case
Instrumented HTTP client and HTTP server applciations exporting traces to Jaeger. We may also try adding manual instrumentation.
Constraints
We may add additional requirements for the instrumented applications such us:
- Add references to OpenTelemetry NuGet packages.
- Concrete versions of OpenTelemetry NuGet packages must be used.
- Must use newer versions of .NET.
Plan
Preparation
- Prepare the use case secenario and make sure it is working.
- Get rid of everything, but HTTP Client and HTTP Server instrumentation. Reason: quicker iterations (especially thanks to quicker build time). Make sure the use case is still working.
It would be good to have some automation here to test without doing to much stuff manually.
Remove Datadog Tracer
- Remove
Datadog.Trace.Tracerand a lot of related code. We can just keep the AutoInstrumentation integration boilerplate for HTTP Client and ASP.NET. - Change the
Datadog.Trace.ClrProfiler.Instrumentation.Initialize()method so that it will be the place where the global OTel trace provider will be configured.
It would be good to have a checkpoint here where the instrumented application is NOOP-instrumented.
Experiments
- Hardcode the global OTel tracer configuration.
- Configure the OTel tracer based on env vars. SDK should handle it. question
- Add manual instrumentation to the applications.
- Try auto-instrumentation using ActivitySource
e.g. in
Datadog.Trace.ClrProfiler.AutoInstrumentation.Http.HttpClient.HttpMessageHandlerCommon. - Test with different versions of OTel SDK in runtime.
- Try using
AppDomain.CurrentDomain.AssemblyResolve +=to add a fallback if the instrumented app does not reference the OTel SDK.
Helpful docs and samples
- https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry/README.md#activity-source
- https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/Console/TestHttpClient.cs
Findings
Required reference to System.Diagnostics.DiagnosticSource
The instrumented application has to include:
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
Testing
Additional setup for Windows
Add msbuild to your PATH. You can do it by adding to ~/.bashrc something more or less like bellow:
PATH="$PATH:/c/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin"
Additional setup for Linux and MacOS
sudo mkdir -p /var/log/opentelemetry/dotnet
sudo chmod a+rwx /var/log/opentelemetry/dotnet
Usage
For .NET Core 3.1 run:
./poc.sh
For .NET 5.0 run:
aspNetAppTargetFramework=net5.0 consoleAppTargetFramework=net5.0 ./poc.sh
For .NET Framework run:
consoleAppTargetFramework=net46 ./poc.sh