-
Notifications
You must be signed in to change notification settings - Fork 793
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
Support for SamplerDetectors and EnvVarSamplerDetector #3635
Changes from 8 commits
0eece8d
59c2f58
478f47c
2ec77cf
dfccced
5649c04
973f289
0e27822
fb11564
7a4caac
58ebd50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// <copyright file="MySamplerDetector.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 OpenTelemetry.Trace; | ||
|
||
internal class MySamplerDetector : ISamplerDetector | ||
{ | ||
public Sampler Detect() | ||
{ | ||
return new MySampler(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ public static void Main() | |
{ | ||
using var tracerProvider = Sdk.CreateTracerProviderBuilder() | ||
.AddSource("MyCompany.MyProduct.MyLibrary") | ||
.SetSampler(new AlwaysOnSampler()) | ||
.ConfigureSampler(x => x.SetDefaultSampler(new AlwaysOnSampler())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be .ConfigureSampler(x => x.Clear().SetDefaultSampler(new AlwaysOnSampler())) Can you elaborate on why you suggest using the "builder API" instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fb11564. New API provide broader functionalities so it should be used in all examples in the repository. |
||
.SetErrorStatusOnException() | ||
.AddConsoleExporter() | ||
.Build(); | ||
|
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.
mm.. I am not sure of the need of such a new api. Can we simply modify SDK to automatically pick Sampler from Env Variables?
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 see some benefits for having builder with detectors:
XRayOTelEnvVarSamplerDetector
. With current design it could be chained with current CommonEnvVar Detector.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.
There are issues with the existing environment variable stuff. Primarily, it doesn't work with IConfiguration/IOptions. This is something I am looking at, hoping to find a new pattern that smooths all of this out. Probably first to drive #3583. I would vote to wait on this sorry @Kielek I know that is probably frustrating!
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.
If we speaking about timeframe, it will be great to include it at least based env. var. support for 1.4.0 release. We would like to give AutoInstrumentation users some flexibility here.
I know that we will need more thing configurable in the future so I will observe issue you have mentioned.