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
@@ -9,9 +9,7 @@ This repository contains what you need to trace C# applications. Some quick note
9
9
-**Datadog C# APM is currently in Alpha**
10
10
- It supports .Net Framework version above 4.5 and .Net Core 2.0.
11
11
- It does not support out of process propagation.
12
-
- It does not provide automatic framework instrumentation, all instrumentation is [manual](#manual-instrumentation).
13
12
- Multiple AppDomains are not supported.
14
-
- Our tracer is based on the current OpenTracing standard, however we do not yet support the following features: `FollowsFrom` references, `Baggage` or `Log`.
15
13
16
14
## The Components
17
15
@@ -56,6 +54,26 @@ And check that the status is "running".
56
54
57
55
The logs are available at the path you configured in `trace.config``log_file` above.
58
56
57
+
### Automatic Instrumentation
58
+
59
+
#### ASP.NET Core
60
+
61
+
To instrument you ASP.NET Core application install the
62
+
`Datadog.Trace.AspNetCore` NuGet package and the following line to your
Once your application is configured this way all the requests to your
74
+
application will be traced and the active span will automatically be set to the
75
+
currently executing request.
76
+
59
77
### Manual Instrumentation
60
78
61
79
#### Introduction
@@ -64,167 +82,111 @@ Before instrumenting your application, have a look at the [Datadog APM Terminolo
64
82
65
83
#### Setup
66
84
67
-
In order to instrument you code you need to add the `Datadog.Trace` NuGet package to your project.
85
+
In order to instrument your code you need to add the `Datadog.Trace` NuGet
86
+
package to your project.
87
+
88
+
Your tracing adventure starts with the `Tracer` class that will be used to
89
+
instrument your code and should be accessed exclusively through the
90
+
`Tracer.Instance` singleton. `Trace.Instance` is statically initialized with a
91
+
`Tracer` created with the default settings but you may instantiate a new one
92
+
with customized values with the `Tracer.Create` method.
68
93
69
-
Your tracing adventure starts with the `ITracer` object, you should typically instantiate only one `ITracer` for the lifetime of your app and use it in all places of your code where you want to add tracing. Instantiating the `ITracer` is done with the `TracerFactory.GetTracer` method.
94
+
`Tracer.Create` takes a number of optional parameters that can be used to
95
+
customize the returned `Tracer`:
70
96
71
-
To get a tracer with default parameters (i.e. the agent endpoint set to `http://localhost:8126`, and the default service name set to the name of the AppDomain):
97
+
- agentEndpoint: the agent endpoint where the traces will be sent (default is http://localhost:8126)
98
+
- defaultServiceName: default name of the service (default is the name of the executing assembly)
99
+
- isDebugEnabled: turns on all debug logging, this may have an impact on application performance (default is false)
Set the ServiceName to recognize which service this trace belongs to; if you don't, the parent span's service name or in case of a root span the defaultServiceName stated above is used.
// Finish sets the span duration and sends it to the agent (if you don't call finish the data will never be sent to Datadog)
125
-
span.Finish();
126
-
```
127
-
128
-
You may add custom tags by calling `ISpan.SetTag`:
129
-
130
-
```csharp
131
-
ISpanspan=tracer.BuildSpan("SqlQuery").Start();
132
-
span.SetTag("db.rows", 10);
174
+
// Close closes the underlying span, this sets its duration and sends it to the agent (if you don't call Close the data will never be sent to Datadog)
175
+
scope.Close();
133
176
```
134
177
135
-
You should not have to explicitly declare parent/children relationship between your spans, but to override the default behavior - a new span is considered a child of the innermost open span in its logical context- use:
Cross-process tracing is supported by propagating context through HTTP headers. This is done with the `ITracer.Inject` and `ITracer.Extract` methods as documented in the [opentracing documentation](http://opentracing.io/documentation/pages/api/cross-process-tracing.html)
145
-
146
-
##### Injection
147
-
148
-
Example code to send a HTTP request with the right headers:
185
+
You should not have to explicitly declare parent/children relationship between your spans, but to override the default behavior - a new span is considered a child of the active Span - use:
149
186
150
187
```csharp
151
-
using (varspan=tracer.BuildSpan("Operation").Start())
0 commit comments