-
Notifications
You must be signed in to change notification settings - Fork 890
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 Language Library Design Principles #84
Add Language Library Design Principles #84
Conversation
It is best to start reviewing using raw view so that you see the diagram: https://github.com/open-telemetry/opentelemetry-specification/blob/e77bb77b2d2e726c8785d0fb77efc6e7fe37d7d5/specification/library-guidelines.md |
specification/library-guidelines.md
Outdated
|
||
The alternate implementation may provide functionality that is identical to the official full SDK, but for example has better performance characteristics. This opens up the possibility of having competing and better implementations. | ||
|
||
Another common use case for alternate implementations is automated testing. A mock implementation can be plugged in during automated tests. For example it can store all generated telemetry data in memory and provide a capability to inspect this stored data. This will allow the tests to verify that the telemetry is generated correctly. Language Library authors are encouraged to provide such mock implementation. |
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.
we discussed that for mocking purposes it's better to use SDK with the mock exporter or processor. This way an actual logic will be tested. Should we encourage this use case at all?
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.
+1 to mock exporter with SDK, this is the model we used in OT. That said, I think it'll be incumbent on anyone doing a replacement implementation to provide their own mock.
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 thought about making the mock just another exporter but I think there are certain benefits for replacing the entire SDK with a mock implementation.
The SDK as we envision it may be too thick for simple mocking. Why do I need batching, tagging and all things that SDK does by default in a mock? When I use a mock in my automated tests I do not intend to verify how SDK does its job, I intend to verify if my instrumented code is calling telemetry API correctly. All I care about in the mock is to be able to inspect the results of telemetry calls.
The SDK's internal logic can be a detriment to my testing goals. For example if it batches and reorganizes telemetry data it may make inspection of data more difficult in the tests. This unneeded logic will also impose a small performance penalty on automated tests.
I think there are probably valid use cases for both approaches. The mocking by replacing only the exporter can be better suited for broader automated tests that are closer to integration tests or end-to-end tests.
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.
How much of an overhead do we really think there will be? I got my terms mixed up earlier - we provide a mock tracer in OT, rather than a mock exporter as there's no exporter concept there - but it seems like a mock exporter is going to be easier for third parties to implement. Moreover, it seems like it'd be valuable to be able to understand the performance overhead of the SDK on the application code.
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.
@austinlparker you are right that likely the performance overhead is going to be minimal. The unnecessary complication of tests may be non-trivial though.
Think about how you would test if the mock is a full SDK with a mock Exporter.
Your test executes a function that calls telemetry API. This in turn ends up in the SDK which decides to do batching and does NOT call the mock Exporter immediately. The SDK calls the mock Exporter after some timeout that is part of batching logic.
Now your test has to asynchronously wait for SDK batching logic timeout. This complicates the test, makes it potentially much slower and also makes it be aware of internal implementation details of the SDK, particularly that there is a batching logic with timeout.
I can envision other troubles as well. E.g. what if batching also reorders data for efficiency purposes? Now I need special logic in my test to find the telemetry data that I am looking for rather than be sure that the first data I see is what I need.
CC: @mtwo for language clean up and suggestions on "glossary" |
Reviewers, I pushed an update, please have another look. Open questions:
|
c739f25
to
eb955da
Compare
@SergeyKanzhelev do you have more comments or we can merge this? |
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.
|
||
SDK provides flexibility and extensibility that may be used by many implementations. Before developing an alternative implementation, please, review extensibility points provided by OpenTelemetry. | ||
|
||
An example use case for alternate implementations is automated testing. A mock implementation can be plugged in during automated tests. For example it can store all generated telemetry data in memory and provide a capability to inspect this stored data. This will allow the tests to verify that the telemetry is generated correctly. Language Library authors are encouraged to provide such mock implementation. |
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 liked the mention you had before about alternative data models. Like event-based, not span-based backends. Alternative Tracer would be most useful in such examples.
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 believe there is a room for improvements. For example, better explain what is expected from the box products that exposes telemetrey.
It is a very important document. And this is a solid staring point. Thank you!
@SergeyKanzhelev sounds good, we can keep improving it in new PRs. |
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 pending some minor comments
|
||
Here is a proposed generic design for a language library: | ||
|
||
![Language Library Design Diagram](language-library-design.png) |
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.
@SergeyKanzhelev how do we distinguish between "default" (context propagation) and "default" (full standard implementation)?
|
||
Here is a proposed generic design for a language library: | ||
|
||
![Language Library Design Diagram](language-library-design.png) |
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.
My understanding is that we'll include Zipkin, Jaeger, and Prometheus out of the box ... all others will need to be linked
These principles provide common ground for understanding what are requirements for a language library API and provides guidelines for language library authors.
0425665
to
61e3ac8
Compare
* Add Language Library Design Principles These principles provide common ground for understanding what are requirements for a language library API and provides guidelines for language library authors. * Fix based on PR comments
…Meter (open-telemetry#84) * Add InstrumentationLibrary to describe telemetry from a named Tracer/Meter Signed-off-by: Bogdan Cristian Drutu <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> Co-authored-by: Christian Neumüller <[email protected]>
…Meter (open-telemetry#84) * Add InstrumentationLibrary to describe telemetry from a named Tracer/Meter Signed-off-by: Bogdan Cristian Drutu <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> * Update text/0083-component.md Co-Authored-By: Christian Neumüller <[email protected]> Co-authored-by: Christian Neumüller <[email protected]>
* Add Language Library Design Principles These principles provide common ground for understanding what are requirements for a language library API and provides guidelines for language library authors. * Fix based on PR comments
These principles provide common ground for understanding what
are requirements for a language library API and provides guidelines
for language library authors.
This is co-authored by me and @bogdandrutu