-
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
Exposing PropertyFetcher as a public API from OpenTelemetry package #1232
Exposing PropertyFetcher as a public API from OpenTelemetry package #1232
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1232 +/- ##
==========================================
- Coverage 78.93% 78.89% -0.05%
==========================================
Files 219 215 -4
Lines 6347 6259 -88
==========================================
- Hits 5010 4938 -72
+ Misses 1337 1321 -16
|
Add this to SDK changelog as a new adition to public API |
Just added |
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
I understand that we want to reduce duplicated code. For example, we already have these shared files: <Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\ExceptionExtensions.cs" Link="Internal\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Trace\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\EnumerationHelper.cs" Link="Implementation\EnumerationHelper.cs" /> |
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'm concerned about exposing this as a public function.
We probably need to consider the file sharing approach.
Avoiding code duplication is not the main reason for this PR. This allows anyone to write a new Instrumentation for DiagnosticSource instrumented libraries. (We already have the basic classes for subscription public, propertyfetcher is also required to fully enable on to write a instrumentation library)) |
Should i move or should I maintain ? |
Please wait to hear Reiley's thoughts after I made clarification above about the intent of this PR. The following class, along with propertyfetcher is public - so that anyone can write their own instrumentation for DiagnosticSource instrumented libraries. |
I'm fine with exposing a public API if the pros > cons. |
just updated the title! |
{ | ||
internal class PropertyFetcher | ||
public class PropertyFetcher |
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.
nit: Should have XML comments now that it is public.
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.
added some. not sure if the best text...
{ | ||
internal class PropertyFetcher | ||
public class PropertyFetcher |
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 think we could improve this API. Internally it has a very nice, typed delegate created. But we only expose object Fetch(object)
which basically throws away that typing information and will box any value types + require a cast. With a little work we could probably also expose:
class PropertyFetcher<TType, TPropertyType> : PropertyFetcher
{
public TPropertyType Fetch(TType instance)
}
That would be useful when you know the types ahead of time, which is actually the more common case. It would allow us to avoid some of those performance penalties.
Let's merge this and then we can try to improve 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.
sounds great :)
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.
@CodeBlanch not sure how it was done originally, but inside the same class, we already have a typedPropertyFetcher. but, in the end, we are just returning as an object.
…/eddynaka/opentelemetry-dotnet into feature/removing-duplicated-code
Fixes #1231.
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes