Skip to content

Commit

Permalink
Rename variables to add to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jan 29, 2021
1 parent 1cce236 commit e06d5fe
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from grpc import ChannelCredentials, ssl_channel_credentials

from opentelemetry.sdk.environment_variables import (
OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE,
OTEL_PYTHON_EXPORTER_JAEGER_INSECURE,
OTEL_EXPORTER_JAEGER_CERTIFICATE,
OTEL_EXPORTER_JAEGER_INSECURE,
)

logger = logging.getLogger(__name__)
Expand All @@ -30,7 +30,7 @@
def _get_insecure(param):
if param is not None:
return param
insecure_env = environ.get(OTEL_PYTHON_EXPORTER_JAEGER_INSECURE)
insecure_env = environ.get(OTEL_EXPORTER_JAEGER_INSECURE)
if insecure_env is not None:
return insecure_env.lower() == "true"
return DEFAULT_INSECURE
Expand All @@ -49,7 +49,7 @@ def _load_credential_from_file(path) -> ChannelCredentials:
def _get_credentials(param):
if param is not None:
return param
creds_env = environ.get(OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE)
creds_env = environ.get(OTEL_EXPORTER_JAEGER_CERTIFICATE)
if creds_env:
return _load_credential_from_file(creds_env)
return ssl_channel_credentials()
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
)
from opentelemetry.sdk import trace
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_JAEGER_CERTIFICATE,
OTEL_EXPORTER_JAEGER_ENDPOINT,
OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE,
)
from opentelemetry.sdk.trace import Resource
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
Expand Down Expand Up @@ -64,9 +64,7 @@ def test_constructor_by_environment_variables(self):
"os.environ",
{
OTEL_EXPORTER_JAEGER_ENDPOINT: collector_endpoint,
OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE: os.path.dirname(
__file__
)
OTEL_EXPORTER_JAEGER_CERTIFICATE: os.path.dirname(__file__)
+ "/certs/cred.cert",
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
OTEL_EXPORTER_OTLP_CERTIFICATE,
OTEL_EXPORTER_OTLP_ENDPOINT,
OTEL_EXPORTER_OTLP_HEADERS,
OTEL_EXPORTER_OTLP_INSECURE,
OTEL_EXPORTER_OTLP_TIMEOUT,
OTEL_PYTHON_EXPORTER_OTLP_INSECURE,
)
from opentelemetry.sdk.resources import Resource as SDKResource

Expand Down Expand Up @@ -171,7 +171,7 @@ def __init__(
)

if insecure is None:
insecure = environ.get(OTEL_PYTHON_EXPORTER_OTLP_INSECURE)
insecure = environ.get(OTEL_EXPORTER_OTLP_INSECURE)
if insecure is None:
insecure = False

