diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 5d3a256d699..62375dcae64 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -191,8 +191,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{CB401DF1-F EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\trace\extending-the-sdk\extending-the-sdk.csproj", "{FCDCF532-A163-40DA-80B7-7530AA1182C4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "correlation", "docs\logs\correlation\correlation.csproj", "{B26BE278-C9DA-4067-A0EE-6A4227B3DC87}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.W3cTraceContext.Tests", "test\OpenTelemetry.Instrumentation.W3cTraceContext.Tests\OpenTelemetry.Instrumentation.W3cTraceContext.Tests.csproj", "{EAAC5A3C-708A-4609-A21F-8E5221AB58F2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.GrpcService", "examples\GrpcService\Examples.GrpcService.csproj", "{DB942F5A-D571-4DEA-B1A7-B6BE0E24E6ED}" @@ -205,7 +203,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\l EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Shared", "src\OpenTelemetry.Shared\OpenTelemetry.Shared.csproj", "{1E504265-1E32-4C61-8CC5-8FA373E16699}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp.AspNetCore.5.0", "test\TestApp.AspNetCore.5.0\TestApp.AspNetCore.5.0.csproj", "{972396A8-E35B-499C-9BA1-765E9B8822E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.5.0", "test\TestApp.AspNetCore.5.0\TestApp.AspNetCore.5.0.csproj", "{972396A8-E35B-499C-9BA1-765E9B8822E1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -377,10 +375,6 @@ Global {FCDCF532-A163-40DA-80B7-7530AA1182C4}.Debug|Any CPU.Build.0 = Debug|Any CPU {FCDCF532-A163-40DA-80B7-7530AA1182C4}.Release|Any CPU.ActiveCfg = Release|Any CPU {FCDCF532-A163-40DA-80B7-7530AA1182C4}.Release|Any CPU.Build.0 = Release|Any CPU - {B26BE278-C9DA-4067-A0EE-6A4227B3DC87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B26BE278-C9DA-4067-A0EE-6A4227B3DC87}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B26BE278-C9DA-4067-A0EE-6A4227B3DC87}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B26BE278-C9DA-4067-A0EE-6A4227B3DC87}.Release|Any CPU.Build.0 = Release|Any CPU {EAAC5A3C-708A-4609-A21F-8E5221AB58F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EAAC5A3C-708A-4609-A21F-8E5221AB58F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {EAAC5A3C-708A-4609-A21F-8E5221AB58F2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -435,7 +429,6 @@ Global {5435517C-AEC5-4182-87AE-14E13D31525F} = {4D492D62-5150-45F9-817F-C99562E364E2} {CB401DF1-FF5C-4055-886E-1183E832B2D6} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD} {FCDCF532-A163-40DA-80B7-7530AA1182C4} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818} - {B26BE278-C9DA-4067-A0EE-6A4227B3DC87} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} {DB942F5A-D571-4DEA-B1A7-B6BE0E24E6ED} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E} {B3F03725-23A0-4582-9526-F6A7E38F35CC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} {13C10C9A-07E8-43EB-91F5-C2B116FBE0FC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} diff --git a/README.md b/README.md index 6accb28cb97..a4d94a6c447 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,6 @@ most common customization and extension scenarios: exporter/processor/sampler](./docs/logs/extending-the-sdk/README.md) * [Building a custom trace exporter/processor/sampler](./docs/trace/extending-the-sdk/README.md) -* [Correlating logs with traces](./docs/logs/correlation/README.md) ## Contributing diff --git a/docs/logs/correlation/Program.cs b/docs/logs/correlation/Program.cs deleted file mode 100644 index 652915b8fd0..00000000000 --- a/docs/logs/correlation/Program.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// 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. -// - -using System.Diagnostics; -using Microsoft.Extensions.Logging; -using OpenTelemetry; -using OpenTelemetry.Trace; - -public class Program -{ - private static readonly ActivitySource DemoSource = new ActivitySource("OTel.Demo"); - - public static void Main() - { - using var tracerProvider = Sdk.CreateTracerProviderBuilder() - .AddSource("OTel.Demo") - .Build(); - - using var loggerFactory = LoggerFactory.Create(builder => - { - builder - .AddJsonConsole(options => { options.IncludeScopes = true; }) - .Configure(options => options.ActivityTrackingOptions = - ActivityTrackingOptions.TraceId | - ActivityTrackingOptions.SpanId); - }); - - var logger = loggerFactory.CreateLogger(); - - logger.LogInformation("Hello, World!"); - - using (var activity = DemoSource.StartActivity("Foo")) - { - logger.LogInformation("Hello, World!"); - } - } -} diff --git a/docs/logs/correlation/README.md b/docs/logs/correlation/README.md deleted file mode 100644 index 1945de82e55..00000000000 --- a/docs/logs/correlation/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# Correlate Logs with Traces - -Starting from `Microsoft.Extensions.Logging` version `5.0`, logs can be -correlated with distributed tracing by enriching each log entry with the -information from the enclosing `Activity`. This can be achieved by enabling the -`ActivityTrackingOptions`. In a [non-host console -app](https://docs.microsoft.com/aspnet/core/fundamentals/logging#non-host-console-app), -it can be achieved as shown below. - -```csharp -using var loggerFactory = LoggerFactory.Create(builder => -{ - builder.Configure(options => options.ActivityTrackingOptions = - ActivityTrackingOptions.TraceId | - ActivityTrackingOptions.SpanId); -}); -``` - -Please refer to the example [here](./Program.cs). - -In an ASP.NET Core app, the above can be achieved by modifying the host -building, as shown below. - -```csharp -public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureLogging(loggingBuilder => - loggingBuilder.Configure(options => - options.ActivityTrackingOptions = - ActivityTrackingOptions.TraceId - | ActivityTrackingOptions.SpanId)) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); -``` - -`Microsoft.Extensions.Logging.ActivityTrackingOptions` supports `TraceId`, -`SpanId`, `ParentId`, `TraceFlags` and `TraceState`. - -## References - -* [ILogger](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger) -* [Microsoft.Extensions.Logging](https://www.nuget.org/packages/Microsoft.Extensions.Logging/) diff --git a/docs/logs/correlation/correlation.csproj b/docs/logs/correlation/correlation.csproj deleted file mode 100644 index 673e43f4df7..00000000000 --- a/docs/logs/correlation/correlation.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/docs/logs/extending-the-sdk/README.md b/docs/logs/extending-the-sdk/README.md index e623202ed4e..3628e77eb86 100644 --- a/docs/logs/extending-the-sdk/README.md +++ b/docs/logs/extending-the-sdk/README.md @@ -10,6 +10,7 @@ OpenTelemetry .NET SDK has provided the following built-in log exporters: * [InMemory](../../../src/OpenTelemetry.Exporter.InMemory/README.md) +* [Console](../../../src/OpenTelemetry.Exporter.Console/README.md) Custom exporters can be implemented to send telemetry data to places which are not covered by the built-in exporters: diff --git a/src/OpenTelemetry.Exporter.Console/README.md b/src/OpenTelemetry.Exporter.Console/README.md index 79c7fec6bab..dccf623de29 100644 --- a/src/OpenTelemetry.Exporter.Console/README.md +++ b/src/OpenTelemetry.Exporter.Console/README.md @@ -4,6 +4,7 @@ [![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.Exporter.Console.svg)](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console) The console exporter prints data to the Console window. +ConsoleExporter supports exporting both traces and logs. **Note:** this exporter is intended to be used during learning how telemetry data are created and exported. It is not recommended for any production @@ -17,7 +18,10 @@ dotnet add package OpenTelemetry.Exporter.Console See the [`TestConsoleExporter.cs`](../../examples/Console/TestConsoleExporter.cs) for an -example of how to use the exporter. +example of how to use the exporter for exporting traces. + +See the [Program](../../docs/logs/getting-started/Program.cs) for +an example of how to use the exporter for exporting logs. ## References diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index c6113287ed0..79d45b8c52e 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -73,8 +73,6 @@ using var otel = Sdk.CreateTracerProvider(b => b ## Advanced topics -* Logs - * [Correlating logs with traces](../../docs/logs/correlation/README.md) * Metrics * [Building your own Exporter](../../docs/metrics/building-your-own-exporter.md) * Trace