Cleanup logging docs (#1563)

* Cleanup logging docs

* remove dead link

* fix link
This commit is contained in:
Cijo Thomas 2020-11-17 08:07:45 -08:00 committed by GitHub
parent 68adae64f4
commit 3c49d35cf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 116 deletions

View File

@ -191,8 +191,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{CB401DF1-F
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\trace\extending-the-sdk\extending-the-sdk.csproj", "{FCDCF532-A163-40DA-80B7-7530AA1182C4}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\trace\extending-the-sdk\extending-the-sdk.csproj", "{FCDCF532-A163-40DA-80B7-7530AA1182C4}"
EndProject 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}" 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.GrpcService", "examples\GrpcService\Examples.GrpcService.csproj", "{DB942F5A-D571-4DEA-B1A7-B6BE0E24E6ED}" 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Shared", "src\OpenTelemetry.Shared\OpenTelemetry.Shared.csproj", "{1E504265-1E32-4C61-8CC5-8FA373E16699}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Shared", "src\OpenTelemetry.Shared\OpenTelemetry.Shared.csproj", "{1E504265-1E32-4C61-8CC5-8FA373E16699}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.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.ActiveCfg = Release|Any CPU
{FCDCF532-A163-40DA-80B7-7530AA1182C4}.Release|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
{EAAC5A3C-708A-4609-A21F-8E5221AB58F2}.Debug|Any CPU.Build.0 = 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 {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} {5435517C-AEC5-4182-87AE-14E13D31525F} = {4D492D62-5150-45F9-817F-C99562E364E2}
{CB401DF1-FF5C-4055-886E-1183E832B2D6} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD} {CB401DF1-FF5C-4055-886E-1183E832B2D6} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
{FCDCF532-A163-40DA-80B7-7530AA1182C4} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818} {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} {DB942F5A-D571-4DEA-B1A7-B6BE0E24E6ED} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
{B3F03725-23A0-4582-9526-F6A7E38F35CC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} {B3F03725-23A0-4582-9526-F6A7E38F35CC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705} {13C10C9A-07E8-43EB-91F5-C2B116FBE0FC} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}

View File

@ -70,7 +70,6 @@ most common customization and extension scenarios:
exporter/processor/sampler](./docs/logs/extending-the-sdk/README.md) exporter/processor/sampler](./docs/logs/extending-the-sdk/README.md)
* [Building a custom trace * [Building a custom trace
exporter/processor/sampler](./docs/trace/extending-the-sdk/README.md) exporter/processor/sampler](./docs/trace/extending-the-sdk/README.md)
* [Correlating logs with traces](./docs/logs/correlation/README.md)
## Contributing ## Contributing

View File

@ -1,50 +0,0 @@
// <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 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<Program>();
logger.LogInformation("Hello, World!");
using (var activity = DemoSource.StartActivity("Foo"))
{
logger.LogInformation("Hello, World!");
}
}
}

View File

@ -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<Startup>();
});
```
`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/)

View File

@ -1,10 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<!---
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryPkgVer)" />
-->
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPkgVer)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePkgVer)" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>
</Project>

View File

@ -10,6 +10,7 @@
OpenTelemetry .NET SDK has provided the following built-in log exporters: OpenTelemetry .NET SDK has provided the following built-in log exporters:
* [InMemory](../../../src/OpenTelemetry.Exporter.InMemory/README.md) * [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 Custom exporters can be implemented to send telemetry data to places which are
not covered by the built-in exporters: not covered by the built-in exporters:

View File

@ -4,6 +4,7 @@
[![NuGet](https://img.shields.io/nuget/dt/OpenTelemetry.Exporter.Console.svg)](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console) [![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. 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 **Note:** this exporter is intended to be used during learning how telemetry
data are created and exported. It is not recommended for any production data are created and exported. It is not recommended for any production
@ -17,7 +18,10 @@ dotnet add package OpenTelemetry.Exporter.Console
See the See the
[`TestConsoleExporter.cs`](../../examples/Console/TestConsoleExporter.cs) for an [`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 ## References

View File

@ -73,8 +73,6 @@ using var otel = Sdk.CreateTracerProvider(b => b
## Advanced topics ## Advanced topics
* Logs
* [Correlating logs with traces](../../docs/logs/correlation/README.md)
* Metrics * Metrics
* [Building your own Exporter](../../docs/metrics/building-your-own-exporter.md) * [Building your own Exporter](../../docs/metrics/building-your-own-exporter.md)
* Trace * Trace