Skip to content

Commit

Permalink
Wrap .NET docs to 80 chars (#1072)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermp committed Jan 26, 2022
1 parent 11ed947 commit 95fac29
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 180 deletions.
19 changes: 12 additions & 7 deletions content/en/docs/instrumentation/net/_index.md
Expand Up @@ -8,8 +8,8 @@ weight: 12
---

Welcome to the OpenTelemetry for .NET documentation! This is intended to be an
overview of OpenTelemetry in this language, and a brief guide to its options
and features.
overview of OpenTelemetry in this language, and a brief guide to its options and
features.

OpenTelemetry for .NET supports all officially supported versions of [.NET
Core](https://dotnet.microsoft.com/download/dotnet-core) and [.NET
Expand All @@ -18,7 +18,8 @@ Framework](https://dotnet.microsoft.com/download/dotnet-framework) except for

# Status and Releases

This is the current release status for OpenTelemetry components in this language:
This is the current release status for OpenTelemetry components in this
language:

| Tracing | Metrics | Logging |
| ------- | ------- | ------- |
Expand All @@ -28,7 +29,11 @@ This is the current release status for OpenTelemetry components in this language

# Further Reading

- [OpenTelemetry .NET on GitHub](https://github.com/open-telemetry/opentelemetry-dotnet)
- [Getting Started](https://github.com/open-telemetry/opentelemetry-dotnet#getting-started)
- [OpenTelemetry .NET Contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib)
- [OpenTelemetry .NET Automatic Instrumentation on GitHub](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation)
- [OpenTelemetry .NET on
GitHub](https://github.com/open-telemetry/opentelemetry-dotnet)
- [Getting
Started](https://github.com/open-telemetry/opentelemetry-dotnet#getting-started)
- [OpenTelemetry .NET
Contrib](https://github.com/open-telemetry/opentelemetry-dotnet-contrib)
- [OpenTelemetry .NET Automatic Instrumentation on
GitHub](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation)
47 changes: 29 additions & 18 deletions content/en/docs/instrumentation/net/automatic.md
Expand Up @@ -4,26 +4,31 @@ weight: 3
linkTitle: Libraries
---

.NET does not support truly automatic instrumentation like other languages today. Instead, you'll need to depend on
[instrumentation libraries](https://opentelemetry.io/docs/reference/specification/glossary/#instrumentation-library)
.NET does not support truly automatic instrumentation like other languages
today. Instead, you'll need to depend on [instrumentation
libraries](https://opentelemetry.io/docs/reference/specification/glossary/#instrumentation-library)
that generate telemetry data for a particular instrumented library.

For example, the instrumentation library for ASP.NET Core will automatically create spans that track inbound requests
once you configure it in your app/service.
For example, the instrumentation library for ASP.NET Core will automatically
create spans that track inbound requests once you configure it in your
app/service.

## Setup

Each instrumentation library is a NuGet package, and installing them is typically done like so:
Each instrumentation library is a NuGet package, and installing them is
typically done like so:

```
dotnet add package OpenTelemetry.Instrumentation.{library-name-or-type}
```

It is typically then registered at application startup time, such as when creating a TracerProvider.
It is typically then registered at application startup time, such as when
creating a TracerProvider.

## Example with ASP.NET Core and HttpClient

As an example, here's how you can automatically instrument inbound and output requests from an ASP.NET Core app.
As an example, here's how you can automatically instrument inbound and output
requests from an ASP.NET Core app.

First, get the appropriate packages:

Expand Down Expand Up @@ -85,24 +90,30 @@ When you run this code and access the `/hello` endpoint, it will:

* Start a new trace
* Automatically generate a span representing the request made to the endpoint
* Automatically generate a child span representing the HTTP GET made to `https://example.com/`
* Automatically generate a child span representing the HTTP GET made to
`https://example.com/`

If you add more instrumentation libraries, then you can generate more data automatically.
If you add more instrumentation libraries, then you can generate more data
automatically.

## Available instrumentation libraries

A full list of instrumentation libraries produced by OpenTelemetry is available in the
[opentelemetry-dotnet](https://github.com/open-telemetry/opentelemetry-dotnet) repository.
A full list of instrumentation libraries produced by OpenTelemetry is available
in the
[opentelemetry-dotnet](https://github.com/open-telemetry/opentelemetry-dotnet)
repository.

You can also find more instrumentations available in the [opentelemetry registry](https://opentelemetry.io/registry/?language=dotnet&component=instrumentation).
You can also find more instrumentations available in the [opentelemetry
registry](https://opentelemetry.io/registry/?language=dotnet&component=instrumentation).

## Next steps

After you have set up instrumentation libraries, you may want to add
[manual instrumentation]({{< relref "manual" >}}) to collect custom telemetry data.
After you have set up instrumentation libraries, you may want to add [manual
instrumentation]({{< relref "manual" >}}) to collect custom telemetry data.

If you are using .NET Framework 4.x instead of modern .NET, refer to the [.NET Framework docs]({{< relref "netframework" >}})
to configure OpenTelemetry and instrumentation libraries on .NET Framework.
If you are using .NET Framework 4.x instead of modern .NET, refer to the [.NET
Framework docs]({{< relref "netframework" >}}) to configure OpenTelemetry and
instrumentation libraries on .NET Framework.

You'll also want to configure an appropriate exporter to [export your telemetry data]({{< relref "exporters" >}})
to one or more telemetry backends.
You'll also want to configure an appropriate exporter to [export your telemetry
data]({{< relref "exporters" >}}) to one or more telemetry backends.
61 changes: 37 additions & 24 deletions content/en/docs/instrumentation/net/exporters.md
Expand Up @@ -3,18 +3,21 @@ title: "Exporters"
weight: 4
---

In order to visualize and analyze your traces and metrics, you will need to export them to a backend.
In order to visualize and analyze your traces and metrics, you will need to
export them to a backend.

## Console exporter

The console exporter is useful for development and debugging tasks, and is the simplest to set up.
The console exporter is useful for development and debugging tasks, and is the
simplest to set up.

```
dotnet add package OpenTelemetry.Exporter.Console
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
```

If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core
services:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand All @@ -39,15 +42,17 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()

## OTLP endpoint or Collector

To send data to an OTLP endpoint or the [OpenTelemetry Collector](/docs/collector/getting-started/), you'll want
to configure an OTLP exporter that sends to your endpoint.
To send data to an OTLP endpoint or the [OpenTelemetry
Collector](/docs/collector/getting-started/), you'll want to configure an OTLP
exporter that sends to your endpoint.

```
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
```

If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core
services:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -79,7 +84,8 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.Build();
```

Use environment variables to set values like headers and an endpoint URL for production.
Use environment variables to set values like headers and an endpoint URL for
production.

### Using gRPC

Expand All @@ -89,8 +95,8 @@ You can also use gRPC to send your OTLP data. To do that, use the following:
OtlpExportProtocol.Grpc
```

If you're not using ASP.NET Core gRPC and you are running on .NET Core 3.x, you'll need to add
the following at application startup
If you're not using ASP.NET Core gRPC and you are running on .NET Core 3.x,
you'll need to add the following at application startup

```csharp
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
Expand All @@ -100,8 +106,9 @@ If you are using .NET 5 or higher, the previous code sample is not required.

## Jaeger

If you are using [Jaeger](https://www.jaegertracing.io/) to visualize trace data,
you'll need to set it up first. This is how to run it in a docker container:
If you are using [Jaeger](https://www.jaegertracing.io/) to visualize trace
data, you'll need to set it up first. This is how to run it in a docker
container:

```shell
$ docker run -d --name jaeger \
Expand All @@ -124,7 +131,8 @@ dotnet add package OpenTelemetry.Exporter.Jaeger
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
```

If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core
services:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -158,8 +166,9 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()

## Zipkin

If you are using [Zipkin](https://zipkin.io/) to visualize traces to visualize trace data,
you'll need to set it up first. This is how to run it in a docker container:
If you are using [Zipkin](https://zipkin.io/) to visualize traces to visualize
trace data, you'll need to set it up first. This is how to run it in a docker
container:

```shell
docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin
Expand All @@ -172,7 +181,8 @@ dotnet add package OpenTelemetry.Exporter.Zipkin
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
```

If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core
services:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -204,11 +214,11 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()

## Prometheus

If you're using Prometheus to visualize metrics data, you'll need to set it up first.
Here's how to do it using a docker container:
If you're using Prometheus to visualize metrics data, you'll need to set it up
first. Here's how to do it using a docker container:

First, you'll need a `prometheus.yml` file to configure your Prometheus backend, such
as the following:
First, you'll need a `prometheus.yml` file to configure your Prometheus backend,
such as the following:

```yml
global:
Expand Down Expand Up @@ -237,7 +247,8 @@ dotnet add package OpenTelemetry.Exporter.Prometheus
dotnet add package OpenTelemetry.Extensions.Hosting --prerelease
```

If you're using ASP.NET Core, configure the exporter in your ASP.NET Core services:
If you're using ASP.NET Core, configure the exporter in your ASP.NET Core
services:

```csharp
var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -275,8 +286,10 @@ using var tracerProvider = Sdk.CreateMeterProviderBuilder()

## Next steps

To ensure you're getting the most data as easily as possible, install [automatic instrumentation libraries]({{< relref "automatic" >}})
to automatically generate observability data.
To ensure you're getting the most data as easily as possible, install [automatic
instrumentation libraries]({{< relref "automatic" >}}) to automatically generate
observability data.

Additionally, enriching your instrumentation generated automatically with [manual instrumentation]({{< relref "manual" >}})
of your own codebase gets you customized observability data.
Additionally, enriching your instrumentation generated automatically with
[manual instrumentation]({{< relref "manual" >}}) of your own codebase gets you
customized observability data.
31 changes: 21 additions & 10 deletions content/en/docs/instrumentation/net/getting-started.md
Expand Up @@ -3,11 +3,17 @@ title: Getting Started
weight: 2
---

OpenTelemetry for .NET is unique among OpenTelemetry implementations, as it is integrated with the .NET `System.Diagnostics` library. At a high level, you can think of OpenTelemetry for .NET as a bridge between the telemetry available through `System.Diagnostics` and the greater OpenTelemetry ecosystem, such as OpenTelemetry Protocol (OTLP) and the OpenTelemetry Collector.
OpenTelemetry for .NET is unique among OpenTelemetry implementations, as it is
integrated with the .NET `System.Diagnostics` library. At a high level, you can
think of OpenTelemetry for .NET as a bridge between the telemetry available
through `System.Diagnostics` and the greater OpenTelemetry ecosystem, such as
OpenTelemetry Protocol (OTLP) and the OpenTelemetry Collector.

## Installation

OpenTelemetry is available as a [NuGet package](https://www.nuget.org/packages/OpenTelemetry/). Install it with your preferred package manager client.
OpenTelemetry is available as a [NuGet
package](https://www.nuget.org/packages/OpenTelemetry/). Install it with your
preferred package manager client.

For example, using the .NET CLI:

Expand Down Expand Up @@ -79,7 +85,8 @@ This output matches the span created in the preceding code sample.

## ASP.NET Core

The following sample demonstrates automatic and manual tracing with ASP.NET Core.
The following sample demonstrates automatic and manual tracing with ASP.NET
Core.

First, install requried packages:

Expand Down Expand Up @@ -137,7 +144,8 @@ app.MapGet("/hello", () =>
app.Run();
```

When you run the app and navigate to the `/hello` route, you'll see output similar to the following:
When you run the app and navigate to the `/hello` route, you'll see output
similar to the following:

```
Activity.Id: 00-d72f7e51dd06b57211f415489df89b1c-c8a394817946316d-01
Expand Down Expand Up @@ -175,15 +183,18 @@ Resource associated with Activity:
service.instance.id: 45aacfb0-e117-40cb-9d4d-9bcca661f6dd
```

This output has both the span created to track work in the route, and an automatically-created span that tracks the inbound ASP.NET Core request itself.
This output has both the span created to track work in the route, and an
automatically-created span that tracks the inbound ASP.NET Core request itself.

## Next steps

To ensure you're getting the most data as easily as possible, install some [instrumentation libraries]({{< relref "automatic" >}}) to automatically
To ensure you're getting the most data as easily as possible, install some
[instrumentation libraries]({{< relref "automatic" >}}) to automatically
generate observability data.

Additionally, enriching your instrumentation generated automatically with [manual instrumentation]({{< relref "manual" >}}) of your own codebase
gets you customized observability data.
Additionally, enriching your instrumentation generated automatically with
[manual instrumentation]({{< relref "manual" >}}) of your own codebase gets you
customized observability data.

You'll also want to configure an appropriate exporter to [export your telemetry data]({{< relref "exporters" >}})
to one or more telemetry backends.
You'll also want to configure an appropriate exporter to [export your telemetry
data]({{< relref "exporters" >}}) to one or more telemetry backends.

0 comments on commit 95fac29

Please sign in to comment.