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: RehanSaeed/Serilog.Enrichers.Span
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.2.0
Choose a base ref
...
head repository: RehanSaeed/Serilog.Enrichers.Span
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.3.0
Choose a head ref

Commits on Apr 21, 2021

  1. Add renovate.json

    renovate-bot authored and RehanSaeed committed Apr 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    dtzWill Will Dietz
    Copy the full SHA
    0a84972 View commit details
  2. Copy the full SHA
    0546e3f View commit details
  3. Bump Download Artifact v2

    RehanSaeed committed Apr 21, 2021
    Copy the full SHA
    aafb22b View commit details
  4. Add autolabeler

    RehanSaeed committed Apr 21, 2021
    Copy the full SHA
    69a01aa View commit details
  5. Copy the full SHA
    41f09ba View commit details

Commits on Apr 29, 2021

  1. Add Native Dependabot

    RehanSaeed committed Apr 29, 2021
    Copy the full SHA
    5b8b60c View commit details
  2. Copy the full SHA
    222de28 View commit details
  3. Copy the full SHA
    d898538 View commit details

Commits on May 12, 2021

  1. Update renovate.json

    RehanSaeed authored May 12, 2021
    Copy the full SHA
    85e4bf8 View commit details
  2. Bump actions/setup-dotnet from 1 to 1.8.0

    Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 1 to 1.8.0.
    - [Release notes](https://github.com/actions/setup-dotnet/releases)
    - [Commits](actions/setup-dotnet@v1...v1.8.0)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and RehanSaeed committed May 12, 2021
    Copy the full SHA
    cb61c9c View commit details
  3. Bump actions/checkout from 2 to 2.3.4

    Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 2.3.4.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v2...v2.3.4)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and RehanSaeed committed May 12, 2021
    Copy the full SHA
    7408b3d View commit details
  4. Copy the full SHA
    4d56968 View commit details
  5. Copy the full SHA
    c287891 View commit details

Commits on May 24, 2021

  1. Copy the full SHA
    cbd4317 View commit details

Commits on May 26, 2021

  1. Bump Microsoft.NET.Test.Sdk from 16.9.4 to 16.10.0

    Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.4 to 16.10.0.
    - [Release notes](https://github.com/microsoft/vstest/releases)
    - [Commits](microsoft/vstest@v16.9.4...v16.10.0)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and RehanSaeed committed May 26, 2021
    Copy the full SHA
    7912695 View commit details
  2. Update dependabot.yml

    RehanSaeed authored May 26, 2021
    Copy the full SHA
    bdb95f3 View commit details

Commits on May 28, 2021

  1. Copy the full SHA
    ebb674a View commit details

Commits on Jun 9, 2021

  1. Copy the full SHA
    0e08d29 View commit details
  2. Copy the full SHA
    c1a70b2 View commit details
  3. Copy the full SHA
    c0b7e45 View commit details

Commits on Jun 15, 2021

  1. Copy the full SHA
    dd05a13 View commit details

Commits on Jun 16, 2021

  1. Copy the full SHA
    459d60a View commit details

Commits on Jun 18, 2021

  1. Copy the full SHA
    d8e2fbd View commit details

Commits on Jun 28, 2021

  1. Copy the full SHA
    cf5bff8 View commit details

Commits on Jun 30, 2021

  1. Copy the full SHA
    58b7b10 View commit details

Commits on Jul 21, 2021

  1. Copy the full SHA
    8949312 View commit details

Commits on Aug 5, 2021

  1. Support AddTags

    심승용 authored and RehanSaeed committed Aug 5, 2021
    Copy the full SHA
    0559e6c View commit details
  2. Add Activity tag enricher

    Kahbazi authored and RehanSaeed committed Aug 5, 2021
    Copy the full SHA
    437e1b2 View commit details
24 changes: 0 additions & 24 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md

This file was deleted.

30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Bug Report"
description: "Create a report to help us improve"
labels: [bug]
body:
- type: textarea
id: describe-the-bug
attributes:
label: "Describe the bug"
description: "A clear and concise description of what the bug is."
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: "Steps to reproduce"
description: "A link to some code to reproduce the bug can speed up a fix. Alternatively, show steps to reproduce the behaviour."
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected-behaviour
attributes:
label: "Expected behaviour"
description: "A clear and concise description of what you expected to happen."
validations:
required: true
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md

This file was deleted.

11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Feature Request"
description: "Suggest an idea for this project"
labels: [enhancement]
body:
- type: textarea
id: describe-the-bug
attributes:
label: "Describe the feature"
description: "A clear and concise description of what the feature is."
validations:
required: true
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/supply-chain-security/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget"
directory: "/"
labels:
- "dependencies"
open-pull-requests-limit: 10
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
labels:
- "dependencies"
open-pull-requests-limit: 10
schedule:
interval: "daily"
15 changes: 15 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ tag-template: '$RESOLVED_VERSION'
change-template: '- $TITLE by @$AUTHOR (#$NUMBER)'
no-changes-template: '- No changes'
categories:
- title: '📚 Documentation'
labels:
- 'documentation'
- title: '🚀 New Features'
labels:
- 'enhancement'
@@ -35,3 +38,15 @@ template: |
## 👨🏼‍💻 Contributors
$CONTRIBUTORS
autolabeler:
- label: 'documentation'
files:
- '**/*.md'
- label: 'enhancement'
files:
- 'Source/**/*'
- label: 'maintenance'
files:
- '.github/**/*'
- 'Images/**/*'
- 'Tests/**/*'
19 changes: 9 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -29,15 +29,12 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: 'Checkout'
uses: actions/checkout@v2
uses: actions/checkout@v2.3.4
with:
lfs: true
fetch-depth: 0
- name: 'Git Fetch Tags'
run: git fetch --tags
shell: pwsh
- name: 'Install .NET Core SDK'
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v1.8.1
- name: 'Dotnet Tool Restore'
run: dotnet tool restore
shell: pwsh
@@ -51,7 +48,7 @@ jobs:
run: dotnet cake --target=Pack
shell: pwsh
- name: 'Publish Artefacts'
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v2.2.4
with:
name: ${{matrix.os}}
path: './Artefacts'
@@ -63,17 +60,19 @@ jobs:
environment:
name: 'GitHub Packages'
url: https://github.com/RehanSaeed/Serilog.Enrichers.Span/packages
permissions:
packages: write
runs-on: windows-latest
steps:
- name: 'Download Artefact'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: 'windows-latest'
- name: 'Dotnet NuGet Add Source'
run: dotnet nuget add source https://nuget.pkg.github.com/RehanSaeed/index.json --name GitHub --username RehanSaeed --password ${{secrets.GITHUB_TOKEN}}
shell: pwsh
- name: 'Dotnet NuGet Push'
run: dotnet nuget push .\windows-latest\*.nupkg --api-key ${{ github.token }} --source GitHub --skip-duplicate
run: dotnet nuget push .\*.nupkg --api-key ${{ github.token }} --source GitHub --skip-duplicate
shell: pwsh

push-nuget:
@@ -86,12 +85,12 @@ jobs:
runs-on: windows-latest
steps:
- name: 'Download Artefact'
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: 'windows-latest'
- name: 'Dotnet NuGet Push'
run: |
Get-ChildItem .\windows-latest -Filter *.nupkg |
Get-ChildItem .\ -Filter *.nupkg |
Where-Object { !$_.Name.Contains('preview') } |
ForEach-Object { dotnet nuget push $_ --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} }
shell: pwsh
24 changes: 9 additions & 15 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -19,29 +19,23 @@ on:
jobs:
analyze:
name: Analyze
permissions:
actions: read
contents: read
security-events: write
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['csharp']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v2.3.4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
3 changes: 3 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ on:

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@
</PropertyGroup>

