Skip to content

Commit

Permalink
Merge branch 'main' into django-asgi
Browse files Browse the repository at this point in the history
  • Loading branch information
owais authored Sep 8, 2021
2 parents beaeb17 + 984f5cd commit 6b30587
Show file tree
Hide file tree
Showing 46 changed files with 294 additions and 187 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[flake8]
ignore =
E501 # line too long, defer to black
F401 # unused import, defer to pylint
W503 # allow line breaks before binary ops
W504 # allow line breaks after binary ops
E203 # allow whitespace before ':' (https://github.com/psf/black#slices)
Expand Down
4 changes: 4 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
components:

sdk-extension/opentelemetry-sdk-extension-aws:
- NathanielRN
14 changes: 14 additions & 0 deletions .github/workflows/component-owners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This action assigns and requires approval from owners of components for
# PRs that are open against those components. Components are defined as
# individual paths within this repository.
name: 'Component Owners'

on:
pull_request_target:

jobs:
run_self:
runs-on: ubuntu-latest
name: Auto Assign Owners
steps:
- uses: dyladan/component-owners@main
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: 3e1c89bcae77c34b9750a1f00608a04a97921c51
CORE_REPO_SHA: c49ad57bfe35cfc69bfa863d74058ca9bec55fc3

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

import itertools
import logging
import sys
import time
import unittest
from unittest import mock

from ddtrace.internal.writer import AgentWriter
from flaky import flaky
from pytest import mark

from opentelemetry import trace as trace_api
from opentelemetry.context import Context
Expand Down Expand Up @@ -469,6 +471,9 @@ def test_span_processor_dropped_spans(self):
self.assertEqual(len(datadog_spans), 128)
tracer_provider.shutdown()

@mark.skipif(
sys.platform == "win32", reason="unreliable test on windows",
)
def test_span_processor_scheduled_delay(self):
"""Test that spans are exported each schedule_delay_millis"""
delay = 300
Expand Down
36 changes: 36 additions & 0 deletions instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

