Skip to content

Commit

Permalink
fix coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
theanotherwise committed Nov 28, 2023
1 parent 6646493 commit 7dbedb7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion images/fastapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ USER "${USER_NAME}"
COPY ./src/* .

RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --upgrade hypercorn uvicorn fastapi
python3 -m pip install --upgrade hypercorn uvicorn fastapi elastic-apm

ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"]
23 changes: 20 additions & 3 deletions images/fastapi/src/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
from fastapi import FastAPI
from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
import os

apm_server = os.getenv('APM_SERVER') or 'apm:8200'
service_name = os.getenv('SERVICE_NAME') or 'fastapi'
env_name = os.getenv('ENV_NAME') or 'staging'

apm = make_apm_client({
'SERVER_URL': apm_server,
'SERVICE_NAME': service_name,
'ENVIRONMENT': env_name,
'SERVER_TIMEOUT': '5s',
'ENABLED': 'true',
'LOG_LEVEL': 'trace',
'LOG_FILE_SIZE': '100mb'
})

app = FastAPI()
app.add_middleware(ElasticAPM, client=apm)


@app.get("/")
async def root():
return {"message": "Hello world!"}
@app.get('/')
def read_root():
return 'fastapi'

0 comments on commit 7dbedb7

Please sign in to comment.