Skip to content

Commit

Permalink
[demo/cartservice] Add support for logs (#3213)
Browse files Browse the repository at this point in the history
Co-authored-by: Fabrizio Ferri-Benedetti <fferribenedetti@splunk.com>
Co-authored-by: Phillip Carter <pcarter@fastmail.com>
Co-authored-by: Mikko Viitanen <74129181+mviitane@users.noreply.github.com>
  • Loading branch information
4 people committed Aug 31, 2023
1 parent 7aa2911 commit 4b66499
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions content/en/docs/demo/services/cart.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ with a Redis caching service for fast access to shopping cart data.

[Cart service source](https://github.com/open-telemetry/opentelemetry-demo/blob/main/src/cartservice/)

> **Note** OpenTelemetry for .NET uses the `System.Diagnostic` library as its
> API in lieu of the standard OpenTelemetry API.
> **Note** OpenTelemetry for .NET uses the `System.Diagnostic.DiagnosticSource`
> library as its API instead of the standard OpenTelemetry API for Traces and
> Metrics. `Microsoft.Extensions.Logging.Abstractions` library is used for Logs.
## Traces

### Initializing Tracing

OpenTelemetry is configured in the .NET DI container. The `AddOpenTelemetry()`
builder method is used to configure desired instrumentation libraries, add
exporters, and set other options. Configuration of the exporter and resource
attributes is performed through environment variables.
OpenTelemetry is configured in the .NET dependency injection container. The
`AddOpenTelemetry()` builder method is used to configure desired instrumentation
libraries, add exporters, and set other options. Configuration of the exporter
and resource attributes is performed through environment variables.

```cs
Action<ResourceBuilder> appResourceBuilder =
Expand Down Expand Up @@ -72,9 +73,9 @@ activity?.AddEvent(new("Fetch cart"));

### Initializing Metrics

Similar to configuring OpenTelemetry Traces, the .NET DI container requires a
call to `AddOpenTelemetry()`. This builder configures desired instrumentation
libraries, exporters, etc.
Similar to configuring OpenTelemetry Traces, the .NET dependency injection
container requires a call to `AddOpenTelemetry()`. This builder configures
desired instrumentation libraries, exporters, etc.

```cs
Action<ResourceBuilder> appResourceBuilder =
Expand All @@ -91,4 +92,11 @@ builder.Services.AddOpenTelemetry()

## Logs

TBD
Logs are configured in the .NET dependency injection container on
`LoggingBuilder` level by calling `AddOpenTelemetry()`. This builder configures
desired options, exporters, etc.

```cs
builder.Logging
.AddOpenTelemetry(options => options.AddOtlpExporter());
```

0 comments on commit 4b66499

Please sign in to comment.