Skip to content

Commit

Permalink
Add api documentation to the doc tree (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyanhui1228 authored Nov 29, 2017
1 parent 95bf4e0 commit 717fa49
Show file tree
Hide file tree
Showing 35 changed files with 172 additions and 452 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ python:
- '3.6'

install:
- pip install --upgrade sphinx
- pip install --upgrade nox-automation

script:
- ./scripts/update_docs.sh
- nox -s docs
- touch docs/.nojekyll

branches:
Expand Down
7 changes: 3 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_theme_options = {
'sidebar_width': '260px',
}

# 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,
Expand Down Expand Up @@ -173,6 +175,3 @@
author, 'OPENCENSUS', 'One line description of project.',
'Miscellaneous'),
]



6 changes: 6 additions & 0 deletions docs/trace/always_off_sampler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sampler - AlwaysOffSampler
==========================

.. automodule:: opencensus.trace.samplers.always_off
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/always_on_sampler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sampler - AlwaysOnSampler
=========================

.. automodule:: opencensus.trace.samplers.always_on
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/binary_format_propagation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Propagator - BinaryFormatPropagator
===================================

.. automodule:: opencensus.trace.propagation.binary_format
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/context_tracer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Context Tracer
==============

.. automodule:: opencensus.trace.tracer.context_tracer
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/execution_context.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Execution Context
=================

.. automodule:: opencensus.trace.execution_context
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/file_exporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Exporter - File Exporter
========================

.. automodule:: opencensus.trace.exporters.file_exporter
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/google_cloud_format_propagation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Propagator - GoogleCloudFormatPropagator
========================================

.. automodule:: opencensus.trace.propagation.google_cloud_format
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/logging_exporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Exporter - Logging Exporter
===========================

.. automodule:: opencensus.trace.exporters.logging_exporter
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/noop_tracer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Noop Tracer
===========

.. automodule:: opencensus.trace.tracer.noop_tracer
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/print_exporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Exporter - Print Exporter
=========================

.. automodule:: opencensus.trace.exporters.print_exporter
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/probability_sampler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sampler - ProbabilitySampler
============================

.. automodule:: opencensus.trace.samplers.probability
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/request_tracer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Request Tracer
==============

.. automodule:: opencensus.trace.request_tracer
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/span.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Span
====

.. automodule:: opencensus.trace.span
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/span_context.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Span Context
============

.. automodule:: opencensus.trace.span_context
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/stackdriver_exporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Exporter - Stackdriver Exporter
===============================

.. automodule:: opencensus.trace.exporters.stackdriver_exporter
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/text_format_propagation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Propagator - TextFormatPropagator
=================================

.. automodule:: opencensus.trace.propagation.text_format
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/trace_context_http_header_format_propagation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Propagator - TraceContextPropagator
===================================

.. automodule:: opencensus.trace.propagation.trace_context_http_header_format
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/trace/trace_options.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Trace Options
=============

.. automodule:: opencensus.trace.trace_options
:members:
:show-inheritance:
418 changes: 0 additions & 418 deletions docs/trace/usage.html

This file was deleted.

34 changes: 26 additions & 8 deletions docs/trace/usage.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
OpenCensus for Python - A stats collection and distributed tracing framework
============================================================================

`Census`_ for Python. Census provides a framework to measure a server's resource
usage and collect performance stats. This repository contains Python related
utilities and supporting software needed by Census.

.. _Census: https://github.com/census-instrumentation
OpenCensus Trace for Python
===========================

.. toctree::
:maxdepth: 2
:hidden:

span
span_context
request_tracer
execution_context
trace_options
always_on_sampler
always_off_sampler
probability_sampler
print_exporter
logging_exporter
stackdriver_exporter
zipkin_exporter
file_exporter
binary_format_propagation
google_cloud_format_propagation
text_format_propagation
trace_context_http_header_format_propagation
noop_tracer
context_tracer

Installation & basic usage
--------------------------
Expand Down
6 changes: 6 additions & 0 deletions docs/trace/zipkin_exporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Exporter - Zipkin Exporter
==========================

