Skip to content

Commit

Permalink
Merge pull request #37 from weni-ai/feature/elastic-apm
Browse files Browse the repository at this point in the history
Add: Elastic apm
  • Loading branch information
zMardone authored Jun 13, 2024
2 parents 54df6bb + 855d531 commit 7282137
Show file tree
Hide file tree
Showing 3 changed files with 909 additions and 709 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 @@ -91,6 +93,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
Loading

0 comments on commit 7282137

Please sign in to comment.