Skip to content

Commit 9b95dfa

Browse files
committed
Document the entry points better
1 parent 810ec49 commit 9b95dfa

File tree

2 files changed

+52
-10
lines changed
  • exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter
  • opentelemetry-sdk/src/opentelemetry/sdk/environment_variables

2 files changed

+52
-10
lines changed

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@
7777
OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE,
7878
OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY,
7979
OTEL_EXPORTER_OTLP_METRICS_COMPRESSION,
80-
OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER
8180
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT,
8281
OTEL_EXPORTER_OTLP_METRICS_HEADERS,
8382
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
8483
OTEL_EXPORTER_OTLP_TIMEOUT,
84+
OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER,
8585
)
8686
from opentelemetry.sdk.metrics._internal.aggregation import Aggregation
8787
from opentelemetry.sdk.metrics.export import ( # noqa: F401
@@ -163,7 +163,9 @@ def __init__(
163163
self._compression = compression or _compression_from_env()
164164
self._session = (
165165
session
166-
or _load_session_from_envvar(OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER)
166+
or _load_session_from_envvar(
167+
OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER
168+
)
167169
or requests.Session()
168170
)
169171
self._session.headers.update(self._headers)

opentelemetry-sdk/src/opentelemetry/sdk/environment_variables/__init__.py

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,35 +400,75 @@
400400
"""
401401
.. envvar:: OTEL_PYTHON_EXPORTER_OTLP_LOGS_CREDENTIAL_PROVIDER
402402
403-
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_LOGS_CREDENTIAL_PROVIDER` provides either `grpc.ChannelCredentials` for grpc OTLP Log exporters,
404-
or `request.Session` for HTTP Log exporters.
403+
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_LOGS_CREDENTIAL_PROVIDER` provides either `grpc.ChannelCredentials` for the grpc OTLP Log exporter,
404+
or `requests.Session` for the HTTP OTLP Log exporter. Entry point providers should implement the following functions:
405+
406+
.. code-block:: python
407+
import requests, grpc
408+
409+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
410+
def request_session_provder() -> requests.Session:
411+
412+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
413+
def channel_credential_provider() -> grpc.ChannelCredentials:
414+
405415
"""
406416
OTEL_PYTHON_EXPORTER_OTLP_CREDENTIAL_PROVIDER = (
407417
"OTEL_PYTHON_EXPORTER_OTLP_CREDENTIAL_PROVIDER"
408418
)
409419
"""
410420
.. envvar:: OTEL_PYTHON_EXPORTER_OTLP_CREDENTIAL_PROVIDER
411421
412-
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_CREDENTIAL_PROVIDER` provides either ChannelCredentials for all grpc OTLP exporters,
413-
or request.Session for HTTP exporters.
422+
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_CREDENTIAL_PROVIDER` provides either `grpc.ChannelCredentials` for all grpc OTLP exporters,
423+
or `requests.Session` for all HTTP OTLP exporters. Entry point providers should implement the following functions:
424+
425+
.. code-block:: python
426+
import requests, grpc
427+
428+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
429+
def request_session_provder() -> requests.Session:
430+
431+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
432+
def channel_credential_provider() -> grpc.ChannelCredentials:
433+
414434
"""
415435
OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER = (
416436
"OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER"
417437
)
418438
"""
419439
.. envvar:: OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER
420440
421-
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER` provides either ChannelCredentials for grpc OTLP Span exporters,
422-
or request.Session for HTTP Span exporters.
441+
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_TRACES_CREDENTIAL_PROVIDER` provides either `grpc.ChannelCredentials` for the grpc OTLP Span exporter,
442+
or `requests.Session` for the HTTP OTLP Span exporter. Entry point providers should implement the following functions:
443+
444+
.. code-block:: python
445+
import requests, grpc
446+
447+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
448+
def request_session_provder() -> requests.Session:
449+
450+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
451+
def channel_credential_provider() -> grpc.ChannelCredentials:
452+
423453
"""
424454
OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER = (
425455
"OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER"
426456
)
427457
"""
428458
.. envvar:: OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER
429459
430-
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER` provides either ChannelCredentials for grpc OTLP Metric exporters,
431-
or request.Session for HTTP Metric exporters.
460+
The :envvar:`OTEL_PYTHON_EXPORTER_OTLP_METRICS_CREDENTIAL_PROVIDER` provides either `grpc.ChannelCredentials` for the grpc OTLP Metric exporter,
461+
or `requests.Session` for the HTTP OTLP Log exporter. Entry point providers should implement the following functions:
462+
463+
.. code-block:: python
464+
import requests, grpc
465+
466+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
467+
def request_session_provder() -> requests.Session:
468+
469+
# Add a reference to this function under the `opentelemetry_otlp_credential_provider` entry point.
470+
def channel_credential_provider() -> grpc.ChannelCredentials:
471+
432472
"""
433473

434474
OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE = "OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE"

0 commit comments

Comments
 (0)