-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for sphinx as a documentation generator (#595)
- Loading branch information
Showing
13 changed files
with
333 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile clean | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
mkdir -p doxyoutput | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
clean: | ||
rm -rf doxyoutput | ||
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'OpenTelemetry C++ API' | ||
copyright = '2021, OpenTelemetry authors' | ||
author = 'OpenTelemetry authors' | ||
|
||
# Run doxygen | ||
# ----------- | ||
# For the readthedocs builds, for some reason exhale doesn't find doxygen. | ||
# So we run it manually here. | ||
import subprocess | ||
import os | ||
if not os.path.isdir('doxyoutput'): | ||
os.mkdir('doxyoutput') | ||
subprocess.call(['doxygen']) | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"breathe", | ||
"exhale", | ||
] | ||
|
||
breathe_projects = { | ||
"OpenTelemetry C++ API": "./doxyoutput/xml" | ||
} | ||
|
||
breathe_default_project = "OpenTelemetry C++ API" | ||
|
||
exhale_args = { | ||
"containmentFolder": "otel_api", | ||
"rootFileName": "otel_api.rst", | ||
"rootFileTitle": "Reference documentation", | ||
"doxygenStripFromPath": "..", | ||
"exhaleUseDoxyfile": True, | ||
"createTreeView": True, | ||
} | ||
|
||
primary_domain = "cpp" | ||
|
||
higlight_language = "cpp" | ||
|
||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = "sphinx_rtd_theme" | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# 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 = ['_static'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OpenTelemetry C++ API | ||
===================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Getting help | ||
------------ | ||
|
||
- Refer to `opentelemetry.io <https://opentelemetry.io/>`__ for general | ||
information about OpenTelemetry. | ||
- Refer to the `OpenTelemetry C++ GitHub | ||
repository <https://github.com/open-telemetry/opentelemetry-cpp>`__ | ||
for further information and resources related to OpenTelemetry C++. | ||
- For questions related to OpenTelemetry C++ that are not covered by | ||
the existing documentation, please ask away in `GitHub | ||
discussions <https://github.com/open-telemetry/opentelemetry-cpp/discussions>`__. | ||
- Feel free to join the `CNCF OpenTelemetry C++ Slack | ||
channel <https://cloud-native.slack.com/archives/C01N3AT62SJ>`__. If | ||
you are new, you can create a CNCF Slack account | ||
`here <http://slack.cncf.io/>`__. | ||
- For bugs and feature requests, write a `GitHub | ||
issue <https://github.com/open-telemetry/opentelemetry-cpp/issues>`__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Getting started | ||
--------------- | ||
|
||
Tracing | ||
~~~~~~~ | ||
|
||
When instrumenting libraries and applications, the most simple approach | ||
requires three steps. | ||
|
||
Obtain a tracer | ||
^^^^^^^^^^^^^^^ | ||
|
||
.. code:: cpp | ||
auto provider = opentelemetry::trace::Provider::GetTracerProvider(); | ||
auto tracer = provider->GetTracer("foo_library", "1.0.0"); | ||
The ``TracerProvider`` acquired in the first step is a singleton object | ||
that is usually provided by the OpenTelemetry C++ SDK. It is used to | ||
provide specific implementations for API interfaces. In case no SDK is | ||
used, the API provides a default no-op implementation of a | ||
``TracerProvider``. | ||
|
||
The ``Tracer`` acquired in the second step is needed to create and start | ||
``Span``\ s. | ||
|
||
Start a span | ||
^^^^^^^^^^^^ | ||
|
||
.. code:: cpp | ||
auto span = tracer->StartSpan("HandleRequest"); | ||
This creates a span, sets its name to ``"HandleRequest"``, and sets its | ||
start time to the current time. Refer to the API documentation for other | ||
operations that are available to enrich spans with additional data. | ||
|
||
Mark a span as active | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. code:: cpp | ||
auto scope = tracer->WithActiveSpan(span); | ||
This marks a span as active and returns a ``Scope`` object bound to the | ||
lifetime of the span. When the ``Scope`` object is destroyed, the | ||
related span is ended. | ||
|
||
The concept of an active span is important, as any span that is created | ||
without explicitly specifying a parent is parented to the currently | ||
active span. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile clean | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
clean: | ||
rm -rf doxyoutput | ||
@$(SPHINXBUILD) -M clean ../../api/docs "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Overview | ||
======== | ||
|
||
The OpenTelemetry C++ API enables developers to instrument their | ||
applications and libraries in order to make them ready to create and | ||
emit telemetry data. The OpenTelemetry C++ API exclusively focuses on | ||
instrumentation and does not address concerns like exporting, sampling, | ||
and aggregating telemetry data. Those concerns are addressed by the | ||
OpenTelemetry C++ SDK. This architecture enables developers to | ||
instrument applications and libraries with the OpenTelemetry C++ API | ||
while being completely agnostic of how telemetry data is exported and | ||
processed. | ||
|
||
Library design | ||
-------------- | ||
|
||
The OpenTelemetry C++ API is provided as a header-only library and | ||
supports all recent versions of the C++ standard, down to C++11. | ||
|
||
A single application might dynamically or statically link to different | ||
libraries that were compiled with different compilers, while several of | ||
the linked libraries are instrumented with OpenTelemetry. OpenTelemetry | ||
C++ supports those scenarios by providing a stable ABI. This is achieved | ||
by a careful API design, and most notably by providing ABI stable | ||
versions of classes from the standard library. All those classes are | ||
provided in the ``opentelemetry::nostd`` namespace. |
Oops, something went wrong.