Expand All @@ -195,7 +195,7 @@ def __init__(
):
compression_algorithm = Compression.Gzip
else:
compression_str = environ.get(OTEL_PYTHON_EXPORTER_OTLP_INSECURE)
compression_str = environ.get(OTEL_EXPORTER_OTLP_INSECURE)
if compression_str is None:
compression_algorithm = Compression.NoCompression
elif (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
OTEL_EXPORTER_OTLP_METRIC_CERTIFICATE,
OTEL_EXPORTER_OTLP_METRIC_ENDPOINT,
OTEL_EXPORTER_OTLP_METRIC_HEADERS,
OTEL_EXPORTER_OTLP_METRIC_INSECURE,
OTEL_EXPORTER_OTLP_METRIC_TIMEOUT,
OTEL_PYTHON_EXPORTER_OTLP_METRIC_INSECURE,
)
from opentelemetry.sdk.metrics import (
Counter,
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(
timeout: Optional[int] = None,
):
if insecure is None:
insecure = environ.get(OTEL_PYTHON_EXPORTER_OTLP_METRIC_INSECURE)
insecure = environ.get(OTEL_EXPORTER_OTLP_METRIC_INSECURE)

if (
not insecure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
OTEL_EXPORTER_OTLP_SPAN_CERTIFICATE,
OTEL_EXPORTER_OTLP_SPAN_ENDPOINT,
OTEL_EXPORTER_OTLP_SPAN_HEADERS,
OTEL_EXPORTER_OTLP_SPAN_INSECURE,
OTEL_EXPORTER_OTLP_SPAN_TIMEOUT,
OTEL_PYTHON_EXPORTER_OTLP_SPAN_INSECURE,
)
from opentelemetry.sdk.trace import Span as SDKSpan
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(
timeout: Optional[int] = None,
):
if insecure is None:
insecure = environ.get(OTEL_PYTHON_EXPORTER_OTLP_SPAN_INSECURE)
insecure = environ.get(OTEL_EXPORTER_OTLP_SPAN_INSECURE)

if (
not insecure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.. _Specification: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/sdk-environment-variables.md#zipkin-exporter
.. envvar:: OTEL_EXPORTER_ZIPKIN_ENDPOINT
.. envvar:: OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT
.. envvar:: OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT
.. code:: python
Expand Down Expand Up @@ -63,7 +63,7 @@
:envvar:`OTEL_EXPORTER_ZIPKIN_ENDPOINT`: target to which the exporter will
send data. This may include a path (e.g. http://example.com:9411/api/v2/spans).
:envvar:`OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT`: transport interchange format
:envvar:`OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT`: transport interchange format
to use when sending data. Currently only Zipkin's v2 json and protobuf formats
are supported, with v2 json being the default.
Expand All @@ -82,7 +82,7 @@
from opentelemetry.exporter.zipkin.gen import zipkin_pb2
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_ZIPKIN_ENDPOINT,
OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT,
OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT,
)
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
from opentelemetry.trace import Span, SpanContext, SpanKind
Expand Down Expand Up @@ -161,7 +161,7 @@ def __init__(

if transport_format is None:
self.transport_format = (
environ.get(OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT)
environ.get(OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT)
or TRANSPORT_FORMAT_JSON
)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from opentelemetry.sdk import trace
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_ZIPKIN_ENDPOINT,
OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT,
OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT,
)
from opentelemetry.sdk.trace import Resource
from opentelemetry.sdk.trace.export import SpanExportResult
Expand Down Expand Up @@ -63,15 +63,15 @@ def setUp(self):
def tearDown(self):
if OTEL_EXPORTER_ZIPKIN_ENDPOINT in os.environ:
del os.environ[OTEL_EXPORTER_ZIPKIN_ENDPOINT]
if OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT in os.environ:
del os.environ[OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT]
if OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT in os.environ:
del os.environ[OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT]

def test_constructor_env_var(self):
"""Test the default values assigned by constructor."""
url = "https://foo:9911/path"
os.environ[OTEL_EXPORTER_ZIPKIN_ENDPOINT] = url
os.environ[
OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT
OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT
] = TRANSPORT_FORMAT_PROTOBUF
service_name = "my-service-name"
port = 9911
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,9 @@
OTEL_EXPORTER_OTLP_METRIC_COMPRESSION = "OTEL_EXPORTER_OTLP_METRIC_COMPRESSION"
OTEL_EXPORTER_OTLP_SPAN_TIMEOUT = "OTEL_EXPORTER_OTLP_SPAN_TIMEOUT"
OTEL_EXPORTER_OTLP_METRIC_TIMEOUT = "OTEL_EXPORTER_OTLP_METRIC_TIMEOUT"
OTEL_PYTHON_EXPORTER_JAEGER_INSECURE = "OTEL_PYTHON_EXPORTER_JAEGER_INSECURE"
OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE = (
"OTEL_PYTHON_EXPORTER_JAEGER_CERTIFICATE"
)
OTEL_PYTHON_EXPORTER_OTLP_INSECURE = "OTEL_PYTHON_EXPORTER_OTLP_INSECURE"
OTEL_PYTHON_EXPORTER_OTLP_SPAN_INSECURE = (
"OTEL_PYTHON_EXPORTER_OTLP_SPAN_INSECURE"
)
OTEL_PYTHON_EXPORTER_OTLP_METRIC_INSECURE = (
"OTEL_PYTHON_EXPORTER_OTLP_METRIC_INSECURE"
)
OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT = (
"OTEL_PYTHON_EXPORTER_ZIPKIN_TRANSPORT_FORMAT"
)
OTEL_EXPORTER_JAEGER_INSECURE = "OTEL_EXPORTER_JAEGER_INSECURE"
OTEL_EXPORTER_JAEGER_CERTIFICATE = "OTEL_EXPORTER_JAEGER_CERTIFICATE"
OTEL_EXPORTER_OTLP_INSECURE = "OTEL_EXPORTER_OTLP_INSECURE"
OTEL_EXPORTER_OTLP_SPAN_INSECURE = "OTEL_EXPORTER_OTLP_SPAN_INSECURE"
OTEL_EXPORTER_OTLP_METRIC_INSECURE = "OTEL_EXPORTER_OTLP_METRIC_INSECURE"
OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT = "OTEL_EXPORTER_ZIPKIN_TRANSPORT_FORMAT"

0 comments on commit e06d5fe

Please sign in to comment.