Skip to content

Commit

Permalink
Span add override parameters
Browse files Browse the repository at this point in the history
for start_time and end_time

Make lint happy

Addressing comments

Addressing comments

Allowing 0 as start and end time

Fix lint issues

Metrics API RFC 0003 cont'd (open-telemetry#136)

* Create functions

Comments for Meter

More comments

Add more comments

Fix typos

* fix lint

* Fix lint

* fix typing

* Remove options, constructors, seperate labels

* Consistent naming for float and int

* Abstract time series

* Use ABC

* Fix typo

* Fix docs

* seperate measure classes

* Add examples

* fix lint

* Update to RFC 0003

* Add spancontext, measurebatch

* Fix docs

* Fix comments

* fix lint

* fix lint

* fix lint

* skip examples

* white space

* fix spacing

* fix imports

* fix imports

* LabelValues to str

* Black formatting

* fix isort

* Remove aggregation

* Fix names

* Remove aggregation from docs

* Fix lint

* metric changes

* Typing

* Fix lint

* Fix lint

* Add space

* Fix lint

* fix comments

* address comments

* fix comments

Adding a working propagator, adding to integrations and example (open-telemetry#137)

Adding a full, end-to-end example of propagation at work in the
example application, including a test.

Adding the use of propagators into the integrations.

Metrics API RFC 0009 (open-telemetry#140)

* Create functions

Comments for Meter

More comments

Add more comments

Fix typos

* fix lint

* Fix lint

* fix typing

* Remove options, constructors, seperate labels

* Consistent naming for float and int

* Abstract time series

* Use ABC

* Fix typo

* Fix docs

* seperate measure classes

* Add examples

* fix lint

* Update to RFC 0003

* Add spancontext, measurebatch

* Fix docs

* Fix comments

* fix lint

* fix lint

* fix lint

* skip examples

* white space

* fix spacing

* fix imports

* fix imports

* LabelValues to str

* Black formatting

* fix isort

* Remove aggregation

* Fix names

* Remove aggregation from docs

* Fix lint

* metric changes

* Typing

* Fix lint

* Fix lint

* Add space

* Fix lint

* fix comments

* handle, recordbatch

* docs

* Update recordbatch

* black

* Fix typo

* remove ValueType

* fix lint

Console exporter (open-telemetry#156)

Make use_span more flexible (closes open-telemetry#147). (open-telemetry#154)

Co-Authored-By: Reiley Yang <reyang@microsoft.com>
Co-Authored-By: Chris Kleinknecht <libc@google.com>

WSGI fixes (open-telemetry#148)

Fix http.url.
Don't delay calling wrapped app.

Skeleton for azure monitor exporters (open-telemetry#151)

Add link to docs to README (open-telemetry#170)

Move example app to the examples folder (open-telemetry#172)

WSGI: Fix port 80 always appended in http.host (open-telemetry#173)

Build and host docs via github action (open-telemetry#167)

Add missing license boilerplate to a few files (open-telemetry#176)

sdk/trace/exporters: add batch span processor exporter (open-telemetry#153)

The exporters specification states that two built-in span processors should be
implemented, the simple processor span and the batch processor span.

This commit implements the latter, it is mainly based on the opentelemetry/java
one.

The algorithm implements the following logic:
- a condition variable is used to notify the worker thread in case the queue
is half full, so that exporting can start before the queue gets full and spans
are dropped.
- export is called each schedule_delay_millis if there is a least one new span
to export.
- when the processor is shutdown all remaining spans are exported.

Implementing W3C TraceContext (fixes open-telemetry#116) (open-telemetry#180)

* Implementing TraceContext (fixes open-telemetry#116)

This introduces a w3c TraceContext propagator, primarily inspired by opencensus.

fix time conversion bug (open-telemetry#182)

Introduce Context.suppress_instrumentation (open-telemetry#181)

Metrics Implementation (open-telemetry#160)

* Create functions

Comments for Meter

More comments

Add more comments

Fix typos

* fix lint

* Fix lint

* fix typing

* Remove options, constructors, seperate labels

* Consistent naming for float and int

* Abstract time series

* Use ABC

* Fix typo

* Fix docs

* seperate measure classes

* Add examples

* fix lint

* Update to RFC 0003

* Add spancontext, measurebatch

* Fix docs

* Fix comments

* fix lint

* fix lint

* fix lint

* skip examples

* white space

* fix spacing

* fix imports

* fix imports

* LabelValues to str

* Black formatting

* fix isort

* Remove aggregation

* Fix names

* Remove aggregation from docs

* Fix lint

* metric changes

* Typing

* Fix lint

* Fix lint

* Add space

* Fix lint

* fix comments

* handle, recordbatch

* docs

* Update recordbatch

* black

* Fix typo

* remove ValueType

* fix lint

* sdk

* metrics

* example

* counter

* Tests

* Address comments

* ADd tests

* Fix typing and examples

* black

* fix lint

* remove override

* Fix tests

* mypy

* fix lint

* fix type

* fix typing

* fix tests

* isort

* isort

* isort

* isort

* noop

* lint

* lint

* fix tuple typing

* fix type

* black

* address comments

* fix type

* fix lint

* remove imports

* default tests

* fix lint

* usse sequence

* remove ellipses

* remove ellipses

* black

* Fix typo

* fix example

* fix type

* fix type

* address comments

Implement Azure Monitor Exporter (open-telemetry#175)

Span add override parameters for start_time and end_time (open-telemetry#179)

CONTRIBUTING.md: Fix clone URL (open-telemetry#177)

Add B3 exporter to alpha release table (open-telemetry#164)

Update README for alpha release (open-telemetry#189)

Update Contributing.md doc (open-telemetry#194)

Add **simple** client/server examples (open-telemetry#191)

Remove unused dev-requirements.txt (open-telemetry#200)

The requirements are contained in tox.ini now.

Fx bug in BoundedList for Python 3.4 and add tests (open-telemetry#199)

* fix bug in BoundedList for python 3.4 and add tests

collections.deque.copy() was introduced in python 3.5, this commit changes
that by the deque constructor and adds some tests to BoundedList and BoundedDict
to avoid similar problems in the future.

Also, improve docstrings of BoundedList and BoundedDict classes

Move util.time_ns to API. (open-telemetry#205)

Add Jaeger exporter (open-telemetry#174)

This adds a Jeager exporter for OpenTelemetry.  This exporter is based
on https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-jaeger.

The exporter uses thrift and can be configured to send data to the agent and
also to a remote collector.

There is a long discussion going on about how to include generated files
in the repo, so for now just put them here.

Add code coverage

Revert latest commit

Fix some "errors" found by mypy. (open-telemetry#204)

Fix some errors found by mypy (split from open-telemetry#201).

Update README for new milestones (open-telemetry#218)

Refactor current span handling for newly created spans. (open-telemetry#198)

1. Make Tracer.start_span() simply create and start the Span,
   without setting it as the current instance.
2. Add an extra Tracer.start_as_current_span() to create the
   Span and set it as the current instance automatically.

Co-Authored-By: Chris Kleinknecht <libc@google.com>

Add set_status to Span (open-telemetry#213)

Initial commit

Initial version
  • Loading branch information
hectorhdzg committed Oct 21, 2019
1 parent dbb3be8 commit c432da3
Show file tree
Hide file tree
Showing 105 changed files with 7,843 additions and 731 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[flake8]
ignore = E501,W503,E203
exclude = .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/,ext/opentelemetry-ext-jaeger/build/*
23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Docs

on:
push:
branches:
- master

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- name: Build docs
run: |
pip install --upgrade tox
tox -e docs
- name: Publish to gh-pages
uses: JamesIves/github-pages-deploy-action@2.0.2
env:
ACCESS_TOKEN: ${{ secrets.DocsPushToken }}
BRANCH: gh-pages
FOLDER: docs/_build/html/
1 change: 1 addition & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ line_length=79
; )
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip_glob=ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/*
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extension-pkg-whitelist=

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
ignore=CVS,gen

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
Expand Down
36 changes: 10 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ See the [public meeting notes](https://docs.google.com/document/d/1CIMGoIOZ-c3-i
for a summary description of past meetings. To request edit access, join the
meeting or get in touch on [Gitter](https://gitter.im/open-telemetry/opentelemetry-python).

See to the [community membership document](https://github.com/open-telemetry/community/blob/master/community-membership.md)
on how to become a [**Member**](https://github.com/open-telemetry/community/blob/master/community-membership.md#member),
[**Approver**](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver)
and [**Maintainer**](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).

## Development

This project uses [`tox`](https://tox.readthedocs.io) to automate some aspects
Expand Down Expand Up @@ -37,7 +42,7 @@ pull requests (PRs).
To create a new PR, fork the project in GitHub and clone the upstream repo:

```sh
$ git clone https://https://github.com/open-telemetry/opentelemetry-python.git
$ git clone https://github.com/open-telemetry/opentelemetry-python.git
```

Add your fork as an origin:
Expand Down Expand Up @@ -74,15 +79,16 @@ Open a pull request against the main `opentelemetry-python` repo.
### How to Get PRs Merged

A PR is considered to be **ready to merge** when:
* It has received two approvals from Collaborators/Maintainers (at different
companies).
* It has received two approvals from [Approvers](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver)
/ [Maintainers](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer)
(at different companies).
* Major feedbacks are resolved.
* It has been open for review for at least one working day. This gives people
reasonable time to review.
* Trivial change (typo, cosmetic, doc, etc.) doesn't have to wait for one day.
* Urgent fix can take exception as long as it has been actively communicated.

Any Collaborator/Maintainer can merge the PR once it is **ready to merge**.
Any Approver / Maintainer can merge the PR once it is **ready to merge**.

## Design Choices

Expand Down Expand Up @@ -111,25 +117,3 @@ For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-sp
as specified with the [napolean
extension](http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#google-vs-numpy)
extension in [Sphinx](http://www.sphinx-doc.org/en/master/index.html).

## Become a Collaborator

Collaborators have write access to the repo.

To become a Collaborator:
* Become an active Contributor by working on PRs.
* Actively participate in the community meeting, design discussion, PR review
and issue discussion.
* Contact the Maintainers, express the willingness and commitment.
* Acknowledged and approved by two Maintainers (at different companies).

## Become a Maintainer

Maintainers have admin access to the repo.

To become a Maintainer:
* Become a [member of OpenTelemetry organization](https://github.com/orgs/open-telemetry/people).
* Become a Collaborator.
* Demonstrate the ability and commitment.
* Contact the Maintainers, express the willingness and commitment.
* Acknowledged and approved by all the current Maintainers.
99 changes: 70 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ The `opentelemetry-sdk` package is the reference implementation of the API.

Libraries that produce telemetry data should only depend on `opentelemetry-api`,
and defer the choice of the SDK to the application developer. Applications may
depend on `opentelemetry-sdk` or another package that implements the API.
depend on `opentelemetry-sdk` or another package that implements the API.

To install the API and SDK packages, fork or clone this repo and do an
[editable
install](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs)
via `pip`:
**Please note** that this library is currently in _alpha_, and shouldn't be
used in production environments.

The API and SDK packages are available on PyPI, and can installed via `pip`:

```sh
pip install -e ./opentelemetry-api
pip install -e ./opentelemetry-sdk
pip install opentelemetry-api
pip install opentelemetry-sdk
```

The
Expand All @@ -34,6 +34,16 @@ directory includes OpenTelemetry integration packages, which can be installed
separately as:

```sh
pip install opentelemetry-ext-{integration}
```

To install the development versions of these packages instead, clone or fork
this repo and do an [editable
install](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs):

```sh
pip install -e ./opentelemetry-api
pip install -e ./opentelemetry-sdk
pip install -e ./ext/opentelemetry-ext-{integration}
```

Expand All @@ -43,41 +53,72 @@ pip install -e ./ext/opentelemetry-ext-{integration}
from opentelemetry import trace
from opentelemetry.context import Context
from opentelemetry.sdk.trace import Tracer
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor

trace.set_preferred_tracer_implementation(lambda T: Tracer())
tracer = trace.tracer()
tracer.add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
)
with tracer.start_span('foo'):
print(Context)
with tracer.start_span('bar'):
print(Context)
with tracer.start_span('baz'):
print(Context)
print(Context)
print(Context)
```

See [opentelemetry-example-app](./opentelemetry-example-app/README.rst) for a complete example.
See the [API
documentation](https://open-telemetry.github.io/opentelemetry-python/) for more
detail, and the
[opentelemetry-example-app](./examples/opentelemetry-example-app/README.rst)
for a complete example.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)

## Release Schedule

OpenTelemetry Python is under active development. Our goal is to release an
_alpha_ version of the library at the end of September 2019. This release isn't
guaranteed to conform to a specific version of the specification, and future
releases will not attempt to maintain backwards compatibility with the alpha
release.

| Component | Version | Target Date |
| --------------------------- | ------- | ----------------- |
| Tracing API | Alpha | September 30 2019 |
| Tracing SDK | Alpha | September 30 2019 |
| Metrics API | Alpha | September 30 2019 |
| Metrics SDK | Alpha | September 30 2019 |
| Jaeger Trace Exporter | Alpha | Unknown |
| Prometheus Metrics Exporter | Alpha | Unknown |
| Context Propagation | Alpha | September 30 2019 |
| OpenTracing Bridge | Alpha | Unknown |
| OpenCensus Bridge | Alpha | Unknown |
OpenTelemetry Python is under active development.

The library is not yet _generally available_, and releases aren't guaranteed to
conform to a specific version of the specification. Future releases will not
attempt to maintain backwards compatibility with previous releases.

The [v0.1 alpha
release](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.1.0)
includes:

- Tracing API
- Tracing SDK
- Metrics API
- Metrics SDK (Partial)
- W3C Trace Context Propagation
- B3 Context Propagation
- HTTP Integrations

See the [project
milestones](https://github.com/open-telemetry/opentelemetry-python/milestones)
for details on upcoming releases. The dates and features described here are
estimates, and subject to change.

Future releases targets include:

| Component | Version | Target Date |
| --------------------------- | ---------- | --------------- |
| Jaeger Trace Exporter | Alpha v0.2 | October 28 2019 |
| Metrics SDK (Complete) | Alpha v0.2 | October 28 2019 |
| Prometheus Metrics Exporter | Alpha v0.2 | October 28 2019 |
| OpenTracing Bridge | Alpha v0.2 | October 28 2019 |

| Component | Version | Target Date |
| ----------------------------------- | ---------- | ---------------- |
| Zipkin Trace Exporter | Alpha v0.3 | November 15 2019 |
| W3C Correlation Context Propagation | Alpha v0.3 | November 15 2019 |
| Support for Tags/Baggage | Alpha v0.3 | November 15 2019 |
| Metrics Aggregation | Alpha v0.3 | November 15 2019 |
| gRPC Integrations | Alpha v0.3 | November 15 2019 |

| Component | Version | Target Date |
| ----------------- | ---------- | ---------------- |
| OpenCensus Bridge | Alpha v0.4 | December 31 2019 |
1 change: 0 additions & 1 deletion dev-requirements.txt

This file was deleted.

3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"sphinx.ext.viewcode",
# Link to other sphinx docs
"sphinx.ext.intersphinx",
# Add a .nojekyll file to the generated HTML docs
# https://help.github.com/en/articles/files-that-start-with-an-underscore-are-missing
"sphinx.ext.githubpages",
]

intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
Expand Down
7 changes: 0 additions & 7 deletions docs/opentelemetry.metrics.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
opentelemetry.metrics package
=============================

Submodules
----------

.. toctree::

opentelemetry.metrics.time_series

Module contents
---------------

Expand Down
5 changes: 0 additions & 5 deletions docs/opentelemetry.metrics.time_series.rst

This file was deleted.

12 changes: 11 additions & 1 deletion docs/opentelemetry.trace.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
opentelemetry.trace package
===========================

.. automodule:: opentelemetry.trace
Submodules
----------

.. toctree::

opentelemetry.trace.status

Module contents
---------------

.. automodule:: opentelemetry.trace
7 changes: 7 additions & 0 deletions docs/opentelemetry.trace.status.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.trace.status
==========================

.. automodule:: opentelemetry.trace.status
:members:
:undoc-members:
:show-inheritance:
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
This module serves as an example to integrate with flask, using
the requests library to perform downstream requests
"""
import time

import flask
import requests

import opentelemetry.ext.http_requests
from opentelemetry import trace
from opentelemetry import propagators, trace
from opentelemetry.ext.wsgi import OpenTelemetryMiddleware
from opentelemetry.sdk.context.propagation.b3_format import B3Format
from opentelemetry.sdk.trace import Tracer


Expand All @@ -39,14 +39,20 @@ def configure_opentelemetry(flask_app: flask.Flask):
* processors?
* exporters?
* propagators?
"""
# Start by configuring all objects required to ensure
# a complete end to end workflow.
# the preferred implementation of these objects must be set,
# as the opentelemetry-api defines the interface with a no-op
# implementation.
trace.set_preferred_tracer_implementation(lambda _: Tracer())
# Next, we need to configure how the values that are used by
# traces and metrics are propagated (such as what specific headers
# carry this value).

# TBD: can remove once default TraceContext propagators are installed.
propagators.set_global_httptextformat(B3Format())

# Integrations are the glue that binds the OpenTelemetry API
# and the frameworks and libraries that are used together, automatically
# creating Spans and propagating context as appropriate.
Expand All @@ -61,8 +67,8 @@ def configure_opentelemetry(flask_app: flask.Flask):
def hello():
# emit a trace that measures how long the
# sleep takes
with trace.tracer().start_span("sleep"):
time.sleep(0.001)
with trace.tracer().start_span("example-request"):
requests.get("http://www.example.com")
return "hello"


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
This module serves as an example for a simple application using metrics
"""

from opentelemetry import metrics
from opentelemetry.sdk.metrics import Counter, Meter

metrics.set_preferred_meter_implementation(lambda _: Meter())
meter = metrics.meter()
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)
meter.record_batch(label_values, [(counter, 50)])
print(counter_handle.data)

# TODO: exporters
File renamed without changes.
Loading

0 comments on commit c432da3

Please sign in to comment.