Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs-branch] Add LoggerProvider spec changes #3707

Merged
merged 29 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e30c3a4
Added back removed projects.
CodeBlanch Sep 29, 2022
1c5e237
Added back API changes.
CodeBlanch Sep 29, 2022
afca077
Updated logger artifacts to be public in API.
CodeBlanch Sep 29, 2022
4b2ae0f
Added back SDK changes.
CodeBlanch Sep 29, 2022
04239f7
Revert global.json changes.
CodeBlanch Sep 29, 2022
6315bc9
Added LoggerProvider extensions.
CodeBlanch Sep 29, 2022
985743a
Fix up Serilog + EventSource projects.
CodeBlanch Sep 29, 2022
f1d4587
CHANGELOG stubs.
CodeBlanch Sep 29, 2022
46cf817
Add back ConsoleExporter changes.
CodeBlanch Sep 29, 2022
5d0d1a2
CHANGELOG stub.
CodeBlanch Sep 29, 2022
8108a4b
Added back InMemoryExporter changes.
CodeBlanch Sep 29, 2022
015221e
Added back OtlpExporter changes.
CodeBlanch Sep 29, 2022
1315570
Added back docs changes.
CodeBlanch Sep 29, 2022
fd1fb8f
Add back examples changes.
CodeBlanch Sep 29, 2022
05136dc
Benchmark fixes.
CodeBlanch Sep 29, 2022
7d3f16d
Benchmark fixes.
CodeBlanch Sep 29, 2022
bc802eb
Add back OtlpExporter test changes.
CodeBlanch Sep 29, 2022
53ea49d
Logs stress test fixes.
CodeBlanch Sep 29, 2022
7d9f35d
Added back test changes.
CodeBlanch Sep 29, 2022
4e08199
Expose more of the new API in SDK.
CodeBlanch Sep 29, 2022
2b2a565
Updates for LogRecord.Severity being made public.
CodeBlanch Sep 29, 2022
7abbe99
Run workflows for any branch starting with "main". (#3708)
CodeBlanch Sep 29, 2022
7c0f485
Revert breaking changes.
CodeBlanch Sep 30, 2022
783bcb0
Suppress a breaking change warning.
CodeBlanch Sep 30, 2022
cc01481
Patch CHANGELOGs.
CodeBlanch Sep 30, 2022
9a8884c
Add back OpenTelemetryLoggerOptions.ConfigureResource.
CodeBlanch Sep 30, 2022
c38e573
[Repo] ApiCompat updates (#3716)
CodeBlanch Sep 30, 2022
d196c78
Tweaks.
CodeBlanch Sep 30, 2022
7fea768
Updated batch log processor envvar keys from spec.
CodeBlanch Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/apicompatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: API Compatibility

on:
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Code Coverage

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: docfx

on:
push:
branches: [ main ]
branches: [ 'main*' ]
pull_request:
branches: [ main ]
branches: [ 'main*' ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-format-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: dotnet format

on:
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.cs'
- '.editorconfig'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: dotnet format

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.cs'
- '.editorconfig'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.cs'
- '.editorconfig'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Integration Tests

on:
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Integration Tests

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux-ci-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Linux

on:
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Linux

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: markdownlint

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.md'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sanitycheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: sanitycheck

on:
push:
branches: [ main ]
branches: [ 'main*' ]
pull_request:
branches: [ main ]
branches: [ 'main*' ]

jobs:
misspell:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-ci-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Windows

on:
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths:
- '**.md'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Windows

on:
push:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
branches: [ 'main*' ]
paths-ignore:
- '**.md'

Expand Down
31 changes: 31 additions & 0 deletions OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Tests.Stress.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore", "test\TestApp.AspNetCore\TestApp.AspNetCore.csproj", "{5FDAF679-DE5A-4C73-A49B-8ABCF2399229}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.LoggingExtensions", "examples\LoggingExtensions\Examples.LoggingExtensions.csproj", "{7642798D-12D4-403A-BB92-B6BEF67C9D4F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.EventSource", "src\OpenTelemetry.Extensions.EventSource\OpenTelemetry.Extensions.EventSource.csproj", "{E55029E5-46B5-46E5-9BB3-CD5CE63E16CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Serilog", "src\OpenTelemetry.Extensions.Serilog\OpenTelemetry.Extensions.Serilog.csproj", "{CB55CD2E-449C-44A2-A7CA-3C701B533F16}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.EventSource.Tests", "test\OpenTelemetry.Extensions.EventSource.Tests\OpenTelemetry.Extensions.EventSource.Tests.csproj", "{2A896854-8537-4BD6-8E1C-2B66B1160258}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Serilog.Tests", "test\OpenTelemetry.Extensions.Serilog.Tests\OpenTelemetry.Extensions.Serilog.Tests.csproj", "{3B3C3571-6116-49D6-B28F-2A541E003577}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -476,6 +486,26 @@ Global
{5FDAF679-DE5A-4C73-A49B-8ABCF2399229}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FDAF679-DE5A-4C73-A49B-8ABCF2399229}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FDAF679-DE5A-4C73-A49B-8ABCF2399229}.Release|Any CPU.Build.0 = Release|Any CPU
{7642798D-12D4-403A-BB92-B6BEF67C9D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7642798D-12D4-403A-BB92-B6BEF67C9D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7642798D-12D4-403A-BB92-B6BEF67C9D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7642798D-12D4-403A-BB92-B6BEF67C9D4F}.Release|Any CPU.Build.0 = Release|Any CPU
{E55029E5-46B5-46E5-9BB3-CD5CE63E16CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E55029E5-46B5-46E5-9BB3-CD5CE63E16CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E55029E5-46B5-46E5-9BB3-CD5CE63E16CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E55029E5-46B5-46E5-9BB3-CD5CE63E16CB}.Release|Any CPU.Build.0 = Release|Any CPU
{CB55CD2E-449C-44A2-A7CA-3C701B533F16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB55CD2E-449C-44A2-A7CA-3C701B533F16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB55CD2E-449C-44A2-A7CA-3C701B533F16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB55CD2E-449C-44A2-A7CA-3C701B533F16}.Release|Any CPU.Build.0 = Release|Any CPU
{2A896854-8537-4BD6-8E1C-2B66B1160258}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A896854-8537-4BD6-8E1C-2B66B1160258}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A896854-8537-4BD6-8E1C-2B66B1160258}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A896854-8537-4BD6-8E1C-2B66B1160258}.Release|Any CPU.Build.0 = Release|Any CPU
{3B3C3571-6116-49D6-B28F-2A541E003577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B3C3571-6116-49D6-B28F-2A541E003577}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B3C3571-6116-49D6-B28F-2A541E003577}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B3C3571-6116-49D6-B28F-2A541E003577}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -512,6 +542,7 @@ Global
{6C7A1595-36D6-4229-BBB5-5A6B5791791D} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{9A07D215-90AC-4BAF-BCDB-73D74FD3A5C5} = {3862190B-E2C5-418E-AFDC-DB281FB5C705}
{5FDAF679-DE5A-4C73-A49B-8ABCF2399229} = {77C7929A-2EED-4AA6-8705-B5C443C8AA0F}
{7642798D-12D4-403A-BB92-B6BEF67C9D4F} = {E359BB2B-9AEC-497D-B321-7DF2450C3B8E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
Expand Down
2 changes: 1 addition & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<MicrosoftNETFrameworkReferenceAssembliesPkgVer>[1.0.0,2.0)</MicrosoftNETFrameworkReferenceAssembliesPkgVer>
<MicrosoftSourceLinkGitHubPkgVer>[1.0.0,2.0)</MicrosoftSourceLinkGitHubPkgVer>
<OpenTracingPkgVer>[0.12.1,0.13)</OpenTracingPkgVer>
<OTelPreviousStableVer>1.3.0</OTelPreviousStableVer>
<OTelPreviousStableVer>1.3.1</OTelPreviousStableVer>
<SerilogPkgVer>[2.8.0,3.0)</SerilogPkgVer>
<StyleCopAnalyzersPkgVer>[1.2.0-beta.435,2.0)</StyleCopAnalyzersPkgVer>
<SystemCollectionsImmutablePkgVer>1.4.0</SystemCollectionsImmutablePkgVer>
Expand Down
5 changes: 1 addition & 4 deletions docs/logs/correlation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public static void Main()
// Setup Logging
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.AddConsoleExporter();
});
builder.AddOpenTelemetry().AddConsoleExporter();
});

