Skip to content

Commit c432da3

Browse files
committed
Span add override parameters
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 <[email protected]> Co-Authored-By: Chris Kleinknecht <[email protected]> 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 <[email protected]> Add set_status to Span (open-telemetry#213) Initial commit Initial version
1 parent dbb3be8 commit c432da3

File tree

105 files changed

+7843
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+7843
-731
lines changed

.flake8

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[flake8]
22
ignore = E501,W503,E203
3+
exclude = .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/,ext/opentelemetry-ext-jaeger/build/*

.github/workflows/docs.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- uses: actions/setup-python@v1
14+
- name: Build docs
15+
run: |
16+
pip install --upgrade tox
17+
tox -e docs
18+
- name: Publish to gh-pages
19+
uses: JamesIves/[email protected]
20+
env:
21+
ACCESS_TOKEN: ${{ secrets.DocsPushToken }}
22+
BRANCH: gh-pages
23+
FOLDER: docs/_build/html/

.isort.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ line_length=79
1212
; )
1313
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
1414
multi_line_output=3
15+
skip_glob=ext/opentelemetry-ext-jaeger/src/opentelemetry/ext/jaeger/gen/*

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extension-pkg-whitelist=
77

88
# Add files or directories to the blacklist. They should be base names, not
99
# paths.
10-
ignore=CVS
10+
ignore=CVS,gen
1111

1212
# Add files or directories matching the regex patterns to the blacklist. The
1313
# regex matches against base names, not paths.

CONTRIBUTING.md

+10-26
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ See the [public meeting notes](https://docs.google.com/document/d/1CIMGoIOZ-c3-i
88
for a summary description of past meetings. To request edit access, join the
99
meeting or get in touch on [Gitter](https://gitter.im/open-telemetry/opentelemetry-python).
1010

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

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

3944
```sh
40-
$ git clone https://https://github.com/open-telemetry/opentelemetry-python.git
45+
$ git clone https://github.com/open-telemetry/opentelemetry-python.git
4146
```
4247

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

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

85-
Any Collaborator/Maintainer can merge the PR once it is **ready to merge**.
91+
Any Approver / Maintainer can merge the PR once it is **ready to merge**.
8692

8793
## Design Choices
8894

@@ -111,25 +117,3 @@ For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-sp
111117
as specified with the [napolean
112118
extension](http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#google-vs-numpy)
113119
extension in [Sphinx](http://www.sphinx-doc.org/en/master/index.html).
114-
115-
## Become a Collaborator
116-
117-
Collaborators have write access to the repo.
118-
119-
To become a Collaborator:
120-
* Become an active Contributor by working on PRs.
121-
* Actively participate in the community meeting, design discussion, PR review
122-
and issue discussion.
123-
* Contact the Maintainers, express the willingness and commitment.
124-
* Acknowledged and approved by two Maintainers (at different companies).
125-
126-
## Become a Maintainer
127-
128-
Maintainers have admin access to the repo.
129-
130-
To become a Maintainer:
131-
* Become a [member of OpenTelemetry organization](https://github.com/orgs/open-telemetry/people).
132-
* Become a Collaborator.
133-
* Demonstrate the ability and commitment.
134-
* Contact the Maintainers, express the willingness and commitment.
135-
* Acknowledged and approved by all the current Maintainers.

README.md

+70-29
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ The `opentelemetry-sdk` package is the reference implementation of the API.
1616

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

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

2626
```sh
27-
pip install -e ./opentelemetry-api
28-
pip install -e ./opentelemetry-sdk
27+
pip install opentelemetry-api
28+
pip install opentelemetry-sdk
2929
```
3030

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

3636
```sh
37+
pip install opentelemetry-ext-{integration}
38+
```
39+
40+
To install the development versions of these packages instead, clone or fork
41+
this repo and do an [editable
42+
install](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs):
43+
44+
```sh
45+
pip install -e ./opentelemetry-api
46+
pip install -e ./opentelemetry-sdk
3747
pip install -e ./ext/opentelemetry-ext-{integration}
3848
```
3949

@@ -43,41 +53,72 @@ pip install -e ./ext/opentelemetry-ext-{integration}
4353
from opentelemetry import trace
4454
from opentelemetry.context import Context
4555
from opentelemetry.sdk.trace import Tracer
56+
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
57+
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
4658

4759
trace.set_preferred_tracer_implementation(lambda T: Tracer())
4860
tracer = trace.tracer()
61+
tracer.add_span_processor(
62+
SimpleExportSpanProcessor(ConsoleSpanExporter())
63+
)
4964
with tracer.start_span('foo'):
50-
print(Context)
5165
with tracer.start_span('bar'):
52-
print(Context)
5366
with tracer.start_span('baz'):
5467
print(Context)
55-
print(Context)
56-
print(Context)
5768
```
5869

59-
See [opentelemetry-example-app](./opentelemetry-example-app/README.rst) for a complete example.
70+
See the [API
71+
documentation](https://open-telemetry.github.io/opentelemetry-python/) for more
72+
detail, and the
73+
[opentelemetry-example-app](./examples/opentelemetry-example-app/README.rst)
74+
for a complete example.
6075

6176
## Contributing
6277

6378
See [CONTRIBUTING.md](CONTRIBUTING.md)
6479

6580
## Release Schedule
6681

67-
OpenTelemetry Python is under active development. Our goal is to release an
68-
_alpha_ version of the library at the end of September 2019. This release isn't
69-
guaranteed to conform to a specific version of the specification, and future
70-
releases will not attempt to maintain backwards compatibility with the alpha
71-
release.
72-
73-
| Component | Version | Target Date |
74-
| --------------------------- | ------- | ----------------- |
75-
| Tracing API | Alpha | September 30 2019 |
76-
| Tracing SDK | Alpha | September 30 2019 |
77-
| Metrics API | Alpha | September 30 2019 |
78-
| Metrics SDK | Alpha | September 30 2019 |
79-
| Jaeger Trace Exporter | Alpha | Unknown |
80-
| Prometheus Metrics Exporter | Alpha | Unknown |
81-
| Context Propagation | Alpha | September 30 2019 |
82-
| OpenTracing Bridge | Alpha | Unknown |
83-
| OpenCensus Bridge | Alpha | Unknown |
82+
OpenTelemetry Python is under active development.
83+
84+
The library is not yet _generally available_, and releases aren't guaranteed to
85+
conform to a specific version of the specification. Future releases will not
86+
attempt to maintain backwards compatibility with previous releases.
87+
88+
The [v0.1 alpha
89+
release](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.1.0)
90+
includes:
91+
92+
- Tracing API
93+
- Tracing SDK
94+
- Metrics API
95+
- Metrics SDK (Partial)
96+
- W3C Trace Context Propagation
97+
- B3 Context Propagation
98+
- HTTP Integrations
99+
100+
See the [project
101+
milestones](https://github.com/open-telemetry/opentelemetry-python/milestones)
102+
for details on upcoming releases. The dates and features described here are
103+
estimates, and subject to change.
104+
105+
Future releases targets include:
106+
107+
| Component | Version | Target Date |
108+
| --------------------------- | ---------- | --------------- |
109+
| Jaeger Trace Exporter | Alpha v0.2 | October 28 2019 |
110+
| Metrics SDK (Complete) | Alpha v0.2 | October 28 2019 |
111+
| Prometheus Metrics Exporter | Alpha v0.2 | October 28 2019 |
112+
| OpenTracing Bridge | Alpha v0.2 | October 28 2019 |
113+
114+
| Component | Version | Target Date |
115+
| ----------------------------------- | ---------- | ---------------- |
116+
| Zipkin Trace Exporter | Alpha v0.3 | November 15 2019 |
117+
| W3C Correlation Context Propagation | Alpha v0.3 | November 15 2019 |
118+
| Support for Tags/Baggage | Alpha v0.3 | November 15 2019 |
119+
| Metrics Aggregation | Alpha v0.3 | November 15 2019 |
120+
| gRPC Integrations | Alpha v0.3 | November 15 2019 |
121+
122+
| Component | Version | Target Date |
123+
| ----------------- | ---------- | ---------------- |
124+
| OpenCensus Bridge | Alpha v0.4 | December 31 2019 |

dev-requirements.txt

-1
This file was deleted.

docs/conf.py

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"sphinx.ext.viewcode",
4343
# Link to other sphinx docs
4444
"sphinx.ext.intersphinx",
45+
# Add a .nojekyll file to the generated HTML docs
46+
# https://help.github.com/en/articles/files-that-start-with-an-underscore-are-missing
47+
"sphinx.ext.githubpages",
4548
]
4649

4750
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}

docs/opentelemetry.metrics.rst

-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
opentelemetry.metrics package
22
=============================
33

4-
Submodules
5-
----------
6-
7-
.. toctree::
8-
9-
opentelemetry.metrics.time_series
10-
114
Module contents
125
---------------
136

docs/opentelemetry.metrics.time_series.rst

-5
This file was deleted.

docs/opentelemetry.trace.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
opentelemetry.trace package
22
===========================
33

4-
.. automodule:: opentelemetry.trace
4+
Submodules
5+
----------
6+
7+
.. toctree::
8+
9+
opentelemetry.trace.status
10+
11+
Module contents
12+
---------------
13+
14+
.. automodule:: opentelemetry.trace

docs/opentelemetry.trace.status.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
opentelemetry.trace.status
2+
==========================
3+
4+
.. automodule:: opentelemetry.trace.status
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py renamed to examples/opentelemetry-example-app/src/opentelemetry_example_app/flask_example.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
This module serves as an example to integrate with flask, using
1717
the requests library to perform downstream requests
1818
"""
19-
import time
20-
2119
import flask
20+
import requests
2221

2322
import opentelemetry.ext.http_requests
24-
from opentelemetry import trace
23+
from opentelemetry import propagators, trace
2524
from opentelemetry.ext.wsgi import OpenTelemetryMiddleware
25+
from opentelemetry.sdk.context.propagation.b3_format import B3Format
2626
from opentelemetry.sdk.trace import Tracer
2727

2828

@@ -39,14 +39,20 @@ def configure_opentelemetry(flask_app: flask.Flask):
3939
4040
* processors?
4141
* exporters?
42-
* propagators?
4342
"""
4443
# Start by configuring all objects required to ensure
4544
# a complete end to end workflow.
4645
# the preferred implementation of these objects must be set,
4746
# as the opentelemetry-api defines the interface with a no-op
4847
# implementation.
4948
trace.set_preferred_tracer_implementation(lambda _: Tracer())
49+
# Next, we need to configure how the values that are used by
50+
# traces and metrics are propagated (such as what specific headers
51+
# carry this value).
52+
53+
# TBD: can remove once default TraceContext propagators are installed.
54+
propagators.set_global_httptextformat(B3Format())
55+
5056
# Integrations are the glue that binds the OpenTelemetry API
5157
# and the frameworks and libraries that are used together, automatically
5258
# creating Spans and propagating context as appropriate.
@@ -61,8 +67,8 @@ def configure_opentelemetry(flask_app: flask.Flask):
6167
def hello():
6268
# emit a trace that measures how long the
6369
# sleep takes
64-
with trace.tracer().start_span("sleep"):
65-
time.sleep(0.001)
70+
with trace.tracer().start_span("example-request"):
71+
requests.get("http://www.example.com")
6672
return "hello"
6773

6874

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2019, OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
"""
16+
This module serves as an example for a simple application using metrics
17+
"""
18+
19+
from opentelemetry import metrics
20+
from opentelemetry.sdk.metrics import Counter, Meter
21+
22+
metrics.set_preferred_meter_implementation(lambda _: Meter())
23+
meter = metrics.meter()
24+
counter = meter.create_metric(
25+
"available memory",
26+
"available memory",
27+
"bytes",
28+
int,
29+
Counter,
30+
("environment",),
31+
)
32+
33+
label_values = ("staging",)
34+
counter_handle = counter.get_handle(label_values)
35+
counter_handle.add(100)
36+
meter.record_batch(label_values, [(counter, 50)])
37+
print(counter_handle.data)
38+
39+
# TODO: exporters

0 commit comments

Comments
 (0)