Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrand authored Mar 10, 2021
2 parents 0efc3ec + 9ef4410 commit c3a260a
Show file tree
Hide file tree
Showing 83 changed files with 968 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: a434be5f450fdd329bcefb41e84406a001f9534c
CORE_REPO_SHA: 10dc3a8bc031d5b355f62a698094a03eedb2a8ee

jobs:
build:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python-contrib/compare/v0.18b0...HEAD)
- Updated instrumentations to use `opentelemetry.trace.use_span` instead of `Tracer.use_span()`
([#364](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/364))

### Changed
- Rename `IdsGenerator` to `IdGenerator`
([#350](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/350))

### Changed
- `opentelemetry-instrumentation-sqlalchemy` Fix multithreading issues in recording spans from SQLAlchemy
Expand All @@ -15,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `opentelemetry-propagator-ot-trace` Add OT Trace Propagator
([#302](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/302))
- `opentelemetry-instrumentation-logging` Added logging instrumentation to enable log - trace correlation.
([#345](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/345))

### Removed
- Remove `component` span attribute in instrumentations.
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ information on this and other language SIGs.

See the [public meeting notes](https://docs.google.com/document/d/1CIMGoIOZ-c3-igzbd6_Pnxx1SjAkjwqoYSUWxPY8XIs/edit)
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).
meeting or get in touch on [Slack](https://cloud-native.slack.com/archives/C01PD4HUVBL).

See to the [community membership document](https://github.com/open-telemetry/community/blob/main/community-membership.md)
on how to become a [**Member**](https://github.com/open-telemetry/community/blob/main/community-membership.md#member),
Expand All @@ -16,9 +16,9 @@ and [**Maintainer**](https://github.com/open-telemetry/community/blob/main/commu
## Find a Buddy and get Started Quickly!

If you are looking for someone to help you find a starting point and be a resource for your first contribution, join our
Gitter and find a buddy!
Slack and find a buddy!

1. Join [Gitter.im](https://gitter.im) and join our [chat room](https://gitter.im/open-telemetry/opentelemetry-python).
1. Join [Slack](https://slack.cncf.io/) and join our [chat room](https://cloud-native.slack.com/archives/C01PD4HUVBL).
2. Post in the room with an introduction to yourself, what area you are interested in (check issues marked "Help Wanted"),
and say you are looking for a buddy. We will match you with someone who has experience in that area.

Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ OpenTelemetry-Python-Contrib
Complimentary instrumentation and vendor-specific packages for use with the
Python `OpenTelemetry <https://opentelemetry.io/>`_ client.

.. image:: https://img.shields.io/gitter/room/opentelemetry/opentelemetry-python
:target: https://gitter.im/open-telemetry/opentelemetry-python
:alt: Gitter Chat
.. image:: https://img.shields.io/badge/slack-chat-green.svg
:target: https://cloud-native.slack.com/archives/C01PD4HUVBL
:alt: Slack Chat


**Please note** that this library is currently in _beta_, and shouldn't
Expand Down
7 changes: 7 additions & 0 deletions docs/instrumentation/logging/logging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OpenTelemetry Logging Instrumentation
=====================================

.. automodule:: opentelemetry.instrumentation.logging
:members:
:undoc-members:
:show-inheritance:
16 changes: 9 additions & 7 deletions docs/nitpick-exceptions.ini
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
[default]
class_references=
; TODO: Understand why sphinx is not able to find this local class
opentelemetry.trace.propagation.textmap.TextMapPropagator
opentelemetry.propagators.textmap.TextMapPropagator
; - AwsXRayFormat
opentelemetry.trace.propagation.textmap.DictGetter
opentelemetry.propagators.textmap.DictGetter
; API
opentelemetry.trace.propagation.textmap.Getter
opentelemetry.propagators.textmap.Getter
; - DatadogFormat
; - AWSXRayFormat
opentelemetry.sdk.trace.id_generator.IdGenerator
; - AwsXRayIdGenerator
TextMapPropagatorT
; - AwsXRayFormat.extract

anys=
; API
opentelemetry.trace.propagation.textmap.TextMapPropagator.fields
opentelemetry.propagators.textmap.TextMapPropagator.fields
; - AWSXRayFormat
TraceId
; - AwsXRayIdsGenerator
; - AwsXRayIdGenerator
TraceIdRatioBased
; - AwsXRayIdsGenerator
; - AwsXRayIdGenerator
; SDK
SpanProcessor
; - DatadogExportSpanProcessor
TracerProvider
; - AwsXRayIdsGenerator
; - AwsXRayIdGenerator
; Instrumentation
BaseInstrumentor
; - instrumentation.*
2 changes: 1 addition & 1 deletion docs/sdk-extension/aws/aws.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OpenTelemetry Python - AWS SDK Extension
========================================

.. automodule:: opentelemetry.sdk.extension.aws.trace.aws_xray_ids_generator
.. automodule:: opentelemetry.sdk.extension.aws.trace.aws_xray_id_generator
:members:
:undoc-members:
:show-inheritance:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from opentelemetry import trace
from opentelemetry.context import Context
from opentelemetry.exporter.datadog import constants
from opentelemetry.trace import get_current_span, set_span_in_context
from opentelemetry.trace.propagation.textmap import (
from opentelemetry.propagators.textmap import (
Getter,
Setter,
TextMapPropagator,
TextMapPropagatorT,
)
from opentelemetry.trace import get_current_span, set_span_in_context


class DatadogFormat(TextMapPropagator):
Expand Down Expand Up @@ -73,7 +73,9 @@ def extract(
trace_state=trace.TraceState([(constants.DD_ORIGIN, origin)]),
)

return set_span_in_context(trace.DefaultSpan(span_context), context)
return set_span_in_context(
trace.NonRecordingSpan(span_context), context
)

def inject(
self,
Expand Down Expand Up @@ -109,7 +111,7 @@ def fields(self):
"""Returns a set with the fields set in `inject`.
See
`opentelemetry.trace.propagation.textmap.TextMapPropagator.fields`
`opentelemetry.propagators.textmap.TextMapPropagator.fields`
"""
return {
self.TRACE_ID_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from opentelemetry.sdk.trace import Span, SpanProcessor
from opentelemetry.sdk.trace.export import SpanExporter
from opentelemetry.trace import INVALID_TRACE_ID
from opentelemetry.util.providers import time_ns
from opentelemetry.util.time import time_ns

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

from opentelemetry import trace as trace_api
from opentelemetry.exporter.datadog import constants, propagator
from opentelemetry.propagators.textmap import DictGetter
from opentelemetry.sdk import trace
from opentelemetry.sdk.trace.ids_generator import RandomIdsGenerator
from opentelemetry.sdk.trace.id_generator import RandomIdGenerator
from opentelemetry.trace import get_current_span, set_span_in_context
from opentelemetry.trace.propagation.textmap import DictGetter

FORMAT = propagator.DatadogFormat()

Expand All @@ -30,12 +30,12 @@
class TestDatadogFormat(unittest.TestCase):
@classmethod
def setUpClass(cls):
ids_generator = RandomIdsGenerator()
id_generator = RandomIdGenerator()
cls.serialized_trace_id = propagator.format_trace_id(
ids_generator.generate_trace_id()
id_generator.generate_trace_id()
)
cls.serialized_parent_id = propagator.format_span_id(
ids_generator.generate_span_id()
id_generator.generate_span_id()
)
cls.serialized_origin = "origin-service"

Expand Down Expand Up @@ -108,7 +108,7 @@ def test_context_propagation(self):
"child",
trace_api.SpanContext(
parent_span_context.trace_id,
RandomIdsGenerator().generate_span_id(),
RandomIdGenerator().generate_span_id(),
is_remote=False,
trace_flags=parent_span_context.trace_flags,
trace_state=parent_span_context.trace_state,
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_sampling_priority_auto_reject(self):
"child",
trace_api.SpanContext(
parent_span_context.trace_id,
RandomIdsGenerator().generate_span_id(),
RandomIdGenerator().generate_span_id(),
is_remote=False,
trace_flags=parent_span_context.trace_flags,
trace_state=parent_span_context.trace_state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ Example
from opentelemetry import trace
from opentelemetry.exporter import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor
_JAEGER_EXPORTER = jaeger.JaegerSpanExporter(
_JAEGER_EXPORTER = jaeger.JaegerExporter(
service_name="example-xxx",
agent_host_name="localhost",
agent_port=6831,
)
_TRACE_PROVIDER = TracerProvider()
_TRACE_PROVIDER.add_span_processor(BatchExportSpanProcessor(_JAEGER_EXPORTER))
_TRACE_PROVIDER.add_span_processor(BatchSpanProcessor(_JAEGER_EXPORTER))
trace.set_tracer_provider(_TRACE_PROVIDER)
AioHttpClientInstrumentor().instrument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
AioHttpClientInstrumentor,
)
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace.status import StatusCode
from opentelemetry.trace import StatusCode


def run_with_test_server(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
DatabaseApiIntegration,
)
from opentelemetry.trace import SpanKind
from opentelemetry.trace.status import Status, StatusCode


# pylint: disable=abstract-method
Expand Down Expand Up @@ -117,13 +116,7 @@ async def traced_execution(
name, kind=SpanKind.CLIENT
) as span:
self._populate_span(span, cursor, *args)
try:
result = await query_method(*args, **kwargs)
return result
except Exception as ex: # pylint: disable=broad-except
if span.is_recording():
span.set_status(Status(StatusCode.ERROR, str(ex)))
raise ex
return await query_method(*args, **kwargs)


def get_traced_cursor_proxy(cursor, db_api_integration, *args, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ def test_span_succeeded(self):
self.assertEqual(span.attributes["db.user"], "testuser")
self.assertEqual(span.attributes["net.peer.name"], "testhost")
self.assertEqual(span.attributes["net.peer.port"], 123)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.UNSET
)
self.assertIs(span.status.status_code, trace_api.StatusCode.UNSET)

def test_span_not_recording(self):
connection_props = {
Expand All @@ -289,8 +287,6 @@ def test_span_not_recording(self):
mock_span = mock.Mock()
mock_span.is_recording.return_value = False
mock_tracer.start_span.return_value = mock_span
mock_tracer.use_span.return_value.__enter__ = mock_span
mock_tracer.use_span.return_value.__exit__ = True
db_integration = AiopgIntegration(
mock_tracer, "testcomponent", connection_attributes
)
Expand Down Expand Up @@ -319,10 +315,8 @@ def test_span_failed(self):
self.assertEqual(len(spans_list), 1)
span = spans_list[0]
self.assertEqual(span.attributes["db.statement"], "Test query")
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR
)
self.assertEqual(span.status.description, "Test Exception")
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
self.assertEqual(span.status.description, "Exception: Test Exception")

def test_executemany(self):
db_integration = AiopgIntegration(self.tracer, "testcomponent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from opentelemetry.instrumentation.asgi.version import __version__ # noqa
from opentelemetry.instrumentation.utils import http_status_to_status_code
from opentelemetry.propagate import extract
from opentelemetry.trace.propagation.textmap import DictGetter
from opentelemetry.propagators.textmap import DictGetter
from opentelemetry.trace.status import Status, StatusCode


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def test_not_recording(self):
mock_span = Mock()
mock_span.is_recording.return_value = False
mock_tracer.start_span.return_value = mock_span
mock_tracer.use_span.return_value.__enter__ = mock_span
mock_tracer.use_span.return_value.__exit__ = True
with patch("opentelemetry.trace.get_tracer") as tracer:
tracer.return_value = mock_tracer
ec2 = boto.ec2.connect_to_region("us-west-2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ def test_not_recording(self):
mock_span = Mock()
mock_span.is_recording.return_value = False
mock_tracer.start_span.return_value = mock_span
mock_tracer.use_span.return_value.__enter__ = mock_span
mock_tracer.use_span.return_value.__exit__ = True
with patch("opentelemetry.trace.get_tracer") as tracer:
tracer.return_value = mock_tracer
ec2 = self.session.create_client("ec2", region_name="us-west-2")
Expand Down Expand Up @@ -138,7 +136,7 @@ def test_s3_client(self):
},
)
self.assertIs(
span.status.status_code, trace_api.status.StatusCode.ERROR,
span.status.status_code, trace_api.StatusCode.ERROR,
)

# Comment test for issue 1088
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Usage
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.instrumentation.celery import CeleryInstrumentor
from celery import Celery
Expand All @@ -40,7 +40,7 @@ Usage
@worker_process_init.connect(weak=False)
def init_celery_tracing(*args, **kwargs):
trace.set_tracer_provider(TracerProvider())
span_processor = BatchExportSpanProcessor(ConsoleSpanExporter())
span_processor = BatchSpanProcessor(ConsoleSpanExporter())
trace.get_tracer_provider().add_span_processor(span_processor)
CeleryInstrumentor().instrument()
Expand All @@ -58,7 +58,7 @@ Setting up tracing

When tracing a celery worker process, tracing and instrumention both must be initialized after the celery worker
process is initialized. This is required for any tracing components that might use threading to work correctly
such as the BatchExportSpanProcessor. Celery provides a signal called ``worker_process_init`` that can be used to
such as the BatchSpanProcessor. Celery provides a signal called ``worker_process_init`` that can be used to
accomplish this as shown in the example above.

References
Expand Down
Loading

0 comments on commit c3a260a

Please sign in to comment.