Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 12 commits into from
Mar 10, 2020
Merged

Improve docs structure #467

merged 12 commits into from
Mar 10, 2020

Conversation

mauriciovasquezbernal
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal commented Mar 6, 2020

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:

  • Current documentation structure is quite plain, an index document with a lot of links to different modules.
  • There are not examples in the current online documentation.
  • It's difficult to keep aligned the examples with the latest released version, i.e, examples in main readme are not synchronized with packages versions on PyPI.

This PR:

  • Creates a tree structure for documentation, it allows to organize it better from a developer point of view and also the rendered documentation should be easier to navigate.
  • Moves partially the main readme to be included in the online docs, the main readme will be updated to have a link to avoid duplicated content)
  • Moves the examples folder to the docs, so they can be accessed through the online documentation.
  • Creates a new pair of "macros" to create links to specific versions. 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.

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
@mauriciovasquezbernal mauriciovasquezbernal added doc Documentation-related build & infra Issues related to build & infrastructure. labels Mar 6, 2020
Copy link
Member

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

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.

Copy link
Member Author

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

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

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?

Copy link
Member Author

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
@mauriciovasquezbernal mauriciovasquezbernal marked this pull request as ready for review March 7, 2020 02:34
@mauriciovasquezbernal mauriciovasquezbernal requested a review from a team March 7, 2020 02:34
@mauriciovasquezbernal mauriciovasquezbernal changed the title [RFC] Improve docs Improve docs structure Mar 9, 2020
@codecov-io
Copy link

codecov-io commented Mar 9, 2020

Codecov Report

Merging #467 into master will decrease coverage by 0.11%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #467      +/-   ##
==========================================
- Coverage   88.78%   88.66%   -0.12%     
==========================================
  Files          42       43       +1     
  Lines        2167     2206      +39     
  Branches      246      249       +3     
==========================================
+ Hits         1924     1956      +32     
- Misses        170      176       +6     
- Partials       73       74       +1
Impacted Files Coverage Δ
...app/src/opentelemetry_example_app/flask_example.py 100% <ø> (ø)
...emetry-sdk/src/opentelemetry/sdk/trace/__init__.py 92.06% <75%> (ø) ⬆️
...ry-ext-wsgi/src/opentelemetry/ext/wsgi/__init__.py 68.14% <0%> (-0.05%) ⬇️
...opentelemetry/sdk/context/propagation/b3_format.py 87.27% <0%> (ø) ⬆️
...pentelemetry/context/propagation/httptextformat.py
.../context/propagation/tracecontexthttptextformat.py
.../opentelemetry/context/propagation/binaryformat.py
.../src/opentelemetry/context/propagation/__init__.py
...pi/src/opentelemetry/trace/propagation/__init__.py 84.61% <0%> (ø)
.../opentelemetry/trace/propagation/httptextformat.py 100% <0%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 005575e...0d56707. Read the comment docs.

@mauriciovasquezbernal
Copy link
Member Author

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.

Copy link
Member

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

mauriciovasquezbernal and others added 3 commits March 9, 2020 14:13
Co-Authored-By: Chris Kleinknecht <[email protected]>
Co-Authored-By: Chris Kleinknecht <[email protected]>
@toumorokoshi
Copy link
Member

@mauriciovasquezbernal let me know when this is ready to merge. Thanks for all the improvements here! a huge win.

@mauriciovasquezbernal
Copy link
Member Author

@toumorokoshi it's ready to go. It's far from perfect but we can work to improve it later on.

@c24t c24t merged commit d5f3a7f into open-telemetry:master Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build & infra Issues related to build & infrastructure. doc Documentation-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants