renaming otcollector to opencensus, as it's using opencensus under the hood. This was originally intended to be replaced by otlp, by a new package can be created for that instead.
Co-authored-by: alrex <alrex.boten@gmail.com>
Some build time improvements:
- split lint/docker-tests/docs into their own steps. Since lint is usually the thing that fails anyways, it's good to have it run first. We could make the build depend on this step to prevent slowing other builds waiting in the pipeline (since we only have 5 workers)
- move all pip install commands into a single line per test environment. this reduces the overhead of calling the pip command separately multiple times per environment.
- removed pip upgrade command for pypy3 and py38
There are some examples that are duplicated in the getting started guide and in
the examples folder itself. This commit removes the duplicated examples and
updates the getting started guide to include then from real source files that
are passed through the linter and have tests.
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: alrex <aboten@lightstep.com>
The CI is not able to catch many documentation problems because we are ignoring
warnings. This commit fixes most of the warnings, ignores the rest and enables
a flag to treat them as errors.
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Add an exporter to Datadog. This implementation makes use of ddtrace to handle the creation of Datadog traces and writing them to the Datadog agent.
Co-Authored-By: Mauricio Vásquez <mauricio@kinvolk.io>
Implement to helper methods to allow users to enable / disable instrumentation
in a single connection object.
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: alrex <alrex.boten@gmail.com>
Adding initial aiohttp client.
This module is only supported on Python3.5, which is the oldest supported by
aiohttp.
Co-authored-by: Yusuke Tsutsumi <yusuke@tsutsumi.io>
The requests integration is named http-requests because at the time it was created there were some problems with pylint.
other integrations are using opentelemetry.ext.integration without problems, tests are passing without issue, even renamed.
The current Pymongo integration uses the monitoring.register() [1] to hook
the different internal calls of Pymongo. This integration doesn't allow to
unregister a monitor. This commit workaround that limitation by adding an
enable flag to the CommandTracer class and adds a logic to disable the
integration. This solution is not perfect becasue there will be some overhead
even when the instrumentation is disabled, but that's what we can do with
the current approach.
[1] https://api.mongodb.com/python/current/api/pymongo/monitoring.html#pymongo.monitoring.register
Co-authored-by: Alex Boten <aboten@lightstep.com>
Implement the BaseInstrumentor interface to make this library compatible with the opentelemetry-auto-instr command.
There is an issue about getting the span when the global tracer provider hasn't been configured, this should be changed in the future once we extend the opentelemetry-auto-instr command to also configure the SDK.
Porting the existing redis instrumentation from the contrib repo to using the OpenTelemetry API and the OpenTelemetry Auto-instrumentation Instrumentor interface.
Similiar to the sqlalchemy PR, the main thing that will need updating is to remove the patch/unpatch methods once the instrumentor interface changes have been merged.
This is replacing open-telemetry/opentelemetry-python-contrib#21
Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
Co-authored-by: Leighton Chen <lechen@microsoft.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Chris Kleinknecht <libc@google.com>
Integration for PyMySQL.
Fixes some documentation as well for other db integrations. Leverages dbapi.
Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
Update tests to use TestBase as described on #303.
Co-authored-by: Yusuke Tsutsumi <yusuke@tsutsumi.io>
Co-authored-by: Chris Kleinknecht <libc@google.com>
Adding a TestBase class which wraps a tracer provider that is configured with a memory span
exporter. This class inherits from unitest.TestCase, hence other test classes
can inherit from it to get access to the underlying memory span exporter and
tracer provider.
Adding a mock propagator that could be used for testing propagation in different packages.
It was implemented in the opentracing-shim and this commit moves it to a generic
place.
Adding disable_session(), which can be used to disable the instrumentation on a single
requests' session object.
opentelemetry-ext-testutil is a package with shared test classes used by ext packages (right now only opentelemetry-ext-flask). We don't release this package, just import it in other tests.
Right now, on each release, we build everything in ext/. This means whoever does the release has to remember to exclude this package when they push the others to PyPI.
This moves the files and package:
Move files ext/opentelemetry-ext-testutil -> tests/util
Move package opentelemetry.ext.testutil -> opentelemetry.test
This makes maintainers' lives easier, but it does mean that other packages that use testutils will have to install install the opentelemetry.test package from source. But this is already the case since we don't publish opentelemetry-ext-testutil.
we move shared test code back into the main repo until we move a package that depends on it into a separate repo, at which point we'll have to put this code in its own top-level package.
Move tox and other configuration files to root folder. Add eachdist to make it
easier to handle operations with different packages.
The eachdist is taken from opentelemetry but slighty modified to avoid ignoring
a given path.
This is a port of grpcio-opentracing, and borrows from opencensus-ext-grpc. It
adds client and server interceptors that wrap each request in a span and use
the new context API to inject/extract the traceparent header to/from gRPC
metadata.
Co-authored-by: alrex <alrex.boten@gmail.com>
Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
Co-authored-by: Mario Jonke <mario.jonke@dynatrace.com>
Co-authored-by: Daniel González <danielgonzalezlopes@gmail.com>
Co-authored-by: Alex Boten <aboten@lightstep.com>
Co-authored-by: Yusuke Tsutsumi <yusuke@tsutsumi.io>
Adding an autoinstrumentation mechanism and a Flask instrumentor (an instrumentor is a class that implements the _instrument and _uninstrument methods).
It works like this:
A console command is defined. This makes it possible to run a command named opentelemetry-auto-instrumentation that will execute this function.
When the opentelemetry-auto-instrumentation command is executed, then the instrument method of the different instrumentors is called, which are made available via an entry-point.
2.In the case of the Flask instrumentor, the original flask.Flask gets replaced with _InstrumentedFlask (in this case, the Flask instrumentor uses monkey patching to perform the instrumentation, nevertheless, monkey patching is not always the method used to do this, so the name instrumentor is preferred over patcher).
Once all instrumentation is enabled, the app is executed.
Co-Authored-By: Mauricio Vásquez <mauricio@kinvolk.io>
Co-authored-by: Chris Kleinknecht <libc@google.com>
Add a test to ensure readmes render properly
Also adds README.rst for testutil package to pass new test.
Co-authored-by: Christian Neumüller <christian+github@neumueller.me>
This commit moves the text on the readmes of the external packages to their
source code as a docstring. This improves the generated documentation and helps
to consolidate the documentation in a single place.
Also unify the readmes present on each package to include a 1 line description, installation instructions and a link to the online documentation. This small readme will be the one shown on Github and on PyPI.
Also change the examples structure to have the following examples:
- basic meter & tracer
- http integration
- jaeger, prometheus, otcollector{tracer, metrics}
- opentracing shim
Co-authored-by: alrex <alrex.boten@gmail.com>
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
OpenTelemetry doesn't support Python 2.7. Removing it from the tests and removing contrib packages that don't support Python 3. In this change:
- removing pylons contrib
- removing mysqldb contrib
- updating minimum versions of flask (>=1.0), gevent (>=1.1)
Signed-off-by: Alex Boten <aboten@lightstep.com>
- 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.
Co-authored-by: Chris Kleinknecht <libc@google.com>
This change implements the Context API portion of OTEP #66. The
CorrelationContext API and Propagation API changes will come in future PRs.
We're leveraging entrypoints to support other implementations of the Context
API if/when necessary. For backwards compatibility, this change uses
aiocontextvars for Python versions older than 3.7.
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
The InMemorySpanExporter provides a friendly interface to retrieving span information, reducing the need for mocking in unit tests.
Signed-off-by: Alex Boten <aboten@lightstep.com>
The primary purpose of LabelSets are to have an optimal way of re-using handles
with the same label values. We achieve this by having the keys and values of
the labels encoded and stored in each LabelSet instance, so we can have an easy
lookup to the corresponding handle for each metric instrument.
The flask integration has (only) two advantages over the plain WSGI middleware
approach:
- It can use the endpoint as span name (which is lower cardinality than the
route; cf #270)
- It can set the http.route attribute.
In addition, it also has an easier syntax to enable (you don't have to know
about Flask.wsgi_app).
Verifying that our tracecontext is compliant with the w3c
tracecontext reference is valuable. Adding a tox command
to verify that the TraceContext propagator adheres to the
w3c spec.
The tracecontexthttptextformat is now completely compliant with the w3c
tracecontext test suite.
In particular, the following errors are fixed in this commit:
* Don't return False in __exit__
Returning a literal causes a mypy error when combined with the
`typing.Optional[bool]` type hint. Furthermore, exception handling is
the same when returning `False` and when returning `None` (the
exception is re-raised). Therefore, it's simpler to remove the return
statement and change the type hint to `None`.
* Correctly initialize nested tuple
Tuples of length 1 should be initialized with a trailing comma to be
properly interpreted.
* Pass correct type to use_context() in test
* Add type annotations for test helper functions
Since we have `disallow_untyped_calls = True` in our mypy config for
tests, we must add type annotations to any function that is called
from a test.
Addditionally, bump minimal mypy version to 0.740 to consistently reproduce these errors.
* Ensure that type info is picked up from installed package.
This required moving all top-level modules to a sub-package, to not
create collisions with py.typed marker files.
See https://www.python.org/dev/peps/pep-0561/#packaging-type-information
* Add MANIFEST.in for SDK package.
* Fix setup for ext packages.
Previously the wheels would contain the metadata but not the actual
code.
* Check that all packages install properly in test.
* Document why we don't use -e.
Adds requests integration. Two commits that might be of special interest (see #94):
* c66af2faa100b0f41afafdb6e4de9f4de4cc62bc requests test: Use actual Response object.
Co-Authored-By: Allan Feldman <6374032+a-feld@users.noreply.github.com>
* 1b90a0ddc286c936f7256b14e14ef36fd3c6a24f More tests, rename to http-requests to work around pylint bug (?)
See previous CI failure for pylint issue:
************* Module ext/opentelemetry-ext-requests/src/__init__.py
ext/opentelemetry-ext-requests/src/__init__.py:1:0: F0001: No module named ext/opentelemetry-ext-requests/src/__init__.py (fatal)
It seems that pylint gets confused when there is more than one "requests" module??
I believe it would be nice to have
tests on CI not only for Python 3.7,
but for all supported Python versions.
These changes:
- fix compatibility with Python 3.5 and 3.4
- add tests for various Python versions on CI
- allow running tests for any branches