Skip to content

Commit

Permalink
Merge branch 'master' into grpc-streaming-bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
alertedsnake committed Jan 14, 2021
2 parents 863a003 + d12f67f commit a512254
Show file tree
Hide file tree
Showing 35 changed files with 254 additions and 63 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CodeQL Analysis

on:
workflow_dispatch:
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '30 1 * * *'

jobs:
CodeQL-Build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: python

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
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: master
CORE_REPO_SHA: 2b188b9a43dfaa74c1a0a4514b91d1cb07d3075d

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ __pycache__
venv*/
.venv*/
opentelemetry-python-core*/
/opentelemetry-python-core

# Installer logs
pip-log.txt
Expand Down
3 changes: 2 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=79
profile=black

; 3 stands for Vertical Hanging Indent, e.g.
; from third_party import (
Expand All @@ -13,6 +14,6 @@ line_length=79
; docs: https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output=3
skip=target
skip_glob=**/gen/*,.venv*/*,venv*/*,reference*/*,opentelemetry-python-core/*
skip_glob=**/gen/*,.venv*/*,venv*/*,reference*/*,opentelemetry-python-core/*,.tox/*
known_first_party=opentelemetry
known_third_party=psutil,pytest,redis,redis_opentracing
12 changes: 10 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ disable=missing-docstring,
wrong-import-order, # Leave this up to isort
bad-continuation, # Leave this up to black
line-too-long, # Leave this up to black
exec-used
exec-used,
super-with-arguments, # temp-pylint-upgrade
isinstance-second-argument-not-valid-type, # temp-pylint-upgrade
raise-missing-from, # temp-pylint-upgrade
unused-argument, # temp-pylint-upgrade
protected-access, # temp-pylint-upgrade
super-init-not-called, # temp-pylint-upgrade
invalid-overridden-method, # temp-pylint-upgrade
missing-module-docstring, # temp-pylint-upgrad, # temp-pylint-upgradee

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -165,7 +173,7 @@ contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=*_pb2.py
generated-members=types_pb2.*

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python-contrib/compare/v0.16b1...HEAD)

### Added
- `opentelemetry-instrumentation-sqlalchemy` Ensure spans have kind set to "CLIENT"
([#278](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/278))
- `opentelemetry-instrumentation-celery` Add support for Celery version 5.x
([#266](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/266))
- `opentelemetry-instrumentation-urllib` Add urllib instrumentation
Expand All @@ -33,6 +35,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#236](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/236))
- Add README and example app for Prometheus Remote Write Exporter
([#227](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/227]))
- `opentelemetry-instrumentation-botocore` Adds a field to report the number of retries it take to complete an API call
([#275](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/275))
- `opentelemetry-instrumentation-requests` Use instanceof to check if responses are valid Response objects
([#273](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/273))

### Changed
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-wsgi` Return `None` for `CarrierGetter` if key not found
Expand All @@ -47,6 +53,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#259](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/259))
- `opentelemetry-instrumentation-grpc` Fix issue tracking child spans in streaming responses
([#260](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/260))
- `opentelemetry-exporter-datadog` Fix unintentional type change of span trace flags
([#261](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/261))
- `opentelemetry-instrumentation-aiopg` Fix AttributeError `__aexit__` when `aiopg.connect` and `aio[g].create_pool` used with async context manager
([#235](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/235))
- `opentelemetry-exporter-datadog` `opentelemetry-sdk-extension-aws` Fix reference to ids_generator in sdk
([#235](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/235))

## [0.16b1](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b1) - 2020-11-26

Expand Down
7 changes: 4 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pylint==2.4.4
pylint~=2.6
flake8~=3.7
isort~=4.3
isort~=5.6
black>=19.3b0,==19.*
mypy==0.740
httpretty~=1.0
mypy==0.790
sphinx~=2.1
sphinx-rtd-theme~=0.4
sphinx-autodoc-typehints~=1.10.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
from ddtrace.span import Span as DatadogSpan

import opentelemetry.trace as trace_api
from opentelemetry.sdk.trace import sampling
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult

# pylint:disable=relative-beyond-top-level
from .constants import (
from opentelemetry.exporter.datadog.constants import (
DD_ORIGIN,
ENV_KEY,
SAMPLE_RATE_METRIC_KEY,
SERVICE_NAME_TAG,
VERSION_KEY,
)
from opentelemetry.sdk.trace import sampling
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult

logger = logging.getLogger(__name__)

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

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 (
Getter,
Expand All @@ -24,9 +25,6 @@
TextMapPropagatorT,
)

# pylint:disable=relative-beyond-top-level
from . import constants


class DatadogFormat(TextMapPropagator):
"""Propagator for the Datadog HTTP header format.
Expand Down Expand Up @@ -62,7 +60,7 @@ def extract(
constants.AUTO_KEEP,
constants.USER_KEEP,
):
trace_flags |= trace.TraceFlags.SAMPLED
trace_flags = trace.TraceFlags(trace.TraceFlags.SAMPLED)

if trace_id is None or span_id is None:
return set_span_in_context(trace.INVALID_SPAN, context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from opentelemetry import trace as trace_api
from opentelemetry.exporter.datadog import constants, propagator
from opentelemetry.sdk import trace
from opentelemetry.sdk.trace.ids_generator import RandomIdsGenerator
from opentelemetry.trace import get_current_span, set_span_in_context
from opentelemetry.trace.propagation.textmap import DictGetter

Expand All @@ -29,7 +30,7 @@
class TestDatadogFormat(unittest.TestCase):
@classmethod
def setUpClass(cls):
ids_generator = trace_api.RandomIdsGenerator()
ids_generator = RandomIdsGenerator()
cls.serialized_trace_id = propagator.format_trace_id(
ids_generator.generate_trace_id()
)
Expand Down Expand Up @@ -107,7 +108,7 @@ def test_context_propagation(self):
"child",
trace_api.SpanContext(
parent_span_context.trace_id,
trace_api.RandomIdsGenerator().generate_span_id(),
RandomIdsGenerator().generate_span_id(),
is_remote=False,
trace_flags=parent_span_context.trace_flags,
trace_state=parent_span_context.trace_state,
Expand Down Expand Up @@ -154,7 +155,7 @@ def test_sampling_priority_auto_reject(self):
"child",
trace_api.SpanContext(
parent_span_context.trace_id,
trace_api.RandomIdsGenerator().generate_span_id(),
RandomIdsGenerator().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 @@ -39,13 +39,12 @@ package_dir=
=src
packages=find_namespace:
install_requires =
snappy >= 2.8
protobuf >= 3.13.0
requests == 2.25.0
opentelemetry-api == 0.17.dev0
opentelemetry-sdk == 0.17.dev0
python-snappy >= 0.5.4
[options.packages.find]
where = src

[options.extras_require]
test =
[options.packages.find]
where = src
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _convert_from_quantile(
) -> Sequence[TimeSeries]:
raise NotImplementedError()

# pylint: disable=no-member
# pylint: disable=no-member,no-self-use
def _create_timeseries(
self,
export_record: ExportRecord,
Expand Down Expand Up @@ -317,6 +317,7 @@ def add_label(label_name: str, label_value: str):
timeseries.samples.append(sample)
return timeseries

# pylint: disable=no-member,no-self-use
def _build_message(self, timeseries: Sequence[TimeSeries]) -> bytes:
write_request = WriteRequest()
write_request.timeseries.extend(timeseries)
Expand Down Expand Up @@ -370,7 +371,7 @@ def _send_message(
)
if not response.ok:
response.raise_for_status()
except requests.exceptions.RequestException as e:
logger.error("Export POST request failed with reason: %s", e)
except requests.exceptions.RequestException as err:
logger.error("Export POST request failed with reason: %s", err)
return MetricsExportResult.FAILURE
return MetricsExportResult.SUCCESS
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
# limitations under the License.

import unittest
from logging import Logger
from unittest.mock import MagicMock, Mock, patch
from unittest.mock import patch

from opentelemetry.exporter.prometheus_remote_write import (
PrometheusRemoteWriteMetricsExporter,
)
from opentelemetry.exporter.prometheus_remote_write.gen.types_pb2 import (
Label,
Sample,
TimeSeries,
)
from opentelemetry.sdk.metrics import Counter
Expand Down Expand Up @@ -339,15 +337,17 @@ def create_label(name, value):
)

expected_timeseries = TimeSeries()
expected_timeseries.labels.append(create_label("__name__", "testname"))
expected_timeseries.labels.append(
expected_timeseries.labels.append( # pylint:disable=E1101
create_label("__name__", "testname")
)
expected_timeseries.labels.append( # pylint:disable=E1101
create_label("resource_name", "resource_value")
)
expected_timeseries.labels.append(
expected_timeseries.labels.append( # pylint:disable=E1101
create_label("record_name", "record_value")
)

sample = expected_timeseries.samples.add()
sample = expected_timeseries.samples.add() # pylint:disable=E1101
sample.timestamp = int(sum_aggregator.last_update_timestamp / 1000000)
sample.value = 5.0

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

import aiopg
import wrapt
from aiopg.utils import _ContextManager, _PoolContextManager

from opentelemetry.instrumentation.aiopg.aiopg_integration import (
AiopgIntegration,
Expand Down Expand Up @@ -99,7 +100,7 @@ def wrap_connect(
"""

# pylint: disable=unused-argument
async def wrap_connect_(
def wrap_connect_(
wrapped: typing.Callable[..., typing.Any],
instance: typing.Any,
args: typing.Tuple[typing.Any, typing.Any],
Expand All @@ -113,7 +114,9 @@ async def wrap_connect_(
version=version,
tracer_provider=tracer_provider,
)
return await db_integration.wrapped_connection(wrapped, args, kwargs)
return _ContextManager(
db_integration.wrapped_connection(wrapped, args, kwargs)
)

try:
wrapt.wrap_function_wrapper(aiopg, "connect", wrap_connect_)
Expand Down Expand Up @@ -191,7 +194,7 @@ def wrap_create_pool(
tracer_provider: typing.Optional[TracerProvider] = None,
):
# pylint: disable=unused-argument
async def wrap_create_pool_(
def wrap_create_pool_(
wrapped: typing.Callable[..., typing.Any],
instance: typing.Any,
args: typing.Tuple[typing.Any, typing.Any],
Expand All @@ -205,7 +208,9 @@ async def wrap_create_pool_(
version=version,
tracer_provider=tracer_provider,
)
return await db_integration.wrapped_pool(wrapped, args, kwargs)
return _PoolContextManager(
db_integration.wrapped_pool(wrapped, args, kwargs)
)

try:
wrapt.wrap_function_wrapper(aiopg, "create_pool", wrap_create_pool_)
Expand Down
Loading

0 comments on commit a512254

Please sign in to comment.