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

[OpenTelemetry.Extensions] Add baggage Activity processor #1659

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
76226d5
feat: Add baggage span processor
MikeGoldsmith Apr 18, 2024
7a18c03
add changelog
MikeGoldsmith Apr 18, 2024
931e8a2
fix line endings, replace invalid icon
MikeGoldsmith Apr 18, 2024
11f4a3d
remove invalid icon from readme
MikeGoldsmith Apr 18, 2024
e2c8403
tweak readme line lengths
MikeGoldsmith Apr 18, 2024
64cd3bf
Merge branch 'main' into mike/baggage-span-processor
MikeGoldsmith Apr 18, 2024
9bfd757
move baggage processor to extensions project
MikeGoldsmith Apr 22, 2024
1be86f1
remove old project files
MikeGoldsmith Apr 22, 2024
8720ad4
revert sln changes
MikeGoldsmith Apr 22, 2024
b67ed25
update comonent owners
MikeGoldsmith Apr 22, 2024
1b0fdd6
update namespace
MikeGoldsmith Apr 22, 2024
51d1d0e
make class internal
MikeGoldsmith Apr 22, 2024
8b6c1e2
add tracer provider builder extension method
MikeGoldsmith Apr 22, 2024
1dfd06d
add example to readme
MikeGoldsmith Apr 22, 2024
4907fad
update api signature
MikeGoldsmith Apr 22, 2024
1727eca
Merge branch 'main' into mike/baggage-span-processor
MikeGoldsmith Apr 22, 2024
c3fb1c3
add changelog entry
MikeGoldsmith Apr 22, 2024
3ab5483
Merge branch 'mike/baggage-span-processor' of github.com:honeycombio/…
MikeGoldsmith Apr 22, 2024
f757947
fix file encoding
MikeGoldsmith Apr 22, 2024
efaea35
Merge branch 'main' into mike/baggage-span-processor
MikeGoldsmith Apr 23, 2024
8c5847d
rename to baggage activity processor
MikeGoldsmith Apr 24, 2024
e12824a
clean up after rename
MikeGoldsmith Apr 24, 2024
e4238c5
update example to show just the activity processor
MikeGoldsmith Apr 24, 2024
bc927a0
Apply suggestions from code review
MikeGoldsmith Apr 24, 2024
61edd97
update component owners for test project too
MikeGoldsmith Apr 24, 2024
ccf54ae
update readme to make trace context headers less specific
MikeGoldsmith Apr 24, 2024
8f9f235
Merge branch 'mike/baggage-span-processor' of github.com:honeycombio/…
MikeGoldsmith Apr 24, 2024
98eb76b
Update readme example text
MikeGoldsmith Apr 24, 2024
2a4852b
use guard to check for null builder
MikeGoldsmith Apr 24, 2024
85fd0e1
Merge branch 'main' into mike/baggage-span-processor
MikeGoldsmith Apr 25, 2024
15ca843
remove warning from readme
MikeGoldsmith Apr 25, 2024
8f5700c
tweak readme text
MikeGoldsmith Apr 25, 2024
6836c4f
Merge branch 'mike/baggage-span-processor' of github.com:honeycombio/…
MikeGoldsmith Apr 25, 2024
9e33de2
fix readme text
MikeGoldsmith Apr 25, 2024
d98d5a7
Merge branch 'main' into mike/baggage-span-processor
MikeGoldsmith Apr 26, 2024
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: 2 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ components:
- srprash
- atshaw43
- ppittle
OpenTelemetry.SpanProcessor.Baggage:
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
- mikegoldsmith
test/OpenTelemetry.Exporter.Geneva.Benchmark/:
- cijothomas
- codeblanch
Expand Down
9 changes: 8 additions & 1 deletion opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 15.0.26124.0
Expand Down Expand Up @@ -344,6 +344,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetec
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.SpanProcessor.Baggage", "src\OpenTelemetry.SpanProcessor.Baggage\OpenTelemetry.SpanProcessor.Baggage.csproj", "{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -690,6 +692,10 @@ Global
{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Release|Any CPU.Build.0 = Release|Any CPU
{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -793,6 +799,7 @@ Global
{033CA8D4-1529-413A-B244-07958D5F9A48} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{36271347-2055-438E-9659-B71542A17A73} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{7AD707F9-DC6D-430A-8834-D5DCD517BF6E} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{04150AB0-2FFF-479E-BBEA-E8F2A3B798F2} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66}
Expand Down
23 changes: 23 additions & 0 deletions src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry;

Check warning on line 4 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Using directive is unnecessary.
using System.Collections.Generic;
using System.Diagnostics;

namespace OpenTelemetry.SpanProcessor.Baggage;
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Span processor that adds <see cref="Baggage"/> fields to every new span

Check warning on line 11 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Documentation text should end with a period
/// </summary>
public class BaggageSpanProcessor : OpenTelemetry.<Activity>

Check warning on line 13 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Symbol 'BaggageSpanProcessor' is not part of the declared public API

Check warning on line 13 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Symbol 'implicit constructor for 'BaggageSpanProcessor'' is not part of the declared public API
MikeGoldsmith marked this conversation as resolved.
Show resolved Hide resolved
{
/// <inheritdoc />
public override void OnStart(Activity activity)

Check warning on line 16 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Symbol 'OnStart' is not part of the declared public API

Check warning on line 16 in src/OpenTelemetry.SpanProcessor.Baggage/BaggageSpanProcessor.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

PublicAPI.txt is missing '#nullable enable', so the nullability annotations of API isn't recorded. It is recommended to enable this tracking.
{
foreach (var entry in Baggage.Current)
{
activity.SetTag(entry.Key, entry.Value);
}
}
}
6 changes: 6 additions & 0 deletions src/OpenTelemetry.SpanProcessor.Baggage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## Unreleased

* Adds Baggage span processor.
([#](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1659))
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>OpenTelemetry baggage span processor</Description>
<PackageTags>$(PackageTags);Baggage</PackageTags>
<MinVerTagPrefix>SpanProcessor.Baggage-</MinVerTagPrefix>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry" Version="$(OTelSdkVersion)" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\AssemblyVersionExtensions.cs" Link="Includes\AssemblyVersionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.SpanProcessor.Baggage", "OpenTelemetry.SpanProcessor.Baggage.csproj", "{6048EBF2-EF94-4988-BC6A-073EFF43B18F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6048EBF2-EF94-4988-BC6A-073EFF43B18F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6048EBF2-EF94-4988-BC6A-073EFF43B18F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6048EBF2-EF94-4988-BC6A-073EFF43B18F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6048EBF2-EF94-4988-BC6A-073EFF43B18F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F0DF08BE-C2DC-4921-98E9-E1AA5A796C91}
EndGlobalSection
EndGlobal
42 changes: 42 additions & 0 deletions src/OpenTelemetry.SpanProcessor.Baggage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Instana Exporter for OpenTelemetry .NET

[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.SpanProcessor.Baggage)](https://www.nuget.org/packages/OpenTelemetry.SpanProcessor.Baggage)
[![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.SpanProcessor.Baggage)](https://www.nuget.org/packages/OpenTelemetry.SpanProcessor.Baggage)

The BaggageSpanProcessor reads entries stored in Baggage from the parent context
and adds the baggage keys and values to the activity as attributes on start.

Add this span processor to a tracer provider.

Warning!

Do not put sensitive information in Baggage.

To repeat: a consequence of adding data to Baggage is that the keys and values
will appear in all outgoing HTTP headers from the application.

## Installation

```shell
dotnet add package OpenTelemetry.SpanProcessor.Baggage
```

### Configure Processor with Trace Provider

This snippet shows how to configure the Instana Exporter for Traces

```csharp
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("DemoSource")
.AddProcessor(new BaggageSpanProcessor())
.Build();
```

The above code must be in application startup. In case of ASP.NET Core
applications, this should be in `ConfigureServices` of `Startup` class.
For ASP.NET applications, this should be in `Global.aspx.cs`.

## Troubleshooting

Before digging into a problem, check if you hit a known issue by looking at the
[GitHub issues](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues).
Loading