Skip to content

Commit

Permalink
Add: Elastic apm
Browse files Browse the repository at this point in the history
  • Loading branch information
zMardone committed Jun 13, 2024
1 parent c9e1d65 commit c80b265
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 4 deletions.
14 changes: 14 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sentry_sdk
import os
from elasticsearch import Elasticsearch
from elasticapm.contrib.starlette import ElasticAPM, make_apm_client
from fastapi import FastAPI
from langchain.embeddings import HuggingFaceHubEmbeddings, CohereEmbeddings
from langchain.embeddings.base import Embeddings
Expand Down Expand Up @@ -88,6 +90,18 @@ def __init__(self, config: AppConfig):
self.content_base_handler = ContentBaseHandler(self.content_base_indexer)
self.api.include_router(self.content_base_handler.router)

# APM Configuration

apm_config = {
'SERVICE_NAME': os.environ.get('APM_SERVICE_NAME'),
'SECRET_TOKEN': os.environ.get('APM_SECRET_TOKEN'),
'SERVER_URL': os.environ.get('APM_SERVER_URL'),
'ENVIRONMENT': os.environ.get('APM_ENVIRONMENT'),
}

apm_CLIENT = make_apm_client(apm_config)
self.api.add_middleware(ElasticAPM, client=apm_CLIENT)


config = AppConfig()
main_app = App(config)
Expand Down
126 changes: 122 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sentry-sdk = {extras = ["fastapi"], version = "^1.35.0"}
xlrd = "^2.0.1"
pdfminer-six = "^20231228"
cohere = "^4.37"
elastic-apm = "^6.22.3"


[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit c80b265

Please sign in to comment.