| Instrumentation | Supported Packages |
| --------------- | ------------------ |
| [opentelemetry-instrumentation-aiohttp-client](./opentelemetry-instrumentation-aiohttp-client) | aiohttp ~= 3.0 |
| [opentelemetry-instrumentation-aiopg](./opentelemetry-instrumentation-aiopg) | aiopg >= 0.13.0, < 1.3.0 |
| [opentelemetry-instrumentation-asgi](./opentelemetry-instrumentation-asgi) | asgiref ~= 3.0 |
| [opentelemetry-instrumentation-asyncpg](./opentelemetry-instrumentation-asyncpg) | asyncpg >= 0.12.0 |
| [opentelemetry-instrumentation-boto](./opentelemetry-instrumentation-boto) | boto~=2.0 |
| [opentelemetry-instrumentation-botocore](./opentelemetry-instrumentation-botocore) | botocore ~= 1.0 |
| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 |
| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi |
| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 |
| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 2.0 |
| [opentelemetry-instrumentation-falcon](./opentelemetry-instrumentation-falcon) | falcon ~= 2.0 |
| [opentelemetry-instrumentation-fastapi](./opentelemetry-instrumentation-fastapi) | fastapi ~= 0.58 |
| [opentelemetry-instrumentation-flask](./opentelemetry-instrumentation-flask) | flask >= 1.0, < 3.0 |
| [opentelemetry-instrumentation-grpc](./opentelemetry-instrumentation-grpc) | grpcio ~= 1.27 |
| [opentelemetry-instrumentation-httpx](./opentelemetry-instrumentation-httpx) | httpx >= 0.18.0, < 0.19.0 |
| [opentelemetry-instrumentation-jinja2](./opentelemetry-instrumentation-jinja2) | jinja2~=2.7 |
| [opentelemetry-instrumentation-logging](./opentelemetry-instrumentation-logging) | logging |
| [opentelemetry-instrumentation-mysql](./opentelemetry-instrumentation-mysql) | mysql-connector-python ~= 8.0 |
| [opentelemetry-instrumentation-psycopg2](./opentelemetry-instrumentation-psycopg2) | psycopg2 >= 2.7.3.1 |
| [opentelemetry-instrumentation-pymemcache](./opentelemetry-instrumentation-pymemcache) | pymemcache ~= 1.3 |
| [opentelemetry-instrumentation-pymongo](./opentelemetry-instrumentation-pymongo) | pymongo ~= 3.1 |
| [opentelemetry-instrumentation-pymysql](./opentelemetry-instrumentation-pymysql) | PyMySQL ~= 0.10.1 |
| [opentelemetry-instrumentation-pyramid](./opentelemetry-instrumentation-pyramid) | pyramid >= 1.7 |
| [opentelemetry-instrumentation-redis](./opentelemetry-instrumentation-redis) | redis >= 2.6 |
| [opentelemetry-instrumentation-requests](./opentelemetry-instrumentation-requests) | requests ~= 2.0 |
| [opentelemetry-instrumentation-sklearn](./opentelemetry-instrumentation-sklearn) | scikit-learn ~= 0.24.0 |
| [opentelemetry-instrumentation-sqlalchemy](./opentelemetry-instrumentation-sqlalchemy) | sqlalchemy |
| [opentelemetry-instrumentation-sqlite3](./opentelemetry-instrumentation-sqlite3) | sqlite3 |
| [opentelemetry-instrumentation-starlette](./opentelemetry-instrumentation-starlette) | starlette ~= 0.13.0 |
| [opentelemetry-instrumentation-tornado](./opentelemetry-instrumentation-tornado) | tornado >= 6.0 |
| [opentelemetry-instrumentation-urllib](./opentelemetry-instrumentation-urllib) | urllib |
| [opentelemetry-instrumentation-urllib3](./opentelemetry-instrumentation-urllib3) | urllib3 >= 1.0.0, < 2.0.0 |
| [opentelemetry-instrumentation-wsgi](./opentelemetry-instrumentation-wsgi) | wsgi |
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_instrumentor_connect(self):
span = spans_list[0]