var logger = loggerFactory.CreateLogger<Program>();
Expand Down
10 changes: 4 additions & 6 deletions docs/logs/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ public static void Main()
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.ConfigureResource(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0"));
options.AddConsoleExporter();
});
builder
.AddOpenTelemetry(options => options.IncludeScopes = true)
.ConfigureResource(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0"))
.AddConsoleExporter();
});

var logger = loggerFactory.CreateLogger<Program>();
Expand Down
8 changes: 4 additions & 4 deletions docs/logs/extending-the-sdk/LoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

internal static class LoggerExtensions
{
public static OpenTelemetryLoggerOptions AddMyExporter(this OpenTelemetryLoggerOptions options)
public static LoggerProviderBuilder AddMyExporter(this LoggerProviderBuilder builder)
{
if (options == null)
if (builder == null)
{
throw new ArgumentNullException(nameof(options));
throw new ArgumentNullException(nameof(builder));
}

return options.AddProcessor(new BatchLogRecordExportProcessor(new MyExporter()));
return builder.AddProcessor(new BatchLogRecordExportProcessor(new MyExporter()));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MyClassWithRedactionEnumerator.cs" company="OpenTelemetry Authors">
// <copyright file="MyRedactedAttributeList.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,32 +17,38 @@
using System.Collections;
using System.Collections.Generic;

internal class MyClassWithRedactionEnumerator : IReadOnlyList<KeyValuePair<string, object>>
internal class MyRedactedAttributeList : IReadOnlyList<KeyValuePair<string, object>>
{
private readonly IReadOnlyList<KeyValuePair<string, object>> state;
private readonly IReadOnlyList<KeyValuePair<string, object>> attributes;

public MyClassWithRedactionEnumerator(IReadOnlyList<KeyValuePair<string, object>> state)
public MyRedactedAttributeList(IReadOnlyList<KeyValuePair<string, object>> attributes)
{
this.state = state;
this.attributes = attributes;
}

public int Count => this.state.Count;
public int Count => this.attributes.Count;

public KeyValuePair<string, object> this[int index] => this.state[index];

public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
public KeyValuePair<string, object> this[int index]
{
foreach (var entry in this.state)
get
{
var entryVal = entry.Value;
var item = this.attributes[index];

var entryVal = item.Value;
if (entryVal != null && entryVal.ToString() != null && entryVal.ToString().Contains("<secret>"))
{
yield return new KeyValuePair<string, object>(entry.Key, "newRedactedValueHere");
}
else
{
yield return entry;
return new KeyValuePair<string, object>(item.Key, "newRedactedValueHere");
}

return item;
}
}

public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
for (var i = 0; i < this.Count; i++)
{
yield return this[i];
}
}

Expand Down
5 changes: 2 additions & 3 deletions docs/logs/extending-the-sdk/MyRedactionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
// limitations under the License.
// </copyright>

using System.Collections.Generic;
using OpenTelemetry;
using OpenTelemetry.Logs;

internal class MyRedactionProcessor : BaseProcessor<LogRecord>
{
public override void OnEnd(LogRecord logRecord)
{
if (logRecord.State is IReadOnlyList<KeyValuePair<string, object>> listOfKvp)
if (logRecord.Attributes != null)
{
logRecord.State = new MyClassWithRedactionEnumerator(listOfKvp);
logRecord.Attributes = new MyRedactedAttributeList(logRecord.Attributes);
}
}
}
18 changes: 8 additions & 10 deletions docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Logs;

namespace ExtendingTheSdk;

public class Program
{
public static void Main()
{
using var loggerFactory = LoggerFactory.Create(builder =>
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.AddProcessor(new MyRedactionProcessor())
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleLogRecordExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter();
}));
using var loggerFactory = LoggerFactory.Create(builder => builder
.AddOpenTelemetry(options => options.IncludeScopes = true)
.AddProcessor(new MyRedactionProcessor())
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleLogRecordExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter());

var logger = loggerFactory.CreateLogger<Program>();

Expand Down
5 changes: 1 addition & 4 deletions docs/logs/getting-started/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public static void Main()
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.AddConsoleExporter();
});
builder.AddOpenTelemetry().AddConsoleExporter();
});

var logger = loggerFactory.CreateLogger<Program>();
Expand Down
Loading