-
Notifications
You must be signed in to change notification settings - Fork 765
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
Refactor TracerProvider to make configuration easy. #1027
Refactor TracerProvider to make configuration easy. #1027
Conversation
@@ -102,18 +101,6 @@ internal static object Run(ConsoleOptions options) | |||
|
|||
internal class MyProcessor : ActivityProcessor | |||
{ |
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.
Writing own Processor is also greatly simplified now. No need of worrying about "next".
ActivityProcessor = this.ActivityProcessor, | ||
}; | ||
|
||
var activitySource = new ActivitySourceAdapter(provider.Sampler, provider.ActivityProcessor, provider.Resource); |
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.
activitysourceadapter won't fech ActiivtyProcessors added after building the provider. its a TODO on my list.
new string[] | ||
{ | ||
"MyCompany.MyProduct.MyLibrary", | ||
}) | ||
.AddMyExporter(); | ||
.Build().AddMyExporter(); |
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.
I know you can add exporter after build, but hey 😺
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.
Yes, for builder, it makes more sense to add everything before Build()
.
@@ -24,12 +24,13 @@ public class Program | |||
|
|||
public static void Main() | |||
{ | |||
using var tracerProvider = Sdk.CreateTracerProvider( | |||
using var tracerProvider = Sdk.CreateTracerProviderBuilder() | |||
.AddActivitySources( |
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.
Trying to get more ideas - which one is more idiomatic? - AddActivitySource
overload (singular form) or AddActivitySources
(plural form).
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.
Should people know that what we did so far is based on Activity? What if in the future it changes to something else? Should we remove the name Activity from it?
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.
I feel like singular but with an overload for plural?
void Add[Activity]Source(this TraceProviderBuilder builder, string sourceName);
void Add[Activity]Source(this TraceProviderBuilder builder, params string[] sourceNames);
Codecov Report
@@ Coverage Diff @@
## master #1027 +/- ##
==========================================
+ Coverage 75.53% 77.03% +1.50%
==========================================
Files 221 221
Lines 6208 6166 -42
==========================================
+ Hits 4689 4750 +61
+ Misses 1519 1416 -103
|
new MySampler()) | ||
.AddProcessor(new SimpleActivityProcessor(new ConsoleExporter(new ConsoleExporterOptions()))); | ||
}) | ||
.SetSampler(new MySampler()) |
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.
"SetSampler" not "UseSampler"?
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.
LGTM
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.
LGTM .
// and use a custom MyProcessor, along with Console exporter. | ||
using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddActivitySource("MyCompany.MyProduct.MyWebServer") | ||
.SetResource(Resources.CreateServiceResource("MyServiceName")) | ||
.AddProcessor(new MyProcessor()) // This must be added before ConsoleExporter |
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.
What happens if it isn't added before ConsoleExporter?
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.
Any enrichments done by MyProcessor will not be visible to ConsoleExporter. Spec says processors are called in order they are added.
Major refactoring in TracerProvider creation, incorporating feedback from #1008, #1008 (comment), and offline feedbacks.
The examples are modified to show the new usage.
Note: This is fairly big change affecting 50 files so want to submit separate PRs for major feedbacks.
For significant contributions please make sure you have completed the following items: