Skip to content

Commit

Permalink
Merge branch 'master' into async-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
laerfulaolun committed Mar 19, 2024
2 parents 2b3cd64 + 8708a23 commit c8ac005
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 30 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ Github issues and feature requests welcomed.

### Integrations

| Category | Library |
|-----------------|-------------------------------------------------------------|
| API | flask |
| Chat | slack |
| Data Scraping | beautifulsoup<br/>facebook groups<br/>instagram<br/>scrapy |
| Databases | elasticsearch<br/>neo4j<br/>splunk |
| Data Store | minio<br/>swift |
| Devices | snmp |
| Google Cloud | google auth api<br/>google people api<br/>google sheets api |
| Logging | sentryio |
| macOS | airport<br/>macchanger |
| Python | logging<br/>requests |
| Recon | nmap |
| Test Automation | selenium |
| Category | Library |
|-------------------|-------------------------------------------------------------|
| API | flask |
| Chat | slack |
| Data Scraping | beautifulsoup<br/>facebook groups<br/>instagram<br/>scrapy |
| Databases | elasticsearch<br/>neo4j<br/>splunk |
| Data Store | minio<br/>swift |
| Devices | snmp |
| Google Cloud | google auth api<br/>google people api<br/>google sheets api |
| Tracing / Logging | openTelemetry<br/>sentryio |
| macOS | airport<br/>macchanger |
| Python | logging<br/>requests |
| Recon | nmap |
| Test Automation | selenium |

#### Requires

Expand Down
51 changes: 51 additions & 0 deletions automon/integrations/openTelemetryWrapper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# OpenTelemetry

## Install Automatic Instrumentation

* https://opentelemetry.io/docs/languages/python/automatic/

```shell
python3 -m pip install -U opentelemetry-distro opentelemetry-exporter-otlp
python3 -m pip install git+https://github.com/TheShellLand/[email protected]#subdirectory=instrumentation/opentelemetry-instrumentation-aiohttp-server
opentelemetry-bootstrap --action install

# python logging
python3 -m pip install -U opentelemetry-instrumentation-logging

# django
python3 -m pip install -U opentelemetry-instrumentation-django
```

## Known issues:

### Problem 1 (fixed):

fixed: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2053#issuecomment-1962248084

```
ERROR: No matching distribution found for opentelemetry-instrumentation-aiohttp-server==0.42b0
```

reference: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2053

Solution:

* install using commit flag

> I have added a new tag: 0.43b0hotfix. This can be used to install
> opentelemetry-instrumentation-aiohttp-server and
> opentelemetry-resource-detector-container with the following pip commands:
opentelemetry-instrumentation-aiohttp-server:

```shell
python3 -m pip install git+https://github.com/open-telemetry/[email protected]#subdirectory=instrumentation/opentelemetry-instrumentation-aiohttp-server
```

opentelemetry-resource-detector-container:

```shell
python3 -m pip install git+https://github.com/open-telemetry/[email protected]#subdirectory=resource/opentelemetry-resource-detector-container
```

solution: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2053#issuecomment-1928485674
1 change: 1 addition & 0 deletions automon/integrations/openTelemetryWrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .config import *
Empty file.
6 changes: 6 additions & 0 deletions automon/integrations/openTelemetryWrapper/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python:3

RUN python3 -m pip install -U opentelemetry-distro opentelemetry-exporter-otlp
RUN python3 -m pip install git+https://github.com/TheShellLand/[email protected]#subdirectory=instrumentation/opentelemetry-instrumentation-aiohttp-server
RUN opentelemetry-bootstrap --action install
RUN python3 -m pip install -U opentelemetry-instrumentation-logging
7 changes: 7 additions & 0 deletions automon/integrations/openTelemetryWrapper/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# build image

cd "$(dirname $0)" && set -xe

docker build $@ -f Dockerfile -t opentelemetry-python .
6 changes: 6 additions & 0 deletions automon/integrations/openTelemetryWrapper/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# opentelemetry
opentelemetry-distro>=0.44b0
opentelemetry-exporter-otlp>=1.22.0
opentelemetry-instrumentation-logging>=0.44b0
# workaround
git+https://github.com/TheShellLand/[email protected]#subdirectory=instrumentation/opentelemetry-instrumentation-aiohttp-server
4 changes: 4 additions & 0 deletions automon/integrations/seleniumWrapper/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ async def find_xpath(

async def get(self, url: str, **kwargs) -> bool:
"""get url"""
if not self.webdriver:
logger.error(f'missing webdriver')
raise Exception(f'missing webdriver')

try:
if self.webdriver.get(url, **kwargs) is None:
logger.info(str(dict(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import asyncio

from automon.integrations.seleniumWrapper import SeleniumBrowser, ChromeWrapper

Expand All @@ -10,22 +11,17 @@

class SeleniumClientTest(unittest.TestCase):

async def test(self):
if browser.run():
await browser.set_window_size(device_type='web-large')
while True:
def test(self):

try:
if await browser.get('http://bing.com'):
self.assertTrue(await browser.save_screenshot())
self.assertTrue(await browser.save_screenshot())
self.assertTrue(await browser.save_screenshot(folder='./'))
if asyncio.run(browser.run()):
asyncio.run(browser.set_window_size(device_type='web-large'))

await browser.quit()
break
if asyncio.run(browser.get('http://bing.com')):
self.assertTrue(asyncio.run(browser.save_screenshot()))
self.assertTrue(asyncio.run(browser.save_screenshot()))
self.assertTrue(asyncio.run(browser.save_screenshot(folder='./')))

except:
pass
asyncio.run(browser.quit())


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion automon/integrations/seleniumWrapper/webdriver_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def update_paths(self, path: str):

return True

logger.error(f'not found: {path}')
logger.error(f'chrome driver not found: {path}')

async def quit(self):
"""quit
Expand Down
2 changes: 1 addition & 1 deletion docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ google-chrome --version
# install chromedriver
cd /tmp/
# https://googlechromelabs.github.io/chrome-for-testing/#stable
wget -q https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
wget -q https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.111/linux64/chromedriver-linux64.zip
unzip chromedriver-linux64.zip
sudo mv chromedriver-linux64/chromedriver /usr/bin/chromedriver
chromedriver --version
7 changes: 7 additions & 0 deletions env-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ OPENSTACK_INTERFACE=public
OPENSTACK_IDENTITY_API_VERSION=3
SWIFTCLIENT_INSECURE=True

# OpenTelemetry
# https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/logging/logging.html
OTEL_PYTHON_LOG_CORRELATION=true
OTEL_PYTHON_LOG_FORMAT='%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] [trace_id=%(otelTraceID)s span_id=%(otelSpanID)s resource.service.name=%(otelServiceName)s trace_sampled=%(otelTraceSampled)s] - %(message)s'
OTEL_PYTHON_LOG_LEVEL=debug


# Splunk SOAR
SPLUNK_SOAR_HOST=
SPLUNK_SOAR_AUTH_TOKEN=
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ neo4j>=4.4.9
python-keystoneclient>=4.2.0
python-swiftclient>=3.12.0

# opentelemetry
opentelemetry-distro>=0.44b0
opentelemetry-exporter-otlp>=1.22.0
opentelemetry-instrumentation-logging>=0.44b0
# workaround
git+https://github.com/TheShellLand/[email protected]#subdirectory=instrumentation/opentelemetry-instrumentation-aiohttp-server

# splunk soar
pytz>=2021.1

Expand Down
2 changes: 1 addition & 1 deletion upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ "$@" == '--local' ]; then
python3 setup.py sdist bdist_wheel
twine check dist/*
python3 -m twine upload --repository $PYPI --repository-url $TWINE_REPOSITORY \
-u $TWINE_USERNAME -p $TWINE_PASSWORD --non-interactive --skip-existing dist/*
-u "$TWINE_USERNAME" -p "$TWINE_PASSWORD" --non-interactive --skip-existing dist/*
python3 setup.py clean --all
elif [ "$@" == '--docker' ]; then
set -x
Expand Down

0 comments on commit c8ac005

Please sign in to comment.