Skip to content

Commit

Permalink
update args
Browse files Browse the repository at this point in the history
  • Loading branch information
vishaalram02 committed Nov 14, 2024
1 parent 6c3efd7 commit 4a7a13d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE,
OTEL_EXPORTER_OTLP_LOGS_CHANNEL_OPTIONS,
OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE,
OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY,
OTEL_EXPORTER_OTLP_LOGS_COMPRESSION,
Expand All @@ -58,6 +59,9 @@ def __init__(
headers: Optional[
Union[TypingSequence[Tuple[str, str]], Dict[str, str], str]
] = None,
channel_options: Optional[
Union[TypingSequence[Tuple[str, str]], str]
] = None,
timeout: Optional[int] = None,
compression: Optional[Compression] = None,
):
Expand Down Expand Up @@ -91,12 +95,17 @@ def __init__(

headers = headers or environ.get(OTEL_EXPORTER_OTLP_LOGS_HEADERS)

channel_options = channel_options or environ.get(
OTEL_EXPORTER_OTLP_LOGS_CHANNEL_OPTIONS
)

super().__init__(
**{
"endpoint": endpoint,
"insecure": insecure,
"credentials": credentials,
"headers": headers,
"channel_options": channel_options,
"timeout": timeout or environ_timeout,
"compression": compression,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class OTLPExporterMixin(
insecure: Connection type
credentials: ChannelCredentials object for server authentication
headers: Headers to send when exporting
channel_options: Options to pass to the gRPC channel
timeout: Backend request timeout in seconds
compression: gRPC compression method to use
"""
Expand All @@ -195,6 +196,9 @@ def __init__(
headers: Optional[
Union[TypingSequence[Tuple[str, str]], Dict[str, str], str]
] = None,
channel_options: Optional[
Union[TypingSequence[Tuple[str, str]], str]
] = None,
timeout: Optional[int] = None,
compression: Optional[Compression] = None,
):
Expand Down Expand Up @@ -243,11 +247,14 @@ def __init__(
else compression
) or Compression.NoCompression

options = None
channel_options = environ.get(OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS)
if channel_options:
options = []
for item in channel_options.split(","):
self._collector_kwargs = None

self._channel_options = channel_options or environ.get(
OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS
)
if isinstance(self._channel_options, str):
self._channel_options: List[Tuple[str, str]] = []
for item in self._channel_options.split(","):
try:
key, value = item.split("=", maxsplit=1)
except ValueError as exc:
Expand All @@ -257,12 +264,14 @@ def __init__(
exc,
)
continue
options.append((key, value))
self._channel_options.append((key, value))

if insecure:
self._client = self._stub(
insecure_channel(
self._endpoint, compression=compression, options=options
self._endpoint,
compression=compression,
options=self._channel_options,
)
)
else:
Expand All @@ -277,7 +286,7 @@ def __init__(
self._endpoint,
credentials,
compression=compression,
options=options,
options=self._channel_options,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from opentelemetry.proto.metrics.v1 import metrics_pb2 as pb2 # noqa: F401
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE,
OTEL_EXPORTER_OTLP_METRICS_CHANNEL_OPTIONS,
OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE,
OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY,
OTEL_EXPORTER_OTLP_METRICS_COMPRESSION,
Expand Down Expand Up @@ -98,6 +99,9 @@ def __init__(
headers: Optional[
Union[TypingSequence[Tuple[str, str]], Dict[str, str], str]
] = None,
channel_options: Optional[
Union[TypingSequence[Tuple[str, str]], str]
] = None,
timeout: Optional[int] = None,
compression: Optional[Compression] = None,
preferred_temporality: Dict[type, AggregationTemporality] = None,
Expand Down Expand Up @@ -142,6 +146,8 @@ def __init__(
insecure=insecure,
credentials=credentials,
headers=headers or environ.get(OTEL_EXPORTER_OTLP_METRICS_HEADERS),
channel_options=channel_options
or environ.get(OTEL_EXPORTER_OTLP_METRICS_CHANNEL_OPTIONS),
timeout=timeout or environ_timeout,
compression=compression,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
)
from opentelemetry.sdk.environment_variables import (
OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE,
OTEL_EXPORTER_OTLP_TRACES_CHANNEL_OPTIONS,
OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE,
OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY,
OTEL_EXPORTER_OTLP_TRACES_COMPRESSION,
Expand Down Expand Up @@ -76,6 +77,7 @@ class OTLPSpanExporter(
insecure: Connection type
credentials: Credentials object for server authentication
headers: Headers to send when exporting
channel_options: Options to pass to the gRPC channel
timeout: Backend request timeout in seconds
compression: gRPC compression method to use
"""
Expand All @@ -91,6 +93,9 @@ def __init__(
headers: Optional[
Union[TypingSequence[Tuple[str, str]], Dict[str, str], str]
] = None,
channel_options: Optional[
Union[TypingSequence[Tuple[str, str]], str]
] = None,
timeout: Optional[int] = None,
compression: Optional[Compression] = None,
):
Expand Down Expand Up @@ -129,6 +134,8 @@ def __init__(
"credentials": credentials,
"headers": headers
or environ.get(OTEL_EXPORTER_OTLP_TRACES_HEADERS),
"channel_options": channel_options
or environ.get(OTEL_EXPORTER_OTLP_TRACES_CHANNEL_OPTIONS),
"timeout": timeout or environ_timeout,
"compression": compression,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@
associated with gRPC or HTTP requests.
"""

OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS = "OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS"
"""
.. envvar:: OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS
The :envvar:`OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS` represents the channel options for the OTLP exporter.
"""

OTEL_EXPORTER_OTLP_COMPRESSION = "OTEL_EXPORTER_OTLP_COMPRESSION"
"""
Expand Down Expand Up @@ -347,13 +353,6 @@
Default: "http://localhost:4317"
"""

OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS = "OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS"
"""
.. envvar:: OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS
The :envvar:`OTEL_EXPORTER_OTLP_CHANNEL_OPTIONS` represents the channel options for the OTLP exporter.
"""

OTEL_EXPORTER_OTLP_INSECURE = "OTEL_EXPORTER_OTLP_INSECURE"
"""
.. envvar:: OTEL_EXPORTER_OTLP_INSECURE
Expand Down

0 comments on commit 4a7a13d

Please sign in to comment.