Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Auto instrumentation paramaters proposal
  • Loading branch information
jeremydvoss committed May 8, 2024
commit 89699617c486a23f01c3a10947a9f21ed076b0ff
14 changes: 14 additions & 0 deletions opentelemetry-distro/src/opentelemetry/distro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@ def _configure(self, **kwargs):
os.environ.setdefault(OTEL_TRACES_EXPORTER, "otlp")
os.environ.setdefault(OTEL_METRICS_EXPORTER, "otlp")
os.environ.setdefault(OTEL_EXPORTER_OTLP_PROTOCOL, "grpc")
# Since the distro sets these env vars, these params are not necesary.
# However they could replace these env var defaults.
# Otherwise, they just serve as an example.
configuration_kwargs = {
# Could be trace_exporters or span_exporters
"span_exporter_names": ("otlp"),
"metric_exporter_names": ("otlp"),
"log_exporter_names": ("otlp"),
"sampler_name": None,
# Could be attribute dict or Resource object
"resource_attributes": {},
# Could be string or bool
"logging_enabled": False,
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def _load_instrumentors(distro):
entry_point.load()()


def _load_configurators():
def _load_configurators(**configuration_kwargs):
configuration_kwargs["auto_instrumentation_version"] =__version__
configurator_name = environ.get(OTEL_PYTHON_CONFIGURATOR, None)
configured = None
for entry_point in iter_entry_points("opentelemetry_configurator"):
Expand All @@ -110,7 +111,7 @@ def _load_configurators():
configurator_name is None
or configurator_name == entry_point.name
):
entry_point.load()().configure(auto_instrumentation_version=__version__) # type: ignore
entry_point.load()().configure(**configuration_kwargs) # type: ignore
configured = entry_point.name
else:
_logger.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def initialize():

try:
distro = _load_distro()
distro.configure()
_load_configurators()
configuration_kwargs = distro.configure()
_load_configurators(**configuration_kwargs)
_load_instrumentors(distro)
except Exception: # pylint: disable=broad-except
logger.exception("Failed to auto initialize opentelemetry")
Expand Down