Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
feat: changes for OTEL integration (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
weliasz committed Mar 30, 2021
1 parent 47e506e commit 7075092
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 113 deletions.
43 changes: 0 additions & 43 deletions splunk_connect_for_snmp_traps/manager/hec_config.py

This file was deleted.

16 changes: 5 additions & 11 deletions splunk_connect_for_snmp_traps/manager/hec_sender.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import concurrent.futures
import logging
import os
import threading

import requests

from splunk_connect_for_snmp_traps.manager.hec_config import HecConfiguration
from splunk_connect_for_snmp_traps.manager.os_config_utils import (
max_allowed_working_threads,
)
Expand All @@ -16,9 +16,9 @@ class HecSender:
def __init__(self, args, server_config):
self._args = args
self._server_config = server_config
self._hec_config = HecConfiguration()
self._thread_local = threading.local()
self._thread_pool_executor = self.configure_thread_pool()
self._endpoint = os.environ["OTEL_SERVER_URL"]

def configure_thread_pool(self):
user_suggested_working_threads = self._args.hec_threads
Expand All @@ -32,23 +32,17 @@ def get_session(self):
return self._thread_local.session

def post_data_to_thread_pool(self, host, variables_binds):
headers = {
"Authorization": f"Splunk {self._hec_config.get_authentication_token()}"
}
data = {
"sourcetype": "sc4snmp:traps",
"host": host,
"index": self._args.index,
# "index": self._server_config["splunk"]["index"],
"event": variables_binds,
}

try:
session = self.get_session()
for endpoint in self._hec_config.get_endpoints():
response = session.post(
url=endpoint, json=data, headers=headers, verify=False
)
logger.debug(f"Response code is {response.status_code}")
response = session.post(url=self._endpoint, json=data)
logger.debug(f"Response code is {response.status_code}")
except requests.ConnectionError as e:
logger.error(f"Connection error when sending data to HEC: {e}")

Expand Down
59 changes: 0 additions & 59 deletions tests/test_hec_config.py

This file was deleted.

0 comments on commit 7075092

Please sign in to comment.