Commit Graph

571 Commits

Author SHA1 Message Date
Lucas Pimentel-Ordyna fb0ac61098
Fix "runtime description" used for internal analytics (#519)
* remove use of RuntimeInformation in NativeMethods and ContainerInfo

* add new FrameworkDescription class

* use new FrameworkDescription class from Api class to set http headers

* clean up xml-doc comments

* add "OS" to Resharper's spell-check abbreviations

* change Resharper's editor style: don't _always_ chop a ternary expression into multiple lines

* revert change to nuget package reference

* refactor code into GetVersionFromAssemblyAttributes()

* make nuget reference private and add comment

* remove unnecessary call to GetTypeInfo()

* coalesce more null values to "unknown"

* add comment

* move the "try/catch" inside the "if" instead of the other way around

* remove try/catch, update comment

* update log messages

* simplify ToString()
2019-10-04 16:32:23 -04:00
Lucas Pimentel-Ordyna 07e420f92d
update msi icon (#523) 2019-10-04 15:43:33 -04:00
Zach Montoya f25de38198
Install the 32-bit Profiler with the 64-bit Installer (#521)
High-Level Summary of Changes:
- 32-bit Installer: Minimal changes. This is the installer we recommend for 32-bit machines.
- 64-bit Installer: Install both the 32-bit Profiler and 64-bit Profiler in the one Installer. This is the installer we recommend for 64-bit machines, regardless of the target application's bitness.

Detailed changes:
- For 64-bit installer builds, make sure to build the 32-bit Profiler before building the MSI, place the 32-bit Profiler on-disk in "Program Files (x86)", and register the 32-bit Profiler as a COM component.
- Change the `Description` of the COM component from `Datadog .NET Tracer <bitness>-bit` to `Datadog .NET Tracer`.
- Edit `Datadog.Trace.proj` so all of the MSI dependencies are built when invoking the `Msi` target. This simplifies the packages Azure DevOps pipeline and developer building steps.
2019-10-03 15:08:59 -07:00
Zach Montoya cee9f59c97
Changes to fix an issue with recent MSI changes. (#522)
In recent changes, we realized we needed to re-install the net45 files in the GAC to allow IIS automatic instrumentation to succeed so we made the change. However, as a result, the net45 files were not placed on-disk in a subdirectory of `DD_DOTNET_TRACER_HOME`. This change fixes that by installing the files twice: once into the GAC and once on-disk.
2019-10-03 12:31:47 -07:00
Zach Montoya dfd0ec45b2
Run IntegrationTests on .NET Core 3.0 (#520)
- Edit tests project, sample projects, and reproduction projects to additionally run against `netcoreapp3.0`
- Edit unit tests using the `TargetFrameworkVersionsFact` to run against `netcoreapp3.0` if they already run against `netcoreapp2.1`
- Use the `UseDotNet@2` task to install the .NET Core SDK's in all of our test pipelines. Also, install the .NET Core 3.0 SDK in all of our pipelines.
- Split the Linux integration-tests into two separate runs: `netcoreapp2.1` and `netcoreapp3.0`
- Edit the `GeneratePackageVersions` tool to allow specifying only one `TargetFramework` for a sample app to run against (needed for `Samples.AspNetCoreMvc2`), and filter the sample apps to publish by `TargetFramework`
2019-10-01 11:55:12 -07:00
Lucas Pimentel-Ordyna 45a33015af
allow declaring multiple assemblies in a single [InterceptMethod] attribute (#507)
* add support for multiple assembly names in a single [InterceptMethod]

* use new "TargetAssemblies" in AdoNet integration
2019-09-30 13:05:59 -04:00
Alexey Zimarev d8ae1332a9 Make possible to create an OpenTrace tracer from existing Tracer (#513)
* Make possible to create an OpenTrace tracer from existing Tracer

* Rename method
2019-09-25 14:21:54 -04:00
Colin Higgins 8e7cb504c0
Consistent Logs for Method Retrieval (#498)
* Log all potentially relevant data in consistent format for method retrieval
2019-09-25 11:31:55 -04:00
Zach Montoya 2134d7a0f0
Load CLR profiler assembly per AppDomain (#510)
Product changes:
- Introduce new map data structures in the profiler to keep track of which app domain's the profiler has been loaded into and which ones have run the startup IL code, and use them to determine if it is safe to instrument a caller method based on its AppDomain.
- Edit MSI to install net45 assets into GAC. This is necessary because we still run into "security grant" issue when the assembly to instrument is domain-neutral and our profiler assembly is not.

Testing changes:
- Refactor AppDomain.Instance program to easily run subprograms to test how integrations are instrumented while run in different AppDomain's. The original subprogram is `SqlServerNestedProgram`. Add a new `ElasticsearchNestedProgram` subprogram with wrapper sample `Samples.Elasticsearch.MultipleAppDomains`, but it is not running in CI because we haven't figured out how to run Elasticsearch in Windows CI on Azure DevOps

Notes:
- As noted with the MSI, we still must have the profiler in the GAC in order to load as a domain-neutral assembly and avoid the "security grant" issue.
2019-09-24 10:50:03 -07:00
Lucas Pimentel-Ordyna 8d5197837b
fix WCF resource name for non-http transports (#509)
* modify Samples.Wcf to allow choosing between WsHttpBinding or NetTcpBinding

* add new Samples.WcfClient

* add string constant SpanTypes.Custom

* rewrite WcfIntegration

* remove unused SpanIntegrationDelegates

* remove unused config file
2019-09-18 12:57:50 -04:00
Zach Montoya 7b96de3736
Load Datadog.Trace.ClrProfiler.Managed via the AppDomain.AssemblyResolve event (#505)
Product changes:
- In `Datadog.Trace.ClrProfiler.Managed.Loader` add the `AppDomain.AssemblyResolve` event handler to load managed profiler dependencies from disk where the profiler is installed. This would remove the need to install files into the GAC or add the `Datadog.Trace.ClrProfiler.Managed` NuGet package to receive auto-instrumentation.
- Stop adding assembly references to the managed profiler code in `ModuleLoadFinished` and instead do that operation in `JITCompilationStarted`. Because of this delayed reference, the runtime will not be able to resolve the assembly reference automatically (perhaps avoiding the SecurityGrant exceptions we have seen in the past!) and will rely on the newly implemented `AppDomain.AssemblyResolve` event to find the managed profiler code.
- Build `Datadog.Trace.ClrProfiler.Managed.Loader` for `netcoreapp2.0` and `net45` because reading environment variables (to obtain profiler file path) is only supported on `netstandard1.3` and higher.

Build changes:
- Combine common settings in `Directory.Build.props` for reproductions, reproduction-dependencies, and samples into `./Test.Common.props`
- For Windows-ready xUnit integration tests, add the `RunOnWindows=True` trait
- Produce managed profiler assets by running `dotnet publish Datadog.Trace.ClrProfiler.Managed` for each target framework
- Stop building `Datadog.Trace.ClrProfiler.Managed.Loader.csproj` inside `Datadog.Trace.proj`'s `BuildCpp` target and instead build it separately whenever we build `Datadog.Trace.ClrProfiler.Native`
2019-09-18 08:10:16 -07:00
Lucas Pimentel-Ordyna 47d87a634b
clean up old IDictionary extension methods (#500)
* use tertiary operator

* add null argument checks

* replace uses of IDictionary.Get<T>() with IDictionary.GetValueOrDefault<T>()

* remove unused extension method

* rename IDictionary.TryGetValueOrDefaultAs() to TryGetValue() and refactor it

* add IDictionary.GetValueOrDefault<TValue>() extension method

* allow more time to flaky test
2019-09-11 12:50:24 -04:00
Zach Montoya 0c0f51cf83
Fix Linux packaging build (#504)
Fix Linux packaging build by building managed components before building the Profiler. The Profiler now needs to embed Datadog.Trace.ClrProfiler.Managed.Loader which means it must be built first.
2019-09-04 07:59:58 -07:00
Zach Montoya 55ea548f3b
Version bump to 1.7.0 (#503) 2019-09-03 16:41:44 -07:00
Zach Montoya c5a8106681
Create reproduction app for EntityFramework6 (#490)
* Add sample program EntityFramework6x.MdTokenLookupFailure

* Add configuration keys for DD_TRACE_DEBUG_LOOKUP_MDTOKEN and DD_TRACE_DEBUG_LOOKUP_FALLBACK to force MethodBuilder behaviors. This is not yet used but can be enabled later.

* Modify the build to build .NET Framework apps and restore all packages.config projects before running the Windows integration tests
2019-08-30 14:53:34 -07:00
Lucas Pimentel-Ordyna 803316aff7
improve container tagging test to include Windows (#499) 2019-08-30 16:13:29 -04:00
Lucas Pimentel-Ordyna 501699feec
update available nuget package versions (#487) 2019-08-30 14:28:13 -04:00
Lucas Pimentel-Ordyna 069bd9c54f
Container tagging (#481)
* parse /proc/self/cgroup to extract container id

* unit tests for parsing /proc/self/cgroup

* add new Agent http header for container id

* add the container id http header if available

* add comments

* rename methods and variables for clarity, add xml-doc comments

* make class members public (the class itself remains internal)

* cache the container id

* remove pod regex

* merge into single regex

* add MockTracerAgent.RequestReceived event

* add internal Tracer.FlushAsync() for testing purposes

* add test that checks for container id

* run tests in Datadog.Trace.IntegrationTests and Datadog.Trace.OpenTracing.IntegrationTests

* rename test method

* remove unused "using" directive

* skip running some tests in CI, will fix in upcoming PR

* move logic to split lines into test assembly

* handle exceptions, add logging

* rename test method

* skip running some tests in CI, will fix in upcoming PR
2019-08-30 14:20:41 -04:00
Zach Montoya 53094f5327
Convert WebRequestIntegration to MethodBuilder / ModuleVersionId (#496) 2019-08-30 11:04:59 -07:00
Lucas Pimentel-Ordyna b735a4bd38
migrate more integrations to newer MethodBuilder (#494)
* use MethodBuilder in AspNetMvcIntegration

* use MethodBuilder in AspNetWebApi2Integration

* use MethodBuilder in WcfIntegration

* add object.GetInstrumentedInterface() extension method

* replace uses of WithConcreteTypeName() to WithConcreteType()

* replace more uses of WithConcreteTypeName() to WithConcreteType()

* remove unused MethodBuilder.WithConcreteTypeName()

* clean up code

* rename fields for clarity

* add more type name constants

* stop using "dynamic" keyword

* use object.GetInstrumentedType()

* remove unused static Type fields

* use object.GetInstrumentedType()

* add more type name constants, remove unused static Type fields

* stop using "dynamic" keyword

* use GetInstrumentedInterface() instead of GetInstrumentedType()
2019-08-30 10:03:09 -04:00
Lucas Pimentel-Ordyna 2b458b0315
update CI badges to point at master branch (#497) 2019-08-30 10:02:17 -04:00
Colin Higgins 058e02a01d
Convert ConnectionMultiplexer to ModuleLookup (#491)
* Convert ConnectionMultiplexer to ModuleLookup
2019-08-30 09:50:22 -04:00
Zach Montoya 2be4161ed4
[Linux] Eager assembly load of managed profiler code (#469)
The main mechanism for loading the managed profiler code was introduced in #462 (commit 4ce932f).

This PR turns on the feature for Linux. The main components are embedding the resources into the shared library, retrieving the embedded resources in the native profiler, and adding the correct PInvoke from the injected assembly load.
2019-08-29 09:04:42 -07:00
Lucas Pimentel-Ordyna 4c6d340758
fix MSVC warning when implicitly converting size_t to ULONG (#495) 2019-08-28 18:07:25 -04:00
Lucas Pimentel-Ordyna 70b4b37535 Fix distribution of randomly generated uint63s (#493)
* fix bitmask

* Introduce statistics tests for random id generator
2019-08-28 12:00:30 -04:00
Zach Montoya 12261f4ccf
Fix InvalidOperationException bug in TraceContext->AgentWriter (#454)
Fix InvalidOperationException bug when simultaneously flushing traces to the agent and appending additional spans to that list. This happens because the TraceContext can write to the same List object that was sent to the AgentWriter (which is later enumerated and invalidated if it is simultaneously being edited).
2019-08-27 12:55:49 -07:00
Colin Higgins c5894f50f2
Convert AdoNet to MethodBuilder (#489)
* Convert AdoNet to MethodBuilder, more sample async calls

* MySql sample
2019-08-27 13:51:42 -04:00
Colin Higgins 98efd8f0e3
Update NuGet package authors (#492)
* Update nuget package authors
2019-08-27 13:31:21 -04:00
Colin Higgins 3713298aba
Add Namespace and Name filters (#486)
* Add Namespace and Name filters

* Remove unused namespaces
2019-08-23 14:20:47 -04:00
Lucas Pimentel-Ordyna 657208bff6
pass module version id to instrumentation wrappers (#488)
* improve logging

* merge LINQ methods

* fix signature size checks

* add new "long moduleVersionPtr" parameter to all integration wrapper methods

* pass the module_version_id pointer to every integration wrapper method

* update integrations json file

* add a check for required wrapper parameters

* add MethodBuiler overload that takes long moduleVersionPtr

* replace uses of GetCallingAssembly() with moduleVersionPtr

* remove unused MethodBuilder.Start(Assembly, ...) delegate

* rename variable for clarity

* revert whitespace changes

* re-add comment

* rename pointer variable, clean up code

* no need to materialize a new array

* fix unit tests and their comments

* fix unit test comments, redux
2019-08-22 19:45:52 -04:00
Colin Higgins 205d469c5f
Module lookup overload (#485)
* ModuleLookup, overload on MethodBuilder
2019-08-22 15:23:31 -04:00
Colin Higgins 55a2f25057
Method builder hardening (#484)
* Failing tests for method builder

* Fix cache key, be explicit in all unclear cases
2019-08-21 13:34:51 -04:00
Colin Higgins f2a8fa521e
Add ModuleVersionId to module_metadata for future use (#483)
* Add ModuleVersionId to module_metadata for future use

* update tests project

* use nullptr and 0

* Log and bail out of MVID is not found
2019-08-21 12:29:18 -04:00
Zach Montoya 6349d6a48a Use microsoft/dotnet:2.1-sdk in CI (#477)
* Extend SmokeTestBase to allow for an override method to customize the ProcessResult assert logic.

* Revert "Extend SmokeTestBase to allow for an override method to customize the ProcessResult assert logic."

This reverts commit e16d2dac829bc446be77c1077ba052390c3f1121.

* Change dotnet.dockerfile to use the Ubuntu image instead of Alpine

* Remove ubuntu suffix from docker image

* Remove apk commands from dotnet.dockerfile

* update base docker image
2019-08-20 17:14:51 -04:00
Colin Higgins da4f5e4e9a
Version bump 1.6.2 (#480) 2019-08-20 10:40:07 -04:00
Colin Higgins 2282259cb2
Revert adonet integration and add more logging (#479) 2019-08-19 17:50:37 -04:00
Zach Montoya efe193ec4c
Fix issue with auto-injection of Correlation Identifiers (Serilog) (#472)
Scenario: Some time after the first span is activated, we have set the
logging context properties dd.trace_id=0 and dd.span_id=0. Application
code then sets their own logging context properties. Then, a new span is
created and previously-set properties no longer exist in the logging context.

Problem: Our OnSpanActivated event immediately disposes the previously-set
correlation identifier properties before re-adding the new values.
Serilog has a strict correctness guarantee that requires properties be
modified in stack order. Since we remove properties further down the stack,
we end up losing properties.

Fix: For Serilog, do not add efault values of TraceId=0 and SpanId=0. Also,
add and remove the two properties on SpanOpened and on SpanClosed.
This ensures that properties only get added to/removed from the stack once.
2019-08-16 11:43:30 -07:00
Colin Higgins c018777c14
Convert ServiceStack.Redis to use mdToken (#466)
* Convert ServiceStack.Redis to use mdToken
2019-08-16 12:56:50 -04:00
Lucas Pimentel-Ordyna 75539e5243 try fixing the capitalization so jobs don't show up twice in github (#476) 2019-08-16 10:59:52 -04:00
Lucas Pimentel-Ordyna 34bcc0cda4
remove RIDs from projects (#474)
* remove <RuntimeIdentifiers> and <RuntimeIdentifier> from all projects, not needed with dotnet SDK 2.1+

* update dotnet sdk version

* installer dotnet sdk earlier

* remove RIDs from sample app paths
2019-08-16 10:56:08 -04:00
Colin Higgins 0004ce1275
Version bump automation (#471)
* Version bump automation tool
2019-08-14 11:19:35 -04:00
Lucas Pimentel-Ordyna 1912beb786 version bump 1.6.1 redux 2019-08-14 08:06:13 -04:00
Colin Higgins 0d92385d5e
Use buildConfiguration variable for build.sh (#468)
* Use build configuration variable for build.sh
2019-08-13 15:33:25 -04:00
Lucas Pimentel-Ordyna 2d1ad0e313
fix default json config file path on ASP.NET (#463)
* use app's folder as default path for config json file on ASP.NET

* show current directory and result of MapPath("~") in sample MVC5 app
2019-08-13 15:28:48 -04:00
Colin Higgins a885ba13bc
Version bump (v1.6.1) (#467)
* Version bump (v1.6.1)
2019-08-13 10:45:36 -04:00
Zach Montoya 4ce932f6d1
[Windows] Eager assembly load of managed profiler code (#462)
Implementation Changes (Enabled only on Windows for now):
* Creates a new library called Datadog.Trace.ClrProfiler.Managed.Loader that is embedded in the native profiler image. When the type is loaded, it has a static constructor to call Assembly.Load on our managed profiler code in a try-catch block.

* On first JITCompilationStarted, dynamically emit IL to load the Datadog.Trace.ClrProfiler.Managed.Loader assembly and attempt to load the managed profiler code.

* Change the native profiler so no edits are made in the JITCompilationStarted event unless the managed profiler code is already loaded.

* Keep track of the app domain of mscorlib, the managed profiler assembly, and the method caller's assembly and do not edit the IL of a method if referencing the managed profiler assembly would invalidate the caller's domain-neutral assembly reference closure.


Tests and Results:
* Enable a subset of integration tests on Windows. Smoke tests and the E2E HttpClientTests are now run on Windows.

* Fixes System.IO.FileNotFoundException when trying to load (Assembly.Load) the managed profiler but it cannot be found. Adds a smoke test called AssemblyLoad.FileNotFoundException to verify the behavior (Windows-only for now).

* Fixes System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. Adds a smoke test called SecurityGrant.FileNotFoundException to verify the behavior (only runs on .NET Framework).
2019-08-12 15:30:05 -07:00
Colin Higgins ae8d3eb9d7
Add trace count header for statistics agent side (#465)
* Add trace count header for statistics agent side

* Add global assertion to MockTracerAgent
2019-08-08 16:04:15 -04:00
Colin Higgins dbd1945354
Convert AdoNet to use mdToken (#438)
* Convert AdoNet to use mdToken

* Use DbCommand as concrete type
2019-08-08 13:09:54 -04:00
Zach Montoya e8dd7232b1
Use MethodBuilder/mdToken in Elasticsearch integrations (#461)
Modify Elasticsearch5 and Elasticsearch6 integrations to use MethodBuilder and mdToken constructs.
2019-07-31 09:20:45 -07:00
Lucas Pimentel-Ordyna 16e6a50cd8
report "interpreter" version (#459)
* add constant for http header "Datadog-Meta-Lang-Version"

* split framework description into interpreter and version

* place managed assembly version into a local variable

* save tracer version and framework name and version into static readonly variables

* no need to keep the strings around in static vars since the HttpClient (and its headers) are kept around forever
2019-07-30 20:36:56 -04:00