@@ -4,36 +4,36 @@ linkTitle: Libraries
4
4
weight : 3
5
5
---
6
6
7
- You can use [ instrumentation libraries] ( /docs/reference/specification/glossary/#instrumentation-library )
7
+ You can use
8
+ [ instrumentation libraries] ( /docs/reference/specification/glossary/#instrumentation-library )
8
9
in order to generate telemetry data for a particular instrumented library.
9
10
10
- For example, [ the instrumentation library for ASP.NET Core ] ( https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore )
11
- will automatically
12
- create [ spans ] ( /docs/concepts/signals/traces/#spans-in-opentelemetry )
13
- and [ metrics ] ( /docs/concepts/signals/metrics )
14
- based on the inbound HTTP requests.
11
+ For example,
12
+ [ the instrumentation library for ASP.NET Core ] ( https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNetCore )
13
+ will automatically create
14
+ [ spans ] ( /docs/concepts/signals/traces/#spans-in-opentelemetry ) and
15
+ [ metrics ] ( /docs/concepts/signals/metrics ) based on the inbound HTTP requests.
15
16
16
17
## Setup
17
18
18
19
Each instrumentation library is a NuGet package, and installing them is
19
20
typically done like so:
20
21
21
- ``` console
22
+ ```
22
23
dotnet add package OpenTelemetry.Instrumentation.{library-name-or-type}
23
24
```
24
25
25
26
It is typically then registered at application startup time, such as when
26
- creating a
27
- [ TracerProvider] ( /docs/concepts/signals/traces/#tracer-provider ) .
27
+ creating a [ TracerProvider] ( /docs/concepts/signals/traces/#tracer-provider ) .
28
28
29
29
## Example with ASP.NET Core and HttpClient
30
30
31
- As an example, here's how you can instrument inbound and output
32
- requests from an ASP.NET Core app.
31
+ As an example, here's how you can instrument inbound and output requests from an
32
+ ASP.NET Core app.
33
33
34
34
First, get the appropriate packages:
35
35
36
- ``` console
36
+ ```
37
37
dotnet add package OpenTelemetry --prerelease
38
38
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
39
39
dotnet add package OpenTelemetry.Exporter.Console --prerelease
@@ -87,16 +87,14 @@ app.MapGet("/hello", async () =>
87
87
app .Run ();
88
88
```
89
89
90
- When you run this code and access the ` /hello ` endpoint,
91
- the instrumentation libraries will:
90
+ When you run this code and access the ` /hello ` endpoint, the instrumentation
91
+ libraries will:
92
92
93
- * Start a new trace
94
- * Generate a span representing the request made to the endpoint
95
- * Generate a child span representing the HTTP GET made to
96
- ` https://example.com/ `
93
+ - Start a new trace
94
+ - Generate a span representing the request made to the endpoint
95
+ - Generate a child span representing the HTTP GET made to ` https://example.com/ `
97
96
98
- If you add more instrumentation libraries,
99
- then you get more telemetry data.
97
+ If you add more instrumentation libraries, then you get more telemetry data.
100
98
101
99
## Available instrumentation libraries
102
100
@@ -108,19 +106,20 @@ You can also find more instrumentations available in the
108
106
109
107
## Next steps
110
108
111
- After you have set up instrumentation libraries, you may want to add [ manual
112
- instrumentation] ( /docs/instrumentation/net/manual ) to collect custom telemetry
113
- data.
109
+ After you have set up instrumentation libraries, you may want to add
110
+ [ manual instrumentation] ( /docs/instrumentation/net/manual ) to collect custom
111
+ telemetry data.
114
112
115
- If you are using .NET Framework 4.x instead of modern .NET, refer to the [ .NET
116
- Framework docs] ( /docs/instrumentation/net/netframework ) to configure
113
+ If you are using .NET Framework 4.x instead of modern .NET, refer to the
114
+ [ .NET Framework docs] ( /docs/instrumentation/net/netframework ) to configure
117
115
OpenTelemetry and instrumentation libraries on .NET Framework.
118
116
119
- You'll also want to configure an appropriate exporter to [ export your telemetry
120
- data] ( /docs/instrumentation/net/exporters ) to one or more telemetry backends.
117
+ You'll also want to configure an appropriate exporter to
118
+ [ export your telemetry data] ( /docs/instrumentation/net/exporters ) to one or more
119
+ telemetry backends.
121
120
122
121
You can also check the
123
- [ automatic instrumentation for .NET] ( /docs/instrumentation/net/automatic ) ,
124
- which is currently in beta.
122
+ [ automatic instrumentation for .NET] ( /docs/instrumentation/net/automatic ) , which
123
+ is currently in beta.
125
124
126
125
[ opentelemetry-dotnet ] : https://github.com/open-telemetry/opentelemetry-dotnet
0 commit comments