Skip to content

Commit

Permalink
Merge branch 'main' into grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
pridhi-arora authored Dec 4, 2022
2 parents b71fdbb + e4a4410 commit dbf0126
Show file tree
Hide file tree
Showing 63 changed files with 1,719 additions and 4,630 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
# skipping auto generated folders
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git
ignore-words-list = ans,ue,ot,hist,ro
16 changes: 12 additions & 4 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[flake8]
ignore =
E501 # line too long, defer to black
W503 # allow line breaks before binary ops
W504 # allow line breaks after binary ops
E203 # allow whitespace before ':' (https://github.com/psf/black#slices)
# line too long, defer to black
E501

# allow line breaks before binary ops
W503

# allow line breaks after binary ops
W504

# allow whitespace before ':' (https://github.com/psf/black#slices)
E203

exclude =
.bzr
.git
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tox-environment: [ "docker-tests", "lint", "spellcheck", "docs", "mypy", "mypyinstalled", "tracecontext" ]
tox-environment: [ "docker-tests-proto3", "docker-tests-proto4", "lint", "spellcheck", "docs", "mypy", "mypyinstalled", "tracecontext" ]
name: ${{ matrix.tox-environment }}
runs-on: ubuntu-20.04
steps:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Regenerate opentelemetry-proto to be compatible with protobuf 3 and 4
([#3070](https://github.com/open-telemetry/opentelemetry-python/pull/3070))
- Rename parse_headers to parse_env_headers and improve error message
([#2376](https://github.com/open-telemetry/opentelemetry-python/pull/2376))
- Add url decode values from OTEL_RESOURCE_ATTRIBUTES
([#3046](https://github.com/open-telemetry/opentelemetry-python/pull/3046))
- Fixed circular dependency issue with custom samplers
([#3026](https://github.com/open-telemetry/opentelemetry-python/pull/3026))
- Add missing entry points for OTLP/HTTP exporter
([#3027](https://github.com/open-telemetry/opentelemetry-python/pull/3027))
- Update logging to include logging api as per specification
([#3038](https://github.com/open-telemetry/opentelemetry-python/pull/3038))
- Fix: Avoid generator in metrics _ViewInstrumentMatch.collect()
([#3035](https://github.com/open-telemetry/opentelemetry-python/pull/3035)
- [exporter-otlp-proto-grpc] add user agent string
Expand Down
7 changes: 5 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ sphinx-autodoc-typehints~=1.12.0
pytest==7.1.3
pytest-cov>=2.8
readme-renderer~=24.0
grpcio-tools~=1.41.0
# This version of grpcio-tools ships with protoc 3.19.4 which appears to be compatible with
# both protobuf 3.19.x and 4.x (see https://github.com/protocolbuffers/protobuf/issues/11123).
# Bump this version with caution to preserve compatibility with protobuf 3.
# https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-proto/pyproject.toml#L28
grpcio-tools==1.48.1
mypy-protobuf~=3.0.0
protobuf~=3.18.1
# temporary fix. we should update the jinja, flask deps
# See https://github.com/pallets/markupsafe/issues/282
# breaking change introduced in markupsafe causes jinja, flask to break
Expand Down
4 changes: 4 additions & 0 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ wrapt>=1.0.0,<2.0.0
# See https://github.com/pallets/markupsafe/issues/282
# breaking change introduced in markupsafe causes jinja, flask to break
markupsafe==2.0.1

# Jaeger generated protobufs do not currently support protobuf 4.x. This can be removed once
# they're regenerated.
protobuf~=3.19
14 changes: 14 additions & 0 deletions docs/api/_logs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
opentelemetry._logs package
=============================

Submodules
----------

.. toctree::

_logs.severity

Module contents
---------------

.. automodule:: opentelemetry._logs
4 changes: 4 additions & 0 deletions docs/api/_logs.severity.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
opentelemetry._logs.severity
============================

.. automodule:: opentelemetry._logs.severity
1 change: 1 addition & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ OpenTelemetry Python API
.. toctree::
:maxdepth: 1

_logs
baggage
context
propagate
Expand Down
7 changes: 7 additions & 0 deletions docs/sdk/_logs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.sdk._logs package
===============================

.. automodule:: opentelemetry.sdk._logs
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/sdk/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ OpenTelemetry Python SDK
.. toctree::
:maxdepth: 1

_logs
resources
trace
metrics
logs
error_handler
environment_variables
7 changes: 0 additions & 7 deletions docs/sdk/logs.export.rst

This file was deleted.

22 changes: 0 additions & 22 deletions docs/sdk/logs.rst

This file was deleted.

7 changes: 0 additions & 7 deletions docs/sdk/logs.severity.rst

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
OTEL_EXPORTER_OTLP_TIMEOUT,
)
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.util.re import parse_headers
from opentelemetry.sdk.metrics.export import MetricsData
from opentelemetry.exporter.otlp.proto.grpc import (
_OTLP_GRPC_HEADERS,
)
from opentelemetry.util.re import parse_env_headers

logger = getLogger(__name__)
SDKDataT = TypeVar("SDKDataT")
Expand Down Expand Up @@ -250,7 +250,7 @@ def __init__(

self._headers = headers or environ.get(OTEL_EXPORTER_OTLP_HEADERS)
if isinstance(self._headers, str):
temp_headers = parse_headers(self._headers)
temp_headers = parse_env_headers(self._headers)
self._headers = tuple(temp_headers.items())
elif isinstance(self._headers, dict):
self._headers = tuple(self._headers.items())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from google.rpc.error_details_pb2 import RetryInfo
from grpc import StatusCode, server

from opentelemetry._logs import SeverityNumber
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
OTLPLogExporter,
)
Expand All @@ -46,9 +47,6 @@
)
from opentelemetry.sdk._logs import LogData, LogRecord
from opentelemetry.sdk._logs.export import LogExportResult
from opentelemetry.sdk._logs.severity import (
SeverityNumber as SDKSeverityNumber,
)
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
from opentelemetry.trace import TraceFlags
Expand Down Expand Up @@ -118,7 +116,7 @@ def setUp(self):
span_id=5213367945872657620,
trace_flags=TraceFlags(0x01),
severity_text="WARNING",
severity_number=SDKSeverityNumber.WARN,
severity_number=SeverityNumber.WARN,
body="Zhengzhou, We have a heaviest rains in 1000 years",
resource=SDKResource({"key": "value"}),
attributes={"a": 1, "b": "c"},
Expand All @@ -134,7 +132,7 @@ def setUp(self):
span_id=5213367945872657623,
trace_flags=TraceFlags(0x01),
severity_text="INFO",
severity_number=SDKSeverityNumber.INFO2,
severity_number=SeverityNumber.INFO2,
body="Sydney, Opera House is closed",
resource=SDKResource({"key": "value"}),
attributes={"custom_attr": [1, 2, 3]},
Expand All @@ -150,7 +148,7 @@ def setUp(self):
span_id=5213367945872657628,
trace_flags=TraceFlags(0x01),
severity_text="ERROR",
severity_number=SDKSeverityNumber.WARN,
severity_number=SeverityNumber.WARN,
body="Mumbai, Boil water before drinking",
resource=SDKResource({"service": "myapp"}),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
OTEL_EXPORTER_OTLP_HEADERS,
OTEL_EXPORTER_OTLP_TIMEOUT,
)
from opentelemetry.sdk._logs import LogData
from opentelemetry.sdk._logs.export import (
LogExporter,
LogExportResult,
LogData,
)
from opentelemetry.exporter.otlp.proto.http import (
_OTLP_HTTP_HEADERS,
Expand All @@ -42,7 +42,7 @@
from opentelemetry.exporter.otlp.proto.http._log_exporter.encoder import (
_ProtobufEncoder,
)
from opentelemetry.util.re import parse_headers
from opentelemetry.util.re import parse_env_headers


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(
OTEL_EXPORTER_OTLP_CERTIFICATE, True
)
headers_string = environ.get(OTEL_EXPORTER_OTLP_HEADERS, "")
self._headers = headers or parse_headers(headers_string)
self._headers = headers or parse_env_headers(headers_string)
self._timeout = timeout or int(
environ.get(OTEL_EXPORTER_OTLP_TIMEOUT, DEFAULT_TIMEOUT)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)


from opentelemetry.sdk._logs.export import LogData
from opentelemetry.sdk._logs import LogData


class _ProtobufEncoder:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
Sum,
)
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.util.re import parse_headers
from opentelemetry.util.re import parse_env_headers

import backoff
import requests
Expand Down Expand Up @@ -119,7 +119,7 @@ def __init__(
OTEL_EXPORTER_OTLP_METRICS_HEADERS,
environ.get(OTEL_EXPORTER_OTLP_HEADERS, ""),
)
self._headers = headers or parse_headers(headers_string)
self._headers = headers or parse_env_headers(headers_string)
self._timeout = timeout or int(
environ.get(
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from opentelemetry.exporter.otlp.proto.http.trace_exporter.encoder import (
_ProtobufEncoder,
)
from opentelemetry.util.re import parse_headers
from opentelemetry.util.re import parse_env_headers


_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(
OTEL_EXPORTER_OTLP_TRACES_HEADERS,
environ.get(OTEL_EXPORTER_OTLP_HEADERS, ""),
)
self._headers = headers or parse_headers(headers_string)
self._headers = headers or parse_env_headers(headers_string)
self._timeout = timeout or int(
environ.get(
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ def test_headers_parse_from_env(self):

self.assertEqual(
cm.records[0].message,
"Header doesn't match the format: missingValue.",
(
"Header format invalid! Header values in environment "
"variables must be URL encoded per the OpenTelemetry "
"Protocol Exporter specification: missingValue"
),
)

@patch.object(requests.Session, "post")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import requests
import responses

from opentelemetry._logs import SeverityNumber
from opentelemetry.exporter.otlp.proto.http import Compression
from opentelemetry.exporter.otlp.proto.http._log_exporter import (
DEFAULT_COMPRESSION,
Expand Down Expand Up @@ -54,7 +55,6 @@
)
from opentelemetry.sdk._logs import LogData
from opentelemetry.sdk._logs import LogRecord as SDKLogRecord
from opentelemetry.sdk._logs.severity import SeverityNumber
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_CERTIFICATE,
OTEL_EXPORTER_OTLP_COMPRESSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ def test_headers_parse_from_env(self):

self.assertEqual(
cm.records[0].message,
"Header doesn't match the format: missingValue.",
(
"Header format invalid! Header values in environment "
"variables must be URL encoded per the OpenTelemetry "
"Protocol Exporter specification: missingValue"
),
)

# pylint: disable=no-self-use
Expand Down
Loading

0 comments on commit dbf0126

Please sign in to comment.