Skip to content

Commit

Permalink
Add ODS Counter for logging received and successful requests for crea…
Browse files Browse the repository at this point in the history
…ting cases

Summary:
We are using thrift service for providing our case creation API from Care Platform to BSE team in fbcode.
They will call a python method, that calls our case creation method in www and all of that is implemented with thrift service.

In care_platform_client.py, we have an implementation of that thrift service that calls ServiceRouter, which routes requests to appropriate WWW service, which creates cases in Salesforce.

In this diff I have added an ODS counter(OBC, the library used here, is an implementation of it in python), which will log all received and successfully created cases in SF for tracking performance of the service in prod.

Differential Revision: D66883904

fbshipit-source-id: c9b59115cccc323974a0b58e742cacd7fb25be07
  • Loading branch information
Adlet Zeineken authored and facebook-github-bot committed Dec 11, 2024
1 parent f9b10e6 commit 02ccfbe
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# pyre-ignore-all-errors

from create_salesforce_case_with_mail.create_salesforce_case_with_mail_draft_service.thrift_clients import (
CreateSalesforceCaseWithMailDraftService,
)

from create_salesforce_case_with_mail.create_salesforce_case_with_mail_draft_service.thrift_types import (
CreateSalesforceCaseWithMailDraftRequest,
CreateSalesforceCaseWithMailDraftResponse_Thrift,
)
from gatekeeper.py.gk import GK
from libfb.py import employee

from monitoring.obc.py import OBCClient
from servicerouter.python.sync_client import get_sr_client

GK_NAME = "care_platform_fbcode_thrift_case_creation_service"
TIER_NAME = "care_platform.create_case_with_mail_for_bse.fbcode_www_thrift_service"
ODS_COUNTER_ENTITY = "care_platform.thrift_case_creation_with_mail_draft"
ODS_RECEIVED_KEY = "care_platform.thrift_case_creation_with_mail_draft.received"
ODS_SUCCESS_KEY = "care_platform.thrift_case_creation_with_mail_draft.success"


def create_case_with_mail(request: CreateSalesforceCaseWithMailDraftRequest):
ods_client = OBCClient.OBCClient("default")
ods_client.bumpEntityKey(ODS_COUNTER_ENTITY, ODS_RECEIVED_KEY)
if GK.check(GK_NAME, employee.get_current_unix_user_fbid()):
with get_sr_client(
CreateSalesforceCaseWithMailDraftService,
tier=TIER_NAME,
) as client:
ods_client.bumpEntityKey(ODS_COUNTER_ENTITY, ODS_SUCCESS_KEY)
return client.genCreateSalesforceCaseWithMailDraft(request)
else:
return CreateSalesforceCaseWithMailDraftResponse_Thrift()

0 comments on commit 02ccfbe

Please sign in to comment.