Skip to content
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

Merged

Conversation

tigrannajaryan
Copy link
Member

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

@tigrannajaryan
Copy link
Member Author

specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved

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.
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

specification/library-guidelines.md Show resolved Hide resolved
@SergeyKanzhelev
Copy link
Member

CC: @mtwo for language clean up and suggestions on "glossary"

@tigrannajaryan
Copy link
Member Author

Reviewers, I pushed an update, please have another look.

Open questions:

  1. Are exporters part of SDK or they are separate packages and should be shown outside of SDK on the diagrams?
  2. Are we OK with 2 different ways of mocking possible?

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/libguide branch 2 times, most recently from c739f25 to eb955da Compare June 10, 2019 15:57
@tigrannajaryan
Copy link
Member Author

@SergeyKanzhelev do you have more comments or we can merge this?

Copy link
Member

@reyang reyang left a 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.
Copy link
Member

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.

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a 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!

@tigrannajaryan
Copy link
Member Author

@SergeyKanzhelev sounds good, we can keep improving it in new PRs.
Can you merge this? I don't have merging rights.

Copy link
Member

@mtwo mtwo left a 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

specification/library-guidelines.md Outdated Show resolved Hide resolved

Here is a proposed generic design for a language library:

![Language Library Design Diagram](language-library-design.png)
Copy link
Member

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)
Copy link
Member

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

specification/library-guidelines.md Outdated Show resolved Hide resolved
specification/library-guidelines.md Outdated Show resolved Hide resolved
These principles provide common ground for understanding what
are requirements for a language library API and provides guidelines
for language library authors.
@SergeyKanzhelev SergeyKanzhelev merged commit 9727633 into open-telemetry:master Jun 10, 2019
@tigrannajaryan tigrannajaryan deleted the feature/tigran/libguide branch June 11, 2019 18:47
SergeyKanzhelev pushed a commit to SergeyKanzhelev/opentelemetry-specification that referenced this pull request Feb 18, 2020
* 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
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 21, 2024
…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]>
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 23, 2024
…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]>
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants