-
Notifications
You must be signed in to change notification settings - Fork 792
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
Add GlobalPropagators API and have instrumentation default to it #1428
Merged
cijothomas
merged 16 commits into
open-telemetry:master
from
cijothomas:cijothomas/globalpropagator1
Nov 3, 2020
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a2008c1
Add GlobalPropagators API and have instrumentation default to it
cijothomas 6aef3e8
Merge branch 'master' into cijothomas/globalpropagator1
cijothomas 7d4a097
changelog
cijothomas 655753a
fix name
cijothomas dd21bef
reset after
cijothomas df433be
min comment address
cijothomas 5d6989c
move id format to same place as context propagator
cijothomas d42da65
renam
cijothomas 51de2ae
renai
cijothomas 08a5c63
text initialize correctly
cijothomas 50036b6
Merge branch 'master' into cijothomas/globalpropagator1
cijothomas 9eaf4c7
Merge branch 'master' into cijothomas/globalpropagator1
cijothomas 9756c11
modify microsoervice example to pick global propagator
cijothomas 399c912
Merge branch 'master' into cijothomas/globalpropagator1
cijothomas b24435b
make Global propagator get only in api
cijothomas 445f40e
Add SetDefaultPropagato to SDK
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/OpenTelemetry.Api/Context/Propagation/NoopTextMapPropagator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// <copyright file="NoopTextMapPropagator.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; | ||
using System.Collections.Generic; | ||
|
||
namespace OpenTelemetry.Context.Propagation | ||
{ | ||
internal class NoopTextMapPropagator : TextMapPropagator | ||
{ | ||
private static readonly PropagationContext DefaultPropagationContext = default; | ||
|
||
public override ISet<string> Fields => null; | ||
|
||
public override PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter) | ||
{ | ||
return DefaultPropagationContext; | ||
} | ||
|
||
public override void Inject<T>(PropagationContext context, T carrier, Action<T, string, string> setter) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// <copyright file="Propagators.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> | ||
|
||
namespace OpenTelemetry.Context.Propagation | ||
{ | ||
/// <summary> | ||
/// Propagators allow setting the global default Propagators. | ||
/// </summary> | ||
public static class Propagators | ||
{ | ||
private static readonly TextMapPropagator Noop = new NoopTextMapPropagator(); | ||
|
||
/// <summary> | ||
/// Gets the Default TextMapPropagator to be used. | ||
/// </summary> | ||
/// <remarks> | ||
/// Setting this can be done only from Sdk. | ||
/// </remarks> | ||
public static TextMapPropagator DefaultTextMapPropagator { get; internal set; } = Noop; | ||
|
||
internal static void Reset() | ||
{ | ||
DefaultTextMapPropagator = Noop; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// <copyright file="PropagatorsTest.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; | ||
using OpenTelemetry.Context.Propagation; | ||
using OpenTelemetry.Context.Propagation.Tests; | ||
using Xunit; | ||
|
||
namespace OpenTelemetry.Context.Tests | ||
{ | ||
public class PropagatorsTest : IDisposable | ||
{ | ||
public PropagatorsTest() | ||
{ | ||
Propagators.Reset(); | ||
} | ||
|
||
[Fact] | ||
public void DefaultTextMapPropagatorIsNoop() | ||
{ | ||
Assert.IsType<NoopTextMapPropagator>(Propagators.DefaultTextMapPropagator); | ||
Assert.Same(Propagators.DefaultTextMapPropagator, Propagators.DefaultTextMapPropagator); | ||
} | ||
|
||
[Fact] | ||
public void CanSetPropagator() | ||
{ | ||
var testPropagator = new TestPropagator(string.Empty, string.Empty); | ||
Propagators.DefaultTextMapPropagator = testPropagator; | ||
Assert.Same(testPropagator, Propagators.DefaultTextMapPropagator); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Propagators.Reset(); | ||
} | ||
} | ||
} |
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for tests only.