-
Notifications
You must be signed in to change notification settings - Fork 711
Improve docs structure #467
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
Improve docs structure #467
Conversation
This is a quite big commit improving documentation layout. It is an ongoing work and is far away of being ready to merge. This commit: - Moves the docs to a structure model - Moves examples into docs and includes basic_tracer as an example of what the final outcome could look like - Small details around
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.
Nice! Thanks for doing this.
I'd love to get this merged in so I can contribute what you've started. Have a few comments but nothing that is a blocker.
docs/conf.py
Outdated
if branch == None or branch == 'latest': | ||
branch = 'master' | ||
|
||
scm_raw_web = 'https://raw.githubusercontent.com/mauriciovasquezbernal/opentelemetry-python/' + branch |
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.
looks like these should be pointed at the main telemetry repo.
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.
Will update just before merging, otherwise I cannot see the results on my testing readthedocs instance.
docs/index.rst
Outdated
:caption: OpenTelemetry API: | ||
TODO: intro with link to opentelemetry.io | ||
|
||
Installation |
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.
FWIW, I wrote an index page that's similar, but has some wording changed to better reflect the fact that this is in a doc vs the repo itself. I'll post here and you can pull stuff in, or I can come in after and add parts I feel are valuable.
.. OpenTelemetry documentation master file, created by
sphinx-quickstart on Mon Jun 3 22:48:38 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
OpenTelemetry-Python
====================
The Python `OpenTelemetry <https://opentelemetry.io/>`_ client.
.. image:: https://img.shields.io/gitter/room/opentelemetry/opentelemetry-python
:target: https://gitter.im/open-telemetry/opentelemetry-python
:alt: Gitter Chat
This documentation describes the opentelemetry-api, opentelemetry-sdk,
and several integration packages.
**Please note** that this library is currently in alpha, and shouldn't be
used in production environments.
Installation
------------
The API and SDK packages are available on PyPI, and can installed via pip:
.. code-block:: bash
pip install opentelemetry-api
pip install opentelemetry-sdk
In addition, there are several extension packages which can be installed separately as::
pip install opentelemetry-ext-{integration}
The extension packages can be found in
`ext/ directory of the repository <https://github.com/open-telemetry/opentelemetry-python/tree/master/ext>`_.
In addition, third party exporters are available:
* `Azure Monitor <https://github.com/microsoft/opentelemetry-exporters-python/tree/master/azure_monitor>`_
Installing Cutting Edge Packages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While the project is pre-1.0, there may be significant functionality that
has not yet been released to PyPI. In that situation, you may want to
install the packages directly from the repo. This can be done by cloning the
repositry and doing an `editable
install <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_:
.. code-block:: bash
git clone https://github.com/open-telemetry/opentelemetry-python.git
cd opentelemetry-python
pip install -e ./opentelemetry-api
pip install -e ./opentelemetry-sdk
pip install -e ./ext/opentelemetry-ext-{integration}
Quick Start
-----------
opentelemetry can be used to emit distributed traces and metrics from your application.
The following are examples using the API and SDK:
Tracing
~~~~~~~
.. code-block:: python
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
trace.set_preferred_tracer_provider_implementation(lambda T: TracerProvider())
trace.tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span('foo'):
with tracer.start_as_current_span('bar'):
with tracer.start_as_current_span('baz'):
print("Hello world from OpenTelemetry Python!")
Metrics
~~~~~~~
.. code-block:: python
from opentelemetry import metrics
from opentelemetry.sdk.metrics import Counter, MeterProvider
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter
from opentelemetry.sdk.metrics.export.controller import PushController
metrics.set_preferred_meter_provider_implementation(lambda _: MeterProvider())
meter = metrics.get_meter(__name__)
exporter = ConsoleMetricsExporter()
controller = PushController(meter, exporter, 5)
counter = meter.create_metric(
"available memory",
"available memory",
"bytes",
int,
Counter,
("environment",),
)
label_values = ("staging",)
counter_handle = counter.get_handle(label_values)
counter_handle.add(100)
More examples are available in the `examples folder <https://github.com/open-telemetry/opentelemetry-python/tree/master/examples>`_.
.. toctree::
:maxdepth: 1
:caption: OpenTelemetry API:
opentelemetry.context
opentelemetry.metrics
opentelemetry.trace
opentelemetry.util.loader
.. toctree::
:maxdepth: 1
:caption: OpenTelemetry SDK:
opentelemetry.sdk.context
opentelemetry.sdk.metrics
opentelemetry.sdk.trace
.. toctree::
:maxdepth: 1
:caption: OpenTelemetry Integrations:
opentelemetry.ext.flask
opentelemetry.ext.http_requests
opentelemetry.ext.jaeger
opentelemetry.ext.opentracing_shim
opentelemetry.ext.pymongo
opentelemetry.ext.wsgi
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
empty_attributes = BoundedDict(MAX_NUM_ATTRIBUTES) | ||
empty_events = BoundedList(MAX_NUM_EVENTS) | ||
empty_links = BoundedList(MAX_NUM_LINKS) | ||
_empty_attributes = BoundedDict(MAX_NUM_ATTRIBUTES) |
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.
was this to help the autodocumentation work better?
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.
Yes, it was just a detail I found. Without the underscore those identifiers are added to the documentation, I don't see any reason to have them there.
- add missing ext packages - use glob where possible to avoid manually adding entries - update main document with Yusuke's recommendations - comment out TODOs Probably other changes I don't remember now
I updated the PR to fix the tests (I had to disable the warning as errors in tox docs) I also added documentation for external packages. The readme of each package is included + the autodoc documentation. I think it's just a temporal solution, I think the best approach is:
I don't want to add more things to this PR right now, we can improve this in follow up 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.
Very nice improvement, I think this is the right direction for the docs.
It is a bit weird that the example code is now buried in docs, instead of docs containing only documentation, but I don't have a strong opinion between this and a top-level examples/
dir.
Tracing | ||
~~~~~~~ | ||
|
||
.. literalinclude:: trace_example.py |
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.
Good call, transclusion here really helps to clean up the docs.
@@ -106,3 +108,27 @@ | |||
# relative to this directory. They are copied after the builtin static files, | |||
# so a file named "default.css" will overwrite the builtin "default.css". | |||
html_static_path = [] | |||
|
|||
# Support external links to specific versions of the files in the Github repo | |||
branch = os.environ.get("READTHEDOCS_VERSION") |
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.
Nice!
Co-Authored-By: Chris Kleinknecht <[email protected]>
Co-Authored-By: Chris Kleinknecht <[email protected]>
Co-Authored-By: Chris Kleinknecht <[email protected]>
@mauriciovasquezbernal let me know when this is ready to merge. Thanks for all the improvements here! a huge win. |
@toumorokoshi it's ready to go. It's far from perfect but we can work to improve it later on. |
I'm opening this PR as a Request For Comments to understand if it makes sense to continue with this approach to improve documentation or not.
The problems I'm trying to solve are:
This PR:
scm_web
&scm_raw_web
.The result documentation can be accessed at https://opentelemetry-python-mauricio.readthedocs.io/en/improve-docsv1/index.html, the only updated example is available at https://opentelemetry-python-mauricio.readthedocs.io/en/improve-docsv1/examples/basic_tracer/README.html. (notice that it includes a link to the example source that is dynamic according to the version).
Please let me know your feedback, I'll happy to continue working on this if you think the result it worthy.