-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from SolarEdgeTech/amenezes/aiohttp
Add support for monitoring aiohttp based applications
- Loading branch information
Showing
20 changed files
with
1,072 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# aiohttp example | ||
This example demonstrates the integration with the [aiohttp](https://docs.aiohttp.org). | ||
|
||
## Running the example | ||
1. Start an instance of SBA (Spring Boot Admin): | ||
```sh | ||
docker run --rm -p 8080:8080 michayaak/spring-boot-admin:2.2.3-1 | ||
``` | ||
2. Once Spring Boot Admin is running, you can run the examples as follow: | ||
```sh | ||
cd examples/aiohttp | ||
poetry install | ||
poetry run python -m aiohttp_example_app | ||
``` | ||
|
||
![aiohttp Example](../images/aiohttp.png) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import datetime | ||
import logging | ||
import random | ||
|
||
from aiohttp import web | ||
|
||
from pyctuator.pyctuator import Pyctuator | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
my_logger = logging.getLogger("example") | ||
app = web.Application() | ||
routes = web.RouteTableDef() | ||
|
||
|
||
@routes.get('/') | ||
def home(request: web.Request) -> web.Response: | ||
my_logger.debug(f"{datetime.datetime.now()} - {str(random.randint(0, 100))}") | ||
print("Printing to STDOUT") | ||
return web.Response(text="Hello World!") | ||
|
||
|
||
example_app_address = "host.docker.internal" | ||
example_sba_address = "localhost" | ||
|
||
pyctuator = Pyctuator( | ||
app, | ||
"Example aiohttp", | ||
app_url=f"http://{example_app_address}:8888", | ||
pyctuator_endpoint_url=f"http://{example_app_address}:8888/pyctuator", | ||
registration_url=f"http://{example_sba_address}:8080/instances", | ||
app_description="Demonstrate Spring Boot Admin Integration with aiohttp", | ||
) | ||
|
||
app.add_routes(routes) | ||
web.run_app(app, port=8888) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[tool.poetry] | ||
name = "aiohttp-pyctuator-example" | ||
version = "1.0.0" | ||
description = "Example of using Pyctuator" | ||
authors = [ | ||
"Luke Skywalker <[email protected]>", | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.7" | ||
psutil = { version = "^5.6" } | ||
aiohttp = { version = "^3.5.4" } | ||
pyctuator = { version = "^0.12" } | ||
|
||
[build-system] | ||
requires = ["poetry>=0.12"] | ||
build-backend = "poetry.masonry.api" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.