Exposing PropertyFetcher as a public API from OpenTelemetry package#1232
Exposing PropertyFetcher as a public API from OpenTelemetry package#1232CodeBlanch merged 7 commits intoopen-telemetry:masterfrom eddynaka:feature/removing-duplicated-code
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 |
|
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" /> |
reyang
left a comment
There was a problem hiding this comment.
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! |
| namespace OpenTelemetry.Instrumentation | ||
| { | ||
| internal class PropertyFetcher | ||
| public class PropertyFetcher |
There was a problem hiding this comment.
nit: Should have XML comments now that it is public.
There was a problem hiding this comment.
added some. not sure if the best text...
| namespace OpenTelemetry.Instrumentation | ||
| { | ||
| internal class PropertyFetcher | ||
| public class PropertyFetcher |
There was a problem hiding this comment.
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.
@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.mdupdated for non-trivial changes