.. automodule:: opencensus.trace.exporters.zipkin_exporter
:members:
:show-inheritance:
1 change: 0 additions & 1 deletion scripts/update_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ set -ev
# Build docs
function build_docs {
rm -rf docs/build/
cp README.rst docs/trace/usage.rst
make html
return $?
}
Expand Down
2 changes: 1 addition & 1 deletion trace/opencensus/trace/exporters/file_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FileExporter(base.Exporter):
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
implement :meth`.Transport.export`. Defaults to
implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.BackgroundThreadTransport`.
"""
Expand Down
2 changes: 1 addition & 1 deletion trace/opencensus/trace/exporters/logging_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LoggingExporter(base.Exporter):
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
implement :meth`.Transport.export`. Defaults to
implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.BackgroundThreadTransport`.
Expand Down
2 changes: 1 addition & 1 deletion trace/opencensus/trace/exporters/print_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PrintExporter(base.Exporter):
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
implement :meth`.Transport.export`. Defaults to
implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.BackgroundThreadTransport`.
"""
Expand Down
2 changes: 1 addition & 1 deletion trace/opencensus/trace/exporters/stackdriver_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class StackdriverExporter(base.Exporter):
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
implement :meth`.Transport.export`. Defaults to
implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.BackgroundThreadTransport`.
"""
Expand Down
2 changes: 1 addition & 1 deletion trace/opencensus/trace/exporters/zipkin_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ZipkinExporter(base.Exporter):
:type transport: :class:`type`
:param transport: Class for creating new transport objects. It should
extend from the base :class:`.Transport` type and
implement :meth`.Transport.export`. Defaults to
implement :meth:`.Transport.export`. Defaults to
:class:`.SyncTransport`. The other option is
:class:`.BackgroundThreadTransport`.
"""
Expand Down
12 changes: 5 additions & 7 deletions trace/opencensus/trace/propagation/google_cloud_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""This file is for converting the trace header in google cloud format and
generate a SpanContext, or converting a SpanContext to a google cloud format
header. Later we will add implementation for supporting other format like
binary format and zipkin, opencensus format.
"""

import logging
import re

Expand All @@ -31,7 +25,11 @@


class GoogleCloudFormatPropagator(object):

"""This class is for converting the trace header in google cloud format
and generate a SpanContext, or converting a SpanContext to a google cloud
format header. Later we will add implementation for supporting other
format like binary format and zipkin, opencensus format.
"""
def from_header(self, header):
"""Generate a SpanContext object using the trace context header.
The value of enabled parsed from header is int. Need to convert to
Expand Down
10 changes: 4 additions & 6 deletions trace/opencensus/trace/propagation/text_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""This module provides the basic utilities for extracting the trace
information from a carrier which is a dict to form a SpanContext. And
generating a dict using the provided SpanContext.
"""

from opencensus.trace.span_context import SpanContext
from opencensus.trace.trace_options import TraceOptions

Expand All @@ -29,7 +24,10 @@


class TextFormatPropagator(object):

"""This class provides the basic utilities for extracting the trace
information from a carrier which is a dict to form a SpanContext. And
generating a dict using the provided SpanContext.
"""
def from_carrier(self, carrier):
"""Generate a SpanContext object using the information in the carrier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@


class TraceContextPropagator(object):
"""Propagator for processing the trace context HTTP header format."""

def from_header(self, header):
"""Generate a SpanContext object using the trace context header.
Expand Down
1 change: 1 addition & 0 deletions trace/opencensus/trace/samplers/always_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


class AlwaysOffSampler(Sampler):
"""Do not trace any requests."""

def should_sample(self, trace_id):
"""Always return False because we don't want to sample."""
Expand Down
3 changes: 2 additions & 1 deletion trace/opencensus/trace/samplers/always_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@


class AlwaysOnSampler(Sampler):
"""Trace every request."""

def should_sample(self, trace_id):
"""Always return True because we want to sampler all requests."""
"""Always return True because we want to sample all requests."""
return True
9 changes: 9 additions & 0 deletions trace/opencensus/trace/samplers/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def __init__(self, rate=None):
self.rate = rate

def should_sample(self, trace_id):
"""Make the sampling decision based on the lower 8 bytes of the trace
ID. If the value is less than the bound, return True, else False.
:type trace_id: str
:param trace_id: Trace ID of the current trace.
:rtype: bool
:returns: The sampling decision.
"""
lower_long = get_lower_long_from_trace_id(trace_id)
bound = self.rate * MAX_VALUE

Expand Down

0 comments on commit 717fa49

Please sign in to comment.