Skip to content

Commit 73ea341

Browse files
chore: merge develop into main (#453)
2 parents b038426 + bd058ef commit 73ea341

42 files changed

Lines changed: 2190 additions & 672 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-test-release.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
pull_request:
1111
branches: [main, develop]
1212

13+
env:
14+
PYTHON_VERSION: "3.9"
15+
POETRY_VERSION: "2.1.2"
16+
1317
jobs:
1418
meta:
1519
runs-on: ubuntu-latest
@@ -55,7 +59,7 @@ jobs:
5559
- uses: actions/checkout@v4
5660
- uses: actions/setup-python@v5
5761
with:
58-
python-version: "3.7"
62+
python-version: ${{ env.PYTHON_VERSION }}
5963
- uses: pre-commit/action@v3.0.1
6064

6165
semgrep:
@@ -71,8 +75,6 @@ jobs:
7175
strategy:
7276
matrix:
7377
python-version:
74-
- "3.7"
75-
- "3.8"
7678
- "3.9"
7779
- "3.10"
7880
- "3.11"
@@ -83,7 +85,7 @@ jobs:
8385
- uses: actions/setup-python@v5
8486
with:
8587
python-version: ${{ matrix.python-version }}
86-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
88+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
8789
- run: |
8890
poetry install
8991
poetry run pytest tests/unit
@@ -100,8 +102,8 @@ jobs:
100102
- uses: actions/checkout@v4
101103
- uses: actions/setup-python@v5
102104
with:
103-
python-version: 3.7
104-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
105+
python-version: ${{ env.PYTHON_VERSION }}
106+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
105107
- name: Install Splunk
106108
run: |
107109
export SPLUNK_PRODUCT=splunk
@@ -135,7 +137,7 @@ jobs:
135137
echo -e "[user_info]\nUSERNAME=Admin\nPASSWORD=Chang3d"'!' | tee -a $SPLUNK_HOME/etc/system/local/user-seed.conf
136138
echo 'OPTIMISTIC_ABOUT_FILE_LOCKING=1' | tee -a $SPLUNK_HOME/etc/splunk-launch.conf
137139
$SPLUNK_HOME/bin/splunk start --accept-license
138-
$SPLUNK_HOME/bin/splunk cmd python -m pip install solnlib
140+
$SPLUNK_HOME/bin/splunk cmd python -m pip install .
139141
$SPLUNK_HOME/bin/splunk set servername custom-servername -auth admin:Chang3d!
140142
$SPLUNK_HOME/bin/splunk restart
141143
until curl -k -s -u admin:Chang3d! https://localhost:8089/services/server/info\?output_mode\=json | jq '.entry[0].content.kvStoreStatus' | grep -o "ready" ; do echo -n "Waiting for KVStore to become ready-" && sleep 5 ; done
@@ -167,8 +169,8 @@ jobs:
167169
persist-credentials: false
168170
- uses: actions/setup-python@v5
169171
with:
170-
python-version: "3.7"
171-
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
172+
python-version: ${{ env.PYTHON_VERSION }}
173+
- run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
172174
- run: |
173175
poetry install
174176
poetry build

.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ header:
1717
license:
1818
spdx-id: Apache-2.0
1919
copyright-owner: Splunk Inc.
20+
pattern: "Copyright \\d{4} Splunk Inc"
2021

2122
paths-ignore:
2223
- ".github/"

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ repos:
33
rev: v3.1.0
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py39-plus]
77
- repo: https://github.com/psf/black
88
rev: 22.10.0
99
hooks:
1010
- id: black
11-
- repo: https://github.com/myint/docformatter
12-
rev: v1.5.0
11+
- repo: https://github.com/PyCQA/docformatter
12+
rev: v1.7.7
1313
hooks:
1414
- id: docformatter
15-
args: [--in-place]
15+
args: [--in-place, --wrap-summaries, "0", --wrap-descriptions, "0"]
16+
language_version: python3
1617
- repo: https://github.com/PyCQA/flake8
1718
rev: 5.0.4
1819
hooks:

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Splunk Solutions SDK is an open source packaged solution for getting data into S
44
This SDK is used by Splunk Add-on builder, and Splunk UCC based add-ons and is intended for use by partner
55
developers. This SDK/Library extends the Splunk SDK for Python.
66