<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="16.9.60" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all" Version="16.10.56" />
<PackageReference Include="MinVer" PrivateAssets="all" Version="2.5.0" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" Version="1.2.0-beta.321" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="all" Version="1.2.0-beta.354" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Banner](Images/Banner.png)

[![NuGet Package](https://img.shields.io/nuget/v/Serilog.Enrichers.Span.svg)](https://www.nuget.org/packages/Serilog.Enrichers.Span/) [![Serilog.Enrichers.Span package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/3f8a2a7e-8124-4987-9c44-916dba83b9d6/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Enrichers.Span/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=3f8a2a7e-8124-4987-9c44-916dba83b9d6&preferRelease=true) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/RehanSaeedUK) [![Twitter Follow](https://img.shields.io/twitter/follow/rehansaeeduk.svg?style=social&label=Follow)](https://twitter.com/RehanSaeedUK)
[![Serilog.Enrichers.Span NuGet Package](https://img.shields.io/nuget/v/Serilog.Enrichers.Span.svg)](https://www.nuget.org/packages/Serilog.Enrichers.Span/) [![Serilog.Enrichers.Span package in serilog-exceptions feed in Azure Artifacts](https://feeds.dev.azure.com/serilog-exceptions/_apis/public/Packaging/Feeds/8479813c-da6b-4677-b40d-78df8725dc9c/Packages/3f8a2a7e-8124-4987-9c44-916dba83b9d6/Badge)](https://dev.azure.com/serilog-exceptions/Serilog.Enrichers.Span/_packaging?_a=package&feed=8479813c-da6b-4677-b40d-78df8725dc9c&package=3f8a2a7e-8124-4987-9c44-916dba83b9d6&preferRelease=true) [![Serilog.Enrichers.Span NuGet Package Downloads](https://img.shields.io/nuget/dt/Serilog.Enrichers.Span)](https://www.nuget.org/packages/Serilog.Enrichers.Span) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/RehanSaeedUK) [![Twitter Follow](https://img.shields.io/twitter/follow/rehansaeeduk.svg?style=social&label=Follow)](https://twitter.com/RehanSaeedUK)

Enrich Serilog log events with properties from open telemetry spans using .NET's [Activity](https://docs.microsoft.com/dotnet/api/system.diagnostics.activity) API.

9 changes: 4 additions & 5 deletions Serilog.Enrichers.Span.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
# Visual Studio Version 17
VisualStudioVersion = 17.0.31423.177
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{719809C2-A551-4C4A-9EFD-B10FB5E35BC0}"
ProjectSection(SolutionItems) = preProject
@@ -44,9 +44,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{26F71F
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Issue Templates", "Issue Templates", "{566DF0E2-1288-4083-9B55-4C8B69BB1432}"
ProjectSection(SolutionItems) = preProject
.github\ISSUE_TEMPLATE\BUG_REPORT.md = .github\ISSUE_TEMPLATE\BUG_REPORT.md
.github\ISSUE_TEMPLATE\FEATURE_REQUEST.md = .github\ISSUE_TEMPLATE\FEATURE_REQUEST.md
.github\ISSUE_TEMPLATE\QUESTION.md = .github\ISSUE_TEMPLATE\QUESTION.md
.github\ISSUE_TEMPLATE\BUG_REPORT.yml = .github\ISSUE_TEMPLATE\BUG_REPORT.yml
.github\ISSUE_TEMPLATE\FEATURE_REQUEST.yml = .github\ISSUE_TEMPLATE\FEATURE_REQUEST.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{0555C737-CE4B-4C78-87AB-6296E1E32D01}"
31 changes: 31 additions & 0 deletions Source/Serilog.Enrichers.Span/ActivityTagEnricher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Serilog.Enrichers.Span
{
using System.Diagnostics;
using System.Linq;
using Serilog.Core;
using Serilog.Events;

/// <summary>
/// A log event enricher which adds tags from the current <see cref="Activity"/>.
/// </summary>
public class ActivityTagEnricher : ILogEventEnricher
{
private const string ActivityTags = "Attributes";

/// <summary>
/// Enrich the log event.
/// </summary>
/// <param name="logEvent">The log event to enrich.</param>
/// <param name="propertyFactory">Factory for creating new properties to add to the event.</param>
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var activity = Activity.Current;

if (activity is not null)
{
var tags = activity.Tags.Select(tag => new LogEventProperty(tag.Key, new ScalarValue(tag.Value)));
logEvent.AddPropertyIfAbsent(new LogEventProperty(ActivityTags, new StructureValue(tags)));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -15,12 +15,31 @@ public static class LoggerEnrichmentConfigurationExtensions
/// <param name="loggerEnrichmentConfiguration">The enrichment configuration.</param>
/// <returns>Configuration object allowing method chaining.</returns>
public static LoggerConfiguration WithSpan(this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration)
=> loggerEnrichmentConfiguration.WithSpan(new SpanOptions());

/// <summary>
/// Enrich logger output with span information from the current <see cref="Activity"/>.
/// </summary>
/// <param name="loggerEnrichmentConfiguration">The enrichment configuration.</param>
/// <param name="spanOptions"><see cref="SpanOptions"/> to use for enriching Activity.</param>
/// <returns>Configuration object allowing method chaining.</returns>
public static LoggerConfiguration WithSpan(this LoggerEnrichmentConfiguration loggerEnrichmentConfiguration, SpanOptions spanOptions)
{
if (loggerEnrichmentConfiguration is null)
{
throw new ArgumentNullException(nameof(loggerEnrichmentConfiguration));
}

if (spanOptions is null)
{
throw new ArgumentNullException(nameof(spanOptions));
}

if (spanOptions.IncludeTags)
{
loggerEnrichmentConfiguration.With<ActivityTagEnricher>();
}

return loggerEnrichmentConfiguration.With<ActivityEnricher>();
}
}
13 changes: 13 additions & 0 deletions Source/Serilog.Enrichers.Span/SpanOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Serilog.Enrichers.Span
{
/// <summary>
/// Options.
/// </summary>
public class SpanOptions
{
/// <summary>
/// Gets or sets a value indicating whether to include tags in log or not. Default is false.
/// </summary>
public bool IncludeTags { get; set; }
}
}
7 changes: 4 additions & 3 deletions Tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -3,13 +3,14 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<ItemGroup Label="Package References">
<PackageReference Include="coverlet.collector" PrivateAssets="all" Version="3.0.3">
<PackageReference Include="coverlet.collector" PrivateAssets="All" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Microsoft.CodeCoverage" PrivateAssets="All" Version="16.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ Task("Test")
new DotNetCoreTestSettings()
{
Blame = true,
Collectors = new string[] { "XPlat Code Coverage" },
Collectors = new string[] { "Code Coverage", "XPlat Code Coverage" },
Configuration = configuration,
Loggers = new string[]
{
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"rollForward": "latestMajor",
"version": "5.0.201"
"version": "5.0.301"
}
}
8 changes: 8 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"config:base"
],
"labels": [
"dependencies"
]
}