You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatically instrument methods decorated with [Trace] (Datadog.Trace.Annotations.TraceAttribute) (DataDog#2606)
* Implement feature to customize span operation and resource name in TraceAnnotationsIntegration spans by decorating a method specified by DD_TRACE_METHODS with a Datadog.Trace.TraceAttribute
Next: Have the profiler automatically find methods with the Datadog.Trace.TraceAttribute and instrument them with the TraceAnnotationsIntegration
* Test: Update tests with a brand new type that isn't not specified in DD_TRACE_METHODS, decorate it with the Datadog.Trace.TraceAttribute, and assert that we have a new span. Also apply the attribute to methods already specified by DD_TRACE_METHODS and assert that we have the same number of spans and that the attribute's ResourceName and OperationName properties get applied to the generated span.
Product:
- Modify the ModuleLoadFinished callback to look through a module (so long as we don't intentionally skip it) to look for methods decorated with Datadog.Trace.TraceAttribute and request ReJIT on them. If the integrations have not been loaded yet, they're put on a queue to be requested for ReJIT at a later ModuleLoadFinished callback.
- Add a new PInvoke in the profiler to add the TraceAnnotationsIntegration type earlier in the startup code path than the InitializeTraceMethods PInvoke, which occurs after Tracer initialization
* Remove Samples.TraceAnnotations.Program[RunTestsAsync] from DD_TRACE_METHODS and mark it with [Trace] to demonstrate that we can instrument early methods (except for the entrypoint Main) at this point
* Update GetIntegrationsFromTraceMethodsConfiguration signature to accept a TypeReference argument so we can re-use the one trace_annotation_integration_type TypeReference
* Add documentation to Datadog.Trace.TraceAttribute and update public api test
* Add log message in TraceAnnotationInfoFactory
* Try to remove whitespace changes
* Fix typo in test case
* Improve logging in cor_profiler.cpp
* Handle Datadog.Trace.TraceAttribute in managed code only by doing reflection, do not depend on having a type reference to it
* - Rename Datadog.Trace.TraceAttribute to Datadog.Trace.Annotations.TraceAttribute and move it to a new Datadog.Trace.Annotations assembly/package
- In Samples.TraceAnnotations, test the official Datadog.Trace.Annotations.TraceAttribute type from the Datadog.Trace.Annotations assembly under alias OfficialTraceAttribute and test a custom-built Datadog.Trace.Annotations.TraceAttribute type from the Samples.TraceAnnotations assembly under alias CustomTraceAttribute
* Add new public API test for Datadog.Trace.Annotations assembly and do some small refactorin
* Add public api tests for Datadog.Trace.AspNet
* Fix snapshots after rebase
* Update docs/Datadog.Trace.Annotations/README.md
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
* Delete public API test for Datadog.Trace.AspNet since we don't expose this to developers
* Implement PR feedback
- Apply nullable at project level for Datadog.Trace.Annotations
- Add attribute to property setter to demonstrate how to use the trace attribute on property accessors methods
- Create a constant field for WStr("Datadog.Trace.Annotations.TraceAttribute") and a static field for its c_string
- Fix comments
- Fix public API snapshots for net6.0
* Fix transient issue with public API test where the test would fail if running multiple tests at once
* Additional docs update to mention the existence of the Datadog.Trace.Annotations NuGet package from the Datadog.Trace README.
Also add further documentation in the Datadog.Trace.Annotations README.
* Add code snippet for TraceAttribute into README
* Add missing Datadog.OpenTracing public api test
* Update trace annotations snapshots
* Optimization: Do not search for trace attributes in assemblies that have the following prefixes
- "System."
- "Microsoft."
- "Datadog."
* Use an updated version of the Datadog.Trace package for the Samples.TraceAnnotations.VersionMismatch.NewerNuGet test application that contains the logic to scan for [Trace]
* Add feature flag DD_TRACE_ANNOTATIONS_ENABLED to control whether the trace annotations feature is enabled, since it incurs an added runtime cost. The default is true so users can immediately take advantage of the feature
Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
This package contains custom attribute types to enable additional features of the Datadog APM instrumentation library.
4
+
5
+
> Note: Automatic instrumentation is required for the attributes in this package to take effect. Please [read our documentation](https://docs.datadoghq.com/tracing/setup/dotnet) for details on how to install the tracer for automatic instrumentation.
6
+
7
+
> Note: If you are unable to add new package references to your application, you may still enable this functionality by defining types inside your application whose full name and type members match the definitions in this package.
8
+
9
+
## Attributes
10
+
### Datadog.Trace.Annotations.TraceAttribute
11
+
An attribute that marks the decorated method to be instrumented by Datadog automatic instrumentation. [Source](https://github.com/DataDog/dd-trace-dotnet/tree/master/tracer/src/Datadog.Trace.Annotations/TraceAttribute.cs)
Copy file name to clipboardExpand all lines: docs/Datadog.Trace/README.md
+2
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ This package contains the Datadog .NET APM tracer for configuring custom instrum
4
4
5
5
> If you are only using automatic instrumentation, **you do not need this package**. Please [read our documentation](https://docs.datadoghq.com/tracing/setup/dotnet) for details on how to install the tracer for automatic instrumentation.
6
6
7
+
> If you are using automatic instrumentation and would like to interact with APM only through C# attributes, see the [Datadog.Trace.Annotations](https://www.nuget.org/packages/Datadog.Trace.Annotations/) NuGet package.
8
+
7
9
## Getting Started
8
10
9
11
1. Configure the Datadog agent for APM [as described in our documentation](https://docs.datadoghq.com/tracing/setup_overview/setup/dotnet-core#configure-the-datadog-agent-for-apm).
0 commit comments