# Check version and name in span's instrumentation info
self.check_span_instrumentation_info(
self.assertEqualSpanInstrumentationInfo(
span, opentelemetry.instrumentation.aiopg
)

Expand Down Expand Up @@ -97,7 +97,7 @@ async def _ctx_manager_connect():
span = spans_list[0]

# Check version and name in span's instrumentation info
self.check_span_instrumentation_info(
self.assertEqualSpanInstrumentationInfo(
span, opentelemetry.instrumentation.aiopg
)

Expand All @@ -118,7 +118,7 @@ def test_instrumentor_create_pool(self):
span = spans_list[0]

# Check version and name in span's instrumentation info
self.check_span_instrumentation_info(
self.assertEqualSpanInstrumentationInfo(
span, opentelemetry.instrumentation.aiopg
)

Expand Down Expand Up @@ -149,7 +149,7 @@ async def _ctx_manager_pool():
span = spans_list[0]

# Check version and name in span's instrumentation info
self.check_span_instrumentation_info(
self.assertEqualSpanInstrumentationInfo(
span, opentelemetry.instrumentation.aiopg
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import asyncpg
import wrapt
from asyncpg import exceptions

from opentelemetry import trace
from opentelemetry.instrumentation.asyncpg.package import _instruments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
from opentelemetry.instrumentation.boto.version import __version__
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.sdk.trace import Resource
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, get_tracer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import io
import json
import sys
import zipfile
from unittest.mock import Mock, patch

Expand All @@ -30,6 +31,7 @@
mock_sts,
mock_xray,
)
from pytest import mark

from opentelemetry import trace as trace_api
from opentelemetry.context import attach, detach, set_value
Expand Down Expand Up @@ -128,12 +130,13 @@ def test_s3_client(self):
s3.list_buckets()
s3.list_buckets()

spans = self.memory_exporter.get_finished_spans()
spans = self.get_finished_spans()
assert spans
span = spans[0]
self.assertEqual(len(spans), 2)
self.assertEqual(
span.attributes,

buckets_span = spans.by_attr("aws.operation", "ListBuckets")
self.assertSpanHasAttributes(
buckets_span,
{
"aws.operation": "ListBuckets",
"aws.region": "us-west-2",
Expand All @@ -144,22 +147,21 @@ def test_s3_client(self):
)

# testing for span error
self.memory_exporter.get_finished_spans()
with self.assertRaises(ParamValidationError):
s3.list_objects(bucket="mybucket")
spans = self.memory_exporter.get_finished_spans()
spans = self.get_finished_spans()
assert spans
span = spans[2]
self.assertEqual(
span.attributes,
objects_span = spans.by_attr("aws.operation", "ListObjects")
self.assertSpanHasAttributes(
objects_span,
{
"aws.operation": "ListObjects",
"aws.region": "us-west-2",
"aws.service": "s3",
},
)
self.assertIs(
span.status.status_code, trace_api.StatusCode.ERROR,
objects_span.status.status_code, trace_api.StatusCode.ERROR,
)

# Comment test for issue 1088
Expand All @@ -172,12 +174,13 @@ def test_s3_put(self):
s3.put_object(**params)
s3.get_object(Bucket="mybucket", Key="foo")

spans = self.memory_exporter.get_finished_spans()
spans = self.get_finished_spans()
assert spans
self.assertEqual(len(spans), 3)
create_bucket_attributes = spans[0].attributes
self.assertEqual(
create_bucket_attributes,

create_span = spans.by_attr("aws.operation", "CreateBucket")
self.assertSpanHasAttributes(
create_span,
{
"aws.operation": "CreateBucket",
"aws.region": "us-west-2",
Expand All @@ -186,9 +189,10 @@ def test_s3_put(self):
SpanAttributes.HTTP_STATUS_CODE: 200,
},
)
put_object_attributes = spans[1].attributes
self.assertEqual(
put_object_attributes,

put_span = spans.by_attr("aws.operation", "PutObject")
self.assertSpanHasAttributes(
put_span,
{
"aws.operation": "PutObject",
"aws.region": "us-west-2",
Expand All @@ -197,10 +201,12 @@ def test_s3_put(self):
SpanAttributes.HTTP_STATUS_CODE: 200,
},
)
self.assertTrue("params.Body" not in spans[1].attributes.keys())
get_object_attributes = spans[2].attributes
self.assertEqual(
get_object_attributes,
self.assertTrue("params.Body" not in put_span.attributes.keys())

get_span = spans.by_attr("aws.operation", "GetObject")

self.assertSpanHasAttributes(
get_span,
{
"aws.operation": "GetObject",
"aws.region": "us-west-2",
Expand Down Expand Up @@ -359,6 +365,10 @@ def get_role_name(self):
Path="/my-path/",
)["Role"]["Arn"]

@mark.skipif(
sys.platform == "win32",
reason="requires docker and Github CI Windows does not have docker installed by default",
)
@mock_lambda
def test_lambda_invoke_propagation(self):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_task(self):

self.assertEqual(consumer.name, "run/tests.celery_test_tasks.task_add")
self.assertEqual(consumer.kind, SpanKind.CONSUMER)
self.assert_span_has_attributes(
self.assertSpanHasAttributes(
consumer,
{
"celery.action": "run",
Expand All @@ -64,7 +64,7 @@ def test_task(self):
producer.name, "apply_async/tests.celery_test_tasks.task_add"
)
self.assertEqual(producer.kind, SpanKind.PRODUCER)
self.assert_span_has_attributes(
self.assertSpanHasAttributes(
producer,
{
"celery.action": "apply_async",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
from opentelemetry.trace.status import Status, StatusCode

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from django.http import HttpRequest, HttpResponse

from opentelemetry.context import attach, detach
from opentelemetry.instrumentation.django.version import __version__
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import SpanKind, get_tracer
from opentelemetry.trace.status import Status, StatusCode

logger = getLogger(__name__)

Expand Down
Loading

0 comments on commit 6b30587

Please sign in to comment.