Skip to content

Commit

Permalink
Fixes lint and sort issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pridhi-arora committed Dec 5, 2022
1 parent b2db218 commit b43a36f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
OTLPLogExporter,
)
from opentelemetry.exporter.otlp.proto.grpc.version import __version__

from opentelemetry.exporter.otlp.proto.grpc.exporter import _translate_value
from opentelemetry.exporter.otlp.proto.grpc.version import __version__
from opentelemetry.proto.collector.logs.v1.logs_service_pb2 import (
ExportLogsServiceRequest,
ExportLogsServiceResponse,
Expand Down Expand Up @@ -253,7 +252,8 @@ def test_otlp_exporter_endpoint(self, mock_secure, mock_insecure):

def test_otlp_headers_from_env(self):
self.assertEqual(
self.exporter._headers, (("user-agent", "OTel OTLP Exporter Python/" + __version__),)
self.exporter._headers,
(("user-agent", "OTel OTLP Exporter Python/" + __version__),),
)

@patch("opentelemetry.exporter.otlp.proto.grpc.exporter._expo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (
OTLPMetricExporter,
)
from opentelemetry.exporter.otlp.proto.grpc.version import __version__
from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import (
ExportMetricsServiceRequest,
ExportMetricsServiceResponse,
Expand Down Expand Up @@ -78,9 +79,6 @@
)
from opentelemetry.test.metrictestutil import _generate_gauge, _generate_sum

from opentelemetry.exporter.otlp.proto.grpc.version import __version__


THIS_DIR = dirname(__file__)


Expand Down Expand Up @@ -416,14 +414,24 @@ def test_otlp_headers_from_env(self, mock_ssl_channel, mock_secure):
exporter = OTLPMetricExporter()
# pylint: disable=protected-access
self.assertEqual(
exporter._headers, (("key1", "value1"), ("key2", "VALUE=2"),("user-agent", "OTel OTLP Exporter Python/" + __version__))
exporter._headers,
(
("key1", "value1"),
("key2", "VALUE=2"),
("user-agent", "OTel OTLP Exporter Python/" + __version__),
),
)
exporter = OTLPMetricExporter(
headers=(("key3", "value3"), ("key4", "value4"))
)
# pylint: disable=protected-access
self.assertEqual(
exporter._headers, (("key3", "value3"), ("key4", "value4"),("user-agent", "OTel OTLP Exporter Python/" + __version__))
exporter._headers,
(
("key3", "value3"),
("key4", "value4"),
("user-agent", "OTel OTLP Exporter Python/" + __version__),
),
)

@patch.dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.exporter.otlp.proto.grpc.version import __version__
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import (
ExportTraceServiceRequest,
ExportTraceServiceResponse,
Expand Down Expand Up @@ -69,8 +70,6 @@
from opentelemetry.test.spantestutil import (
get_span_with_dropped_attributes_events_links,
)
from opentelemetry.exporter.otlp.proto.grpc.version import __version__


THIS_DIR = os.path.dirname(__file__)

Expand Down Expand Up @@ -277,21 +276,36 @@ def test_otlp_headers_from_env(self, mock_ssl_channel, mock_secure):
exporter = OTLPSpanExporter()
# pylint: disable=protected-access
self.assertEqual(
exporter._headers, (("key1", "value1"),("key2", "VALUE=2"), ("user-agent", "OTel OTLP Exporter Python/" + __version__))
exporter._headers,
(
("key1", "value1"),
("key2", "VALUE=2"),
("user-agent", "OTel OTLP Exporter Python/" + __version__),
),
)
exporter = OTLPSpanExporter(
headers=(("key3", "value3"), ("key4", "value4"))
)
# pylint: disable=protected-access
self.assertEqual(
exporter._headers, (("key3", "value3"), ("key4", "value4"), ("user-agent", "OTel OTLP Exporter Python/" + __version__))
exporter._headers,
(
("key3", "value3"),
("key4", "value4"),
("user-agent", "OTel OTLP Exporter Python/" + __version__),
),
)
exporter = OTLPSpanExporter(
headers={"key5": "value5", "key6": "value6"}
)
# pylint: disable=protected-access
self.assertEqual(
exporter._headers, (("key5", "value5"), ("key6", "value6"), ("user-agent", "OTel OTLP Exporter Python/" + __version__))
exporter._headers,
(
("key5", "value5"),
("key6", "value6"),
("user-agent", "OTel OTLP Exporter Python/" + __version__),
),
)

@patch.dict(
Expand Down Expand Up @@ -436,8 +450,11 @@ def test_otlp_exporter_otlp_compression_precendence(
def test_otlp_headers(self, mock_ssl_channel, mock_secure):
exporter = OTLPSpanExporter()
# pylint: disable=protected-access
#This ensures that there is no other header than standard user-agent.
self.assertEqual(exporter._headers, (("user-agent", "OTel OTLP Exporter Python/" + __version__),))
# This ensures that there is no other header than standard user-agent.
self.assertEqual(
exporter._headers,
(("user-agent", "OTel OTLP Exporter Python/" + __version__),),
)
@patch("opentelemetry.exporter.otlp.proto.grpc.exporter.backoff")
@patch("opentelemetry.exporter.otlp.proto.grpc.exporter.sleep")
def test_handles_backoff_v2_api(self, mock_sleep, mock_backoff):
Expand Down

0 comments on commit b43a36f

Please sign in to comment.