Skip to content

Commit

Permalink
Updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Jul 18, 2022
1 parent 12c92ad commit cf69b8c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 85 deletions.
6 changes: 6 additions & 0 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Tr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.LoggingExtensions", "examples\LoggingExtensions\Examples.LoggingExtensions.csproj", "{CCBBAD69-4A7D-41F8-8697-6E3F043F7BD5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Serilog.Tests", "test\OpenTelemetry.Extensions.Serilog.Tests\OpenTelemetry.Extensions.Serilog.Tests.csproj", "{C470DC46-8DE6-4668-BD25-ADF851F6E1E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -481,6 +483,10 @@ Global
{CCBBAD69-4A7D-41F8-8697-6E3F043F7BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCBBAD69-4A7D-41F8-8697-6E3F043F7BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCBBAD69-4A7D-41F8-8697-6E3F043F7BD5}.Release|Any CPU.Build.0 = Release|Any CPU
{C470DC46-8DE6-4668-BD25-ADF851F6E1E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C470DC46-8DE6-4668-BD25-ADF851F6E1E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C470DC46-8DE6-4668-BD25-ADF851F6E1E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C470DC46-8DE6-4668-BD25-ADF851F6E1E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 0 additions & 16 deletions examples/LogEmitter/Examples.LogEmitter.csproj

This file was deleted.

56 changes: 0 additions & 56 deletions examples/LogEmitter/Program.cs

This file was deleted.

11 changes: 0 additions & 11 deletions examples/LogEmitter/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Tracing\OpenTelemetry.Extensions.Tracing.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Serilog\OpenTelemetry.Extensions.Serilog.csproj" />
</ItemGroup>

Expand Down
9 changes: 8 additions & 1 deletion examples/LoggingExtensions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
// limitations under the License.
// </copyright>

using System.Diagnostics.Tracing;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;
using Serilog;

var resourceBuilder = ResourceBuilder.CreateDefault().AddService("Examples.LogEmitter");
var resourceBuilder = ResourceBuilder.CreateDefault().AddService("Examples.LoggingExtensions");

// Note: It is important that OpenTelemetryLoggerProvider is disposed when the
// app is shutdown. In this example we allow Serilog to do that by calling CloseAndFlush.
Expand All @@ -30,6 +31,12 @@
.AddConsoleExporter();
});

// Creates an OpenTelemetryEventSourceLogEmitter for routing EventSources with
// names matching OpenTelemetry* into logs
using var openTelemetryEventSourceLogEmitter = new OpenTelemetryEventSourceLogEmitter(
openTelemetryLoggerProvider,
(name) => name.StartsWith("OpenTelemetry") ? EventLevel.LogAlways : null);

// Configure Serilog global logger
Log.Logger = new LoggerConfiguration()
.WriteTo.OpenTelemetry(openTelemetryLoggerProvider, disposeProvider: true) // <- Register OpenTelemetry Serilog sink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)

data.Message = rawMessage;

this.logEmitter.Log(in data, in attributes);
this.logEmitter.Emit(in data, in attributes);
}
#pragma warning restore CA1062 // Validate arguments of public methods

Expand Down

0 comments on commit cf69b8c

Please sign in to comment.