7-
> Note: this project uses `poetry` 1.5.1.
7+
> Note: this project uses `poetry` 2.1.2.

docs/observability.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# observability.py
2+
3+
::: solnlib.observability

docs/release_8_0_0.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Release 8.0.0
2+
3+
## Breaking changes
4+
5+
### Python 3.7 and 3.8 are no longer supported
6+
7+
As of version 8.0.0, Python 3.7 and 3.8 are no longer supported.
8+
The minimum required Python version is now **3.9**.
9+
10+
If your add-on runs on Python 3.7 or 3.8, you must upgrade your environment
11+
before upgrading solnlib to 8.0.0.
12+
13+
### New required dependencies
14+
15+
The `observability` module introduces the following new dependencies:
16+
17+
* `opentelemetry-api >=1.39.1,<2`
18+
* `opentelemetry-sdk >=1.39.1,<2`
19+
* `opentelemetry-exporter-otlp-proto-grpc >=1.39.1,<2`
20+
* `grpcio >=1.74.0`
21+
22+
These are installed automatically when installing solnlib via pip.
23+
24+
## New features
25+
26+
### ObservabilityService
27+
28+
A new `solnlib.observability` module has been added. It provides OpenTelemetry
29+
metric instrumentation for Splunk modular inputs, with automatic integration
30+
with the Splunk Spotlight collector.
31+
32+
The module exposes two public components:
33+
34+
* `ObservabilityService` — initializes a `MeterProvider` with two built-in
35+
event counters and attempts to connect to the local Spotlight OTLP collector.
36+
Falls back silently when the collector is not available, so observability
37+
failures never break the add-on.
38+
* `LoggerMetricExporter` — an OpenTelemetry `MetricExporter` that writes
39+
data points to a Python logger. Useful for local development and debugging.
40+
41+
**Built-in counters:**
42+
43+
| Attribute | Metric name | Unit |
44+
|-------------------------|-------------------------------|-------|
45+
| `event_count_counter` | `splunk.addon.events` | `1` |
46+
| `event_bytes_counter` | `splunk.addon.events.bytes` | `By` |
47+
48+
**Example usage:**
49+
50+
```python
51+
import logging
52+
from solnlib.observability import ObservabilityService, ATTR_MODINPUT_NAME
53+
54+
logger = logging.getLogger(__name__)
55+
56+
obs = ObservabilityService(
57+
modinput_type="my-input",
58+
logger=logger,
59+
ta_name="my_ta",
60+
ta_version="1.0.0",
61+
)
62+
63+
# In your event collection loop:
64+
if obs.event_count_counter:
65+
obs.event_count_counter.add(len(events), {ATTR_MODINPUT_NAME: stanza_name})
66+
if obs.event_bytes_counter:
67+
obs.event_bytes_counter.add(total_bytes, {ATTR_MODINPUT_NAME: stanza_name})
68+
```
69+
70+
When `ta_name` and `ta_version` are not provided, they are read automatically
71+
from `app.conf` via `get_conf_stanzas`. Pass them explicitly when running
72+
outside a full Splunk environment.
73+
74+
Additional instruments can be registered using `ObservabilityService.register_instrument`.
75+
76+
For full API reference see [observability.py](observability.md).

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ nav:
3232
- Home: index.md
3333
- Release 6.0.0: release_6_0_0.md
3434
- Release 7.0.0: release_7_0_0.md
35+
- Release 8.0.0: release_8_0_0.md
3536
- References:
3637
- modular_input:
3738
- "checkpointer.py": modular_input/checkpointer.md
@@ -45,6 +46,7 @@ nav:
4546
- "hec_config.py": hec_config.md
4647
- "log.py": log.md
4748
- "net_utils.py": net_utils.md
49+
- "observability.py": observability.md
4850
- "orphan_process_monitor.py": orphan_process_monitor.md
4951
- "pattern.py": pattern.md
5052
- "server_info.py": server_info.md

0 commit comments

Comments
 (0)