Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: open-telemetry/opentelemetry-dotnet
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0-rc4
Choose a base ref
...
head repository: open-telemetry/opentelemetry-dotnet
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.0-rc5
Choose a head ref
  • 16 commits
  • 76 files changed
  • 11 contributors

Commits on Apr 28, 2021

  1. Doc for customizing tracing sdk (#2016)

    * Doc for customizing tracing sdk
    cijothomas authored Apr 28, 2021
    Copy the full SHA
    58a8d1b View commit details
  2. Copy the full SHA
    50b0148 View commit details

Commits on Apr 29, 2021

  1. Copy the full SHA
    d07ec26 View commit details

Commits on May 3, 2021

  1. Copy the full SHA
    4aeb61b View commit details
  2. Fix docs (#2022)

    andreatosato authored May 3, 2021
    Copy the full SHA
    6f2f7e4 View commit details
  3. Copy the full SHA
    073ce6c View commit details

Commits on May 4, 2021

  1. Update HttpInListener to add gRPC tags - By creating a new activity w…

    …ith the OperationName used by the framework (#1879)
    utpilla authored May 4, 2021
    Copy the full SHA
    c28efc3 View commit details
  2. Copy the full SHA
    9805587 View commit details

Commits on May 6, 2021

  1. Copy the full SHA
    6cdfcea View commit details

Commits on May 11, 2021

  1. Copy the full SHA
    7af7947 View commit details

Commits on May 25, 2021

  1. Add Windows and Linux status badge to main readme (#2061)

    * Add Windows and Linux status badge to main readme
    
    * code change to trigger full CI
    cijothomas authored May 25, 2021
    Copy the full SHA
    f84a98c View commit details

Commits on May 27, 2021

  1. Copy the full SHA
    a0fcbc0 View commit details

Commits on May 28, 2021

  1. Bug fix: Call Dispose for ThreadLocal variables (#2049)

    Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
    xiang17 and cijothomas authored May 28, 2021
    Copy the full SHA
    b4d3202 View commit details
  2. Copy the full SHA
    21c1791 View commit details

Commits on Jun 1, 2021

  1. Copy the full SHA
    5ddf9a4 View commit details

Commits on Jun 9, 2021

  1. Copy the full SHA
    f987ac8 View commit details
Showing with 1,142 additions and 810 deletions.
  1. +2 −1 .gitignore
  2. +7 −0 OpenTelemetry.sln
  3. +6 −2 README.md
  4. +5 −3 VERSIONING.md
  5. +12 −3 docs/logs/extending-the-sdk/MyExporter.cs
  6. +78 −0 docs/trace/customizing-the-sdk/Program.cs
  7. +118 −0 docs/trace/customizing-the-sdk/README.md
  8. +8 −0 docs/trace/customizing-the-sdk/customizing-the-sdk.csproj
  9. +2 −0 docs/trace/getting-started/README.md
  10. +20 −3 examples/AspNetCore/Controllers/WeatherForecastController.cs
  11. +20 −0 examples/AspNetCore/Program.cs
  12. +1 −0 examples/AspNetCore/appsettings.json
  13. +1 −0 src/OpenTelemetry.Api/.publicApi/net452/PublicAPI.Unshipped.txt
  14. +1 −0 src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
  15. +11 −0 src/OpenTelemetry.Api/CHANGELOG.md
  16. +25 −11 src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs
  17. +0 −83 src/OpenTelemetry.Api/Context/Propagation/BaseHeaderParser.cs
  18. +0 −44 src/OpenTelemetry.Api/Context/Propagation/GenericHeaderParser.cs
  19. +0 −54 src/OpenTelemetry.Api/Context/Propagation/HeaderUtilities.cs
  20. +0 −40 src/OpenTelemetry.Api/Context/Propagation/HttpHeaderParser.cs
  21. +0 −37 src/OpenTelemetry.Api/Context/Propagation/HttpParseResult.cs
  22. +0 −263 src/OpenTelemetry.Api/Context/Propagation/HttpRuleParser.cs
  23. +0 −123 src/OpenTelemetry.Api/Context/Propagation/NameValueHeaderValue.cs
  24. +49 −0 src/OpenTelemetry.Api/Internal/ActivityHelperExtensions.cs
  25. +1 −1 src/OpenTelemetry.Api/OpenTelemetry.Api.csproj
  26. +11 −0 src/OpenTelemetry.Api/Trace/TracerProviderBuilder.cs
  27. +8 −0 src/OpenTelemetry.Exporter.Console/CHANGELOG.md
  28. +15 −2 src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs
  29. +1 −1 src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj
  30. +8 −0 src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
  31. +1 −1 src/OpenTelemetry.Exporter.InMemory/InMemoryExporterHelperExtensions.cs
  32. +1 −1 src/OpenTelemetry.Exporter.InMemory/OpenTelemetry.Exporter.InMemory.csproj
  33. +8 −0 src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
  34. +1 −1 src/OpenTelemetry.Exporter.Jaeger/OpenTelemetry.Exporter.Jaeger.csproj
  35. +8 −0 src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
  36. +1 −1 src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj
  37. +4 −0 src/OpenTelemetry.Exporter.ZPages/CHANGELOG.md
  38. +1 −1 src/OpenTelemetry.Exporter.ZPages/OpenTelemetry.Exporter.ZPages.csproj
  39. +8 −0 src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
  40. +1 −1 src/OpenTelemetry.Exporter.Zipkin/OpenTelemetry.Exporter.Zipkin.csproj
  41. +4 −0 src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
  42. +4 −0 src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md
  43. +1 −1 src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs
  44. +10 −0 src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
  45. +6 −4 src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
  46. +1 −1 src/OpenTelemetry.Instrumentation.AspNetCore/README.md
  47. +0 −1 src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs
  48. +4 −0 src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md
  49. +4 −0 src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
  50. +4 −0 src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
  51. +4 −0 src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md
  52. +1 −1 src/OpenTelemetry.Shared/OpenTelemetry.Shared.csproj
  53. +4 −0 src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md
  54. +1 −1 src/OpenTelemetry.Shims.OpenTracing/OpenTelemetry.Shims.OpenTracing.csproj
  55. +1 −1 src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
  56. +1 −1 src/OpenTelemetry/.publicApi/net46/PublicAPI.Unshipped.txt
  57. +14 −2 src/OpenTelemetry/.publicApi/net461/PublicAPI.Unshipped.txt
  58. +14 −2 src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt
  59. +7 −0 src/OpenTelemetry/BatchLogRecordExportProcessor.cs
  60. +19 −0 src/OpenTelemetry/CHANGELOG.md
  61. +4 −3 src/OpenTelemetry/Internal/SelfDiagnosticsConfigRefresher.cs
  62. +27 −1 src/OpenTelemetry/Internal/SelfDiagnosticsEventListener.cs
  63. +80 −5 src/OpenTelemetry/Logs/LogRecord.cs
  64. +100 −0 src/OpenTelemetry/Logs/LogRecordScope.cs
  65. +2 −0 src/OpenTelemetry/Logs/OpenTelemetryLogger.cs
  66. +1 −1 src/OpenTelemetry/OpenTelemetry.csproj
  67. +13 −20 src/OpenTelemetry/Trace/TracerProviderBuilderBase.cs
  68. +0 −19 src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs
  69. +80 −0 test/Benchmarks/Logs/LogScopeBenchmarks.cs
  70. +9 −27 test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
  71. +88 −0 test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs
  72. +86 −7 test/OpenTelemetry.Tests/Logs/LogRecordTest.cs
  73. +23 −0 test/OpenTelemetry.Tests/Trace/ActivityExtensionsTest.cs
  74. +59 −0 test/OpenTelemetry.Tests/Trace/Propagation/BaggagePropagatorTest.cs
  75. +0 −35 test/OpenTelemetry.Tests/Trace/TracerProviderBuilderExtensionsTest.cs
  76. +22 −0 test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
*.user
*.userosscache
*.sln.docstates
.vscode/solution-explorer
.vscode/
.devcontainer/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
7 changes: 7 additions & 0 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
@@ -199,6 +199,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.5.0", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "exception-reporting", "docs\trace\exception-reporting\exception-reporting.csproj", "{08D29501-F0A3-468F-B18D-BD1821A72383}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "customizing-the-sdk", "docs\trace\customizing-the-sdk\customizing-the-sdk.csproj", "{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -393,6 +395,10 @@ Global
{08D29501-F0A3-468F-B18D-BD1821A72383}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08D29501-F0A3-468F-B18D-BD1821A72383}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08D29501-F0A3-468F-B18D-BD1821A72383}.Release|Any CPU.Build.0 = Release|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -423,6 +429,7 @@ Global
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{972396A8-E35B-499C-9BA1-765E9B8822E1} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{08D29501-F0A3-468F-B18D-BD1821A72383} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
{64E3D8BB-93AB-4571-93F7-ED8D64DFFD06} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,10 +2,13 @@

[![Slack](https://img.shields.io/badge/slack-@cncf/otel/dotnet-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01N3BC2W7Q)
[![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet/branch/main/graphs/badge.svg?)](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet/)
[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-dotnet?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-dotnet/releases/)
[![Nuget](https://img.shields.io/nuget/vpre/OpenTelemetry.svg)](https://www.nuget.org/profiles/OpenTelemetry)
[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-dotnet)](https://github.com/open-telemetry/opentelemetry-dotnet/releases/)
[![Nuget](https://img.shields.io/nuget/v/OpenTelemetry.svg)](https://www.nuget.org/profiles/OpenTelemetry)
[![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.svg)](https://www.nuget.org/profiles/OpenTelemetry)

[![Windows](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/windows-ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/windows-ci.yml)
[![Linux](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/linux-ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-dotnet/actions/workflows/linux-ci.yml)

The .NET [OpenTelemetry](https://opentelemetry.io/) client.

## Supported .NET Versions
@@ -97,6 +100,7 @@ Approvers
* [Eddy Nakamura](https://github.com/eddynaka), Microsoft
* [Paulo Janotti](https://github.com/pjanotti), Splunk
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Utkarsh Umesan Pillai](https://github.com/utpilla), Microsoft

*Find more about the approver role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).*
8 changes: 5 additions & 3 deletions VERSIONING.md
Original file line number Diff line number Diff line change
@@ -56,9 +56,11 @@ changes. For example,
shows the public APIs, per target framework for the
`OpenTelemetry.Instrumentation.AspNetCore` package.

Since no stable version has been released so far, every API is listed in the
"Unshipped.txt" file. Once 1.0.0 is shipped, it'll be moved to "Shipped.txt"
file.
APIs which are released as part of stable packages will be listed in the
"Shipped.txt" file, and those APIs which are released as part of
[pre-release](#pre-releases) packages in the "Unshipped.txt". APIs will be moved
from "Unshipped.txt" to "Shipped.txt" when the packages move from
[pre-release](#pre-releases) to stable.

## Packaging

15 changes: 12 additions & 3 deletions docs/logs/extending-the-sdk/MyExporter.cs
Original file line number Diff line number Diff line change
@@ -44,12 +44,21 @@ public override ExportResult Export(in Batch<LogRecord> batch)

sb.Append($"{record}(");

int scopeDepth = -1;

record.ForEachScope(ProcessScope, sb);

static void ProcessScope(object scope, StringBuilder builder)
=> builder.Append($"{scope}");
void ProcessScope(LogRecordScope scope, StringBuilder builder)
{
if (++scopeDepth > 0)
{
builder.Append(", ");
}

builder.Append($"{scope.Scope}");
}

sb.Append($")");
sb.Append(')');
}

Console.WriteLine($"{this.name}.Export([{sb.ToString()}])");
78 changes: 78 additions & 0 deletions docs/trace/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;

public class Program
{
private static readonly ActivitySource MyLibraryActivitySource = new ActivitySource(
"MyCompany.MyProduct.MyLibrary");

private static readonly ActivitySource ComponentAActivitySource = new ActivitySource(
"AbcCompany.XyzProduct.ComponentA");

private static readonly ActivitySource ComponentBActivitySource = new ActivitySource(
"AbcCompany.XyzProduct.ComponentB");

private static readonly ActivitySource SomeOtherActivitySource = new ActivitySource(
"SomeCompany.SomeProduct.SomeComponent");

public static void Main()
{
using var tracerProvider = Sdk.CreateTracerProviderBuilder()

// The following adds subscription to activities from Activity Source
// named "MyCompany.MyProduct.MyLibrary" only.
.AddSource("MyCompany.MyProduct.MyLibrary")

// The following adds subscription to activities from all Activity Sources
// whose name starts with "AbcCompany.XyzProduct.".
.AddSource("AbcCompany.XyzProduct.*")
.AddConsoleExporter()
.Build();

// This activity source is enabled.
using (var activity = MyLibraryActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is enabled through wild card "AbcCompany.XyzProduct.*"
using (var activity = ComponentAActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is enabled through wild card "AbcCompany.XyzProduct.*"
using (var activity = ComponentBActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}

// This activity source is not enabled, so activity will
// be null here.
using (var activity = SomeOtherActivitySource.StartActivity("SayHello"))
{
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
}
}
}
118 changes: 118 additions & 0 deletions docs/trace/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Customizing OpenTelemetry .NET SDK

**This doc is work-in-progress.**

## TracerProvider

As shown in the [getting-started](../getting-started/README.md) doc, a valid
[`TracerProvider`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#tracer-provider)
must be configured and built to collect traces with OpenTelemetry .NET Sdk.
`TracerProvider` holds all the configuration for tracing like samplers,
processors, etc. Naturally, almost all the customizations must be done on the
`TracerProvider`.

## Building a TracerProvider

Building a `TracerProvider` is done using `TracerProviderBuilder` which must be
obtained by calling `Sdk.CreateTracerProviderBuilder()`. `TracerProviderBuilder`
exposes various methods which configures the provider it is going to build. These
includes methods like `SetSampler`, `AddProcessor` etc, and are explained in
subsequent sections of this document. Once configuration is done, calling
`Build()` on the `TracerProviderBuilder` builds the `TracerProvider` instance.
Once built, changes to its configuration is not allowed, with the exception of
adding more processors. In most cases, a single `TracerProvider` is created at
the application startup, and is disposed when application shuts down.

The snippet below shows how to build a basic `TracerProvider`. This will create
a provider with default configuration, and is not particularly useful. The
subsequent sections shows how to build a more useful provider.

```csharp
using OpenTelemetry;
using OpenTelemetry.Trace;

using var tracerProvider = Sdk.CreateTracerProviderBuilder().Build();
```

## TracerProvider configuration

`TracerProvider` holds the tracing configuration, which includes the following:

1. The list of `ActivitySource`s (aka Tracers) from which traces are collected.
2. The list of instrumentations enabled via
[InstrumentationLibrary](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#instrumentation-library).
3. The list of
[Processors](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-processor),
including exporting processors which exports traces to
[Exporters](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#span-exporter)
4. The
[Resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md)
associated with the traces.
5. The
[Sampler](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#sampler)
to be used.

### Activity Source

`ActivitySource` denotes a
[`Tracer`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#tracer),
which is used to start activities. The SDK follows an explicit opt-in model for
listening to activity sources. i.e, by default, it listens to no sources. Every
activity source which produce telemetry must be explicitly added to the tracer
provider to start collecting traces from them.

`AddSource` method on `TracerProviderBuilder` can be used to add a
`ActivitySource` to the provider. The name of the `ActivitySource`
(case-insensitive) must be the argument to this method. Multiple `AddSource` can
be called to add more than one source. It also supports wild-card subscription
model as well.

It is not possible to add sources *after* the provider is built, by calling the
`Build()` method on the `TracerProviderBuilder`.

The snippet below shows how to add activity sources to the provider.

```csharp
using OpenTelemetry;
using OpenTelemetry.Trace;

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
// The following subscribes to activities from Activity Source
// named "MyCompany.MyProduct.MyLibrary" only.
.AddSource("MyCompany.MyProduct.MyLibrary")
// The following subscribes to activities from all Activity Sources
// whose name starts with "AbcCompany.XyzProduct.".
.AddSource("AbcCompany.XyzProduct.*")
.Build();
```

See [Program.cs](./Program.cs) for complete example.

**Note**
A common mistake while configuring `TracerProvider` is forgetting to add
all `ActivitySources` to the provider. It is recommended to leverage the
wild card subscription model where it makes sense. For example, if your
application is expecting to enable tracing from a number of libraries
from a company "Abc", the you can use `AddSource("Abc.*")` to enable
all sources whose name starts with "Abc.".

### Instrumentation

// TODO

### Processor

// TODO

### Resource

// TODO

### Sampler

// TODO

## Context Propagation

// TODO: OpenTelemetry Sdk contents about Context.
// TODO: Links to built-in instrumentations doing Propagation.
8 changes: 8 additions & 0 deletions docs/trace/customizing-the-sdk/customizing-the-sdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<!---
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryExporterConsolePkgVer)" />
-->
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions docs/trace/getting-started/README.md
Original file line number Diff line number Diff line change
@@ -77,5 +77,7 @@ to learn more.

## Learn more

* If you want to customize the Sdk, refer to [customizing
the SDK](../customizing-the-sdk/README.md).
* If you want to build a custom exporter/processor/sampler, refer to [extending
the SDK](../extending-the-sdk/README.md).
23 changes: 20 additions & 3 deletions examples/AspNetCore/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
using System.Net.Http;
using Examples.AspNetCore.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace Examples.AspNetCore.Controllers
{
@@ -32,23 +33,39 @@ public class WeatherForecastController : ControllerBase
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
};

private static HttpClient httpClient = new HttpClient();
private static readonly HttpClient HttpClient = new HttpClient();

private readonly ILogger<WeatherForecastController> logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
using var scope = this.logger.BeginScope("{Id}", Guid.NewGuid().ToString("N"));

// Making an http call here to serve as an example of
// how dependency calls will be captured and treated
// automatically as child of incoming request.
var res = httpClient.GetStringAsync("http://google.com").Result;
var res = HttpClient.GetStringAsync("http://google.com").Result;
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
var forecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)],
})
.ToArray();

this.logger.LogInformation(
"WeatherForecasts generated {count}: {forecasts}",
forecast.Length,
forecast);

return forecast;
}
}
}
Loading