Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…try-python into sample
  • Loading branch information
lzchen committed Aug 31, 2020
2 parents 4ca421c + dd47cd4 commit a3430b6
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 221 deletions.
94 changes: 9 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@

---

## About this project
## OpenTelemetry Python

The Python [OpenTelemetry](https://opentelemetry.io/) client.
The Python [OpenTelemetry](https://opentelemetry.io/) implementation.

## Installation
## Getting started

OpenTelemetry's goal is to provide a single set of APIs to capture distributed traces and metrics from your application and send them to an observability platform. This project allows you to do just that for applications written in Python.

This repository includes multiple installable packages. The `opentelemetry-api`
package includes abstract classes and no-op implementations that comprise the OpenTelemetry API following
Expand All @@ -52,9 +54,6 @@ 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.

**Please note** that this library is currently in _beta_, and shouldn't
generally be used in production environments.

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

```sh
Expand Down Expand Up @@ -94,13 +93,9 @@ The online documentation is available at https://opentelemetry-python.readthedoc
if you want to access the documentation for the latest version use
https://opentelemetry-python.readthedocs.io/en/latest/.

## Compatible Exporters

See the [OpenTelemetry registry](https://opentelemetry.io/registry/?s=python) for a list of exporters available.

## Contributing

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

We meet weekly on Thursday at 9AM PT. The meeting is subject to change depending on contributors' availability. Check the [OpenTelemetry community calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com) for specific dates.

Expand Down Expand Up @@ -134,78 +129,7 @@ Maintainers ([@open-telemetry/python-maintainers](https://github.com/orgs/open-t
<img src="https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-python" />
</a>

## Release Schedule

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. Each alpha
and beta release includes significant changes to the API and SDK packages,
making them incompatible with each other.

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

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

- OpenTracing Bridge
- Jaeger Trace Exporter
- Trace Sampling

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

- Metrics Instruments and Labels
- Flask Integration
- PyMongo Integration

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

- Metrics MinMaxSumCount Aggregator
- Context API
- Full Metrics SDK Pipeline
- Metrics STDOUT Exporter
- Dbapi2 Integration
- MySQL Integration
- Psycopg2 Integration
- Zipkin Exporter
- Prometheus Metrics Exporter
- New Examples and Improvements to Existing Examples

The [v0.5 beta
release](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.5.0)
includes:

- W3C Correlation Context Propagation
- OpenTelemetry Collector Exporter Integration for both metrics and traces
- Metrics SDK
- Global configuration module
- Documentation improvements

The [v0.6 beta
release](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.6.0)
includes:

- API changes and bugfixes
- An autoinstrumentation package and updated Flask instrumentation
- gRPC integration

See the [project
milestones](https://github.com/open-telemetry/opentelemetry-python/milestones)
for details on upcoming releases. The dates and features described in issues
## Project Status

Project [boards](https://github.com/open-telemetry/opentelemetry-python/projects) and [milestones](https://github.com/open-telemetry/opentelemetry-python/milestones) can be found at the respective links. We try to keep these accurate and should be the best place to go for answers on project status. The dates and features described in issues
and milestones are estimates, and subject to change.
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ The Python `OpenTelemetry <https://opentelemetry.io/>`_ client.
This documentation describes the :doc:`opentelemetry-api <api/api>`,
:doc:`opentelemetry-sdk <sdk/sdk>`, and several `integration packages <#integrations>`_.

**Please note** that this library is currently in alpha, and shouldn't be
used in production environments.
**Please note** that this library is currently in _beta_, and shouldn't
generally be used in production environments.

Installation
------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ url = https://github.com/open-telemetry/opentelemetry-python/instrumentation/ope
platforms = any
license = Apache-2.0
classifiers =
Development Status :: 3 - Alpha
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
([#1005](https://github.com/open-telemetry/opentelemetry-python/pull/1005))
- Moved samplers from API to SDK
([#1023](https://github.com/open-telemetry/opentelemetry-python/pull/1023))
- Change return value type of `correlationcontext.get_correlations` to immutable `MappingProxyType`
([#1024](https://github.com/open-telemetry/opentelemetry-python/pull/1024))
- Change is_recording_events to is_recording
([#1034](https://github.com/open-telemetry/opentelemetry-python/pull/1034))
- Remove lazy Event and Link API from Span interface
([#1045](https://github.com/open-telemetry/opentelemetry-python/pull/1045))

## Version 0.12b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import typing
from types import MappingProxyType

from opentelemetry.context import get_value, set_value
from opentelemetry.context.context import Context
Expand All @@ -22,7 +23,7 @@

def get_correlations(
context: typing.Optional[Context] = None,
) -> typing.Dict[str, object]:
) -> typing.Mapping[str, object]:
"""Returns the name/value pairs in the CorrelationContext
Args:
Expand All @@ -33,8 +34,8 @@ def get_correlations(
"""
correlations = get_value(_CORRELATION_CONTEXT_KEY, context=context)
if isinstance(correlations, dict):
return correlations.copy()
return {}
return MappingProxyType(correlations.copy())
return MappingProxyType({})


def get_correlation(
Expand Down Expand Up @@ -67,7 +68,7 @@ def set_correlation(
Returns:
A Context with the value updated
"""
correlations = get_correlations(context=context)
correlations = dict(get_correlations(context=context))
correlations[name] = value
return set_value(_CORRELATION_CONTEXT_KEY, correlations, context=context)

Expand All @@ -84,7 +85,7 @@ def remove_correlation(
Returns:
A Context with the name/value removed
"""
correlations = get_correlations(context=context)
correlations = dict(get_correlations(context=context))
correlations.pop(name, None)

return set_value(_CORRELATION_CONTEXT_KEY, correlations, context=context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def inject(
)


def _format_correlations(correlations: typing.Dict[str, object]) -> str:
def _format_correlations(correlations: typing.Mapping[str, object]) -> str:
return ",".join(
key + "=" + urllib.parse.quote_plus(str(value))
for key, value in correlations.items()
Expand Down
23 changes: 0 additions & 23 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,6 @@ def attributes(self) -> types.Attributes:
return self._attributes


class LazyLink(LinkBase):
"""A lazy link to a `Span`.
Args:
context: `SpanContext` of the `Span` to link to.
link_formatter: Callable object that returns the attributes of the
Link.
"""

def __init__(
self,
context: "SpanContext",
link_formatter: types.AttributesFormatter,
) -> None:
super().__init__(context)
self._link_formatter = link_formatter

@property
def attributes(self) -> types.Attributes:
return self._link_formatter()


class SpanKind(enum.Enum):
"""Specifies additional details on how this span relates to its parent span.
Expand Down Expand Up @@ -464,7 +442,6 @@ def get_tracer_provider() -> TracerProvider:
"DefaultSpan",
"DefaultTracer",
"DefaultTracerProvider",
"LazyLink",
"Link",
"LinkBase",
"ParentSpan",
Expand Down
21 changes: 0 additions & 21 deletions opentelemetry-api/src/opentelemetry/trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ def add_event(
timestamp if the `timestamp` argument is omitted.
"""

@abc.abstractmethod
def add_lazy_event(
self,
name: str,
event_formatter: types.AttributesFormatter,
timestamp: typing.Optional[int] = None,
) -> None:
"""Adds an `Event`.
Adds a single `Event` with the name, an event formatter that calculates
the attributes lazily and, optionally, a timestamp. Implementations
should generate a timestamp if the `timestamp` argument is omitted.
"""

@abc.abstractmethod
def update_name(self, name: str) -> None:
"""Updates the `Span` name.
Expand Down Expand Up @@ -233,14 +220,6 @@ def add_event(
) -> None:
pass

def add_lazy_event(
self,
name: str,
event_formatter: types.AttributesFormatter,
timestamp: typing.Optional[int] = None,
) -> None:
pass

def update_name(self, name: str) -> None:
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_modifying_correlations(self):
ctx = cctx.set_correlation("test", "value")
self.assertEqual(cctx.get_correlation("test", context=ctx), "value")
correlations = cctx.get_correlations(context=ctx)
correlations["test"] = "mess-this-up"
with self.assertRaises(TypeError):
correlations["test"] = "mess-this-up"
self.assertEqual(cctx.get_correlation("test", context=ctx), "value")

def test_remove_correlations(self):
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#1023](https://github.com/open-telemetry/opentelemetry-python/pull/1023))
- Sampling spec changes
([#1034](https://github.com/open-telemetry/opentelemetry-python/pull/1034))
- Remove lazy Event and Link API from Span interface
([#1045](https://github.com/open-telemetry/opentelemetry-python/pull/1045))

## Version 0.12b0

Expand Down
43 changes: 0 additions & 43 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,35 +284,6 @@ def attributes(self) -> types.Attributes:
return self._attributes


class LazyEvent(EventBase):
"""A text annotation with a set of attributes.
Args:
name: Name of the event.
event_formatter: Callable object that returns the attributes of the
event.
timestamp: Timestamp of the event. If `None` it will filled
automatically.
"""

def __init__(
self,
name: str,
event_formatter: types.AttributesFormatter,
timestamp: Optional[int] = None,
) -> None:
super().__init__(name, timestamp)
self._event_formatter = event_formatter

@property
def attributes(self) -> types.Attributes:
attributes = self._event_formatter()
_filter_attribute_values(attributes)
if not attributes:
attributes = Span._new_attributes()
return attributes


def _is_valid_attribute_value(value: types.AttributeValue) -> bool:
"""Checks if attribute value is valid.
Expand Down Expand Up @@ -596,20 +567,6 @@ def add_event(
)
)

def add_lazy_event(
self,
name: str,
event_formatter: types.AttributesFormatter,
timestamp: Optional[int] = None,
) -> None:
self._add_event(
LazyEvent(
name=name,
event_formatter=event_formatter,
timestamp=time_ns() if timestamp is None else timestamp,
)
)

def start(self, start_time: Optional[int] = None) -> None:
with self._lock:
if not self.is_recording():
Expand Down
Loading

0 comments on commit a3430b6

Please sign in to comment.