fead: add OpenTelemetry observability support for modular inputs#450
fead: add OpenTelemetry observability support for modular inputs#450wtobis-splunk wants to merge 10 commits intodevelopfrom
Conversation
solnlib/observability.py
Outdated
| @@ -0,0 +1,534 @@ | |||
| # | |||
| # Copyright 2025 Splunk Inc. | |||
There was a problem hiding this comment.
| # Copyright 2025 Splunk Inc. | |
| # Copyright 2026 Splunk Inc. |
There was a problem hiding this comment.
Done, updated to 2026.
solnlib/__init__.py
Outdated
| hec_config, | ||
| log, | ||
| net_utils, | ||
| observability, |
There was a problem hiding this comment.
I am thinking about this import. It means that observability will be imported even if it is not used.
I checked the otel modules and importing them takes around 0,5-0,6 sec.
It's just a note. If that's ok, then we can leave it.
There was a problem hiding this comment.
Good point — removed observability from __init__.py to avoid the ~0.5s import overhead for users who don't need it. Users should import directly via from solnlib.observability import ....
solnlib/observability.py
Outdated
| from opentelemetry.sdk.resources import Resource | ||
| from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter | ||
|
|
||
| _Logger: TypeAlias = Union[logging.Logger, logging.LoggerAdapter] |
There was a problem hiding this comment.
| _Logger: TypeAlias = Union[logging.Logger, logging.LoggerAdapter] | |
| _Logger = Union[logging.Logger, logging.LoggerAdapter] |
What about not adding a type to _Logger, in order to avoid typing_extensions? If we want to leave it, maybe we should add it as a dependency in pyproject.toml?
There was a problem hiding this comment.
Removed typing_extensions dependency and TypeAlias annotation — using plain _Logger = Union[...] instead.
…ity from __init__
Issue number
ADDON-85636
Summary
This PR introduces a new solnlib.observability module that adds an ObservabilityService for Splunk modular inputs and a LoggerMetricExporter for local/debug metric export. The service initializes standard event count and event byte counters, reads TA metadata from app.conf, attempts secure OTLP export to the local Spotlight collector with env/IPC-based port discovery, and degrades gracefully when observability is unavailable.
It also adds unit tests covering exporter behavior and OTLP setup/fallback paths, exports the new module through
solnlib.__init__, and updates project dependencies and MkDocs references so the new observability API is documented and packaged correctly, and formally drops Python 3.7 support from the package configuration.Testing