Skip to content

Instantly share code, notes, and snippets.

View srinivasiyer's full-sized avatar

Srinivas Iyer srinivasiyer

View GitHub Profile
@tracer.wrap(
service=DatadogService.CHANNELS_SERVICES.value,
name=DatadogOperation.SERVICE_METHOD.value,
resource="ConversationsService.get_conversation",
)
async def get_conversation(
self,
*,
user_group_id: int,
conversation_id: int,
@tracer.wrap(
service=DatadogService.CHANNELS_DOCUMENTDB.value,
name=DatadogOperation.MONGO_QUERY.value,
span_type=DatadogSpanType.DATABASE.value,
resource="InboxesRepository.fetch_one",
)
async def fetch_one(self, *, inbox_id: int) -> Optional[InboxModel]:
span = tracer.current_span()
add_tag_to_span(span, "inbox_id", inbox_id)
@srinivasiyer
srinivasiyer / account_agents_repository.py
Created June 16, 2022 03:38
Dadadog Decorator for Repository File in Python
@tracer.wrap(
service=DatadogService.CHANNELS_CHAT_API.value,
name=DatadogOperation.API_CALL.value,
resource="AccountAgentsRepository.fetch_all",
)
async def fetch_all(
self, *, chat_account_id: int, api_access_token: str
) -> List[AccountAgentModel]:
url = f"{self.__chat_api_host}/api/v1/accounts/{chat_account_id}/agents"
@srinivasiyer
srinivasiyer / route_trace_middleware.py
Created June 16, 2022 03:34
Datadog Route Middleware in Python for FastAPI
from typing import Awaitable, Callable, Dict, Optional, Union
from ddtrace import tracer
from fastapi import Request, Response
from starlette.routing import Match, Scope
from constants.datadog import DatadogOperation, DatadogSpanType
class RouteTraceMiddleware: