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.