department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
283 stars 204 forks source link

Investigate and document an alternative tracking approach #19451

Closed LindseySaari closed 3 years ago

LindseySaari commented 3 years ago

Issue Description

It was discussed that a proxy sinatra (middleware) app may be the solution needed to send metrics to Datadog for vtk tracking purposes.


Tasks

ericboehs commented 3 years ago

We're wanting to track command usage in vtk. Each command ran will increment a counter unique to the command (but not the individual who ran it). Currently, we have two external options for tracking that I'm aware of: Datadog and Google Analytics.

We talked with our analytic team and they said GA wouldn't be a great fit for our use case. We may want to revisit this since we're having to do workarounds for Datadog.

The primary issue we're facing is that Datadog doesn't allow client tokens to report metrics via their API. Their RUM and Mobile SDK somehow does but I'm not sure how. Perhaps a good step would be to contact Datadog and see if there's something that I'm doing wrong.

Since we're unable to use client tokens, we'd have to use our private API keys which we can't package with our open-source gem. To circumvent this issue, a middleware app could stand in between our clients and Datadog to allow for submission of these metrics without revealing our private API key.

In order to do this, we'll need a public facing endpoint available for our clients to access. This middleware would ideally be an independent application rather than an extra endpoint on vets-api as this functionality seems completely out-of-scope of something vets-api should handle. Since our applications should be hosted within our TIC, we'd need to add a rule to our revproxy to allow this endpoint to be accessible. Our production revproxy is va.gov which would mean our endpoint would be something like va.gov/cli-analytics/record. Demian suggested we use dev.va.gov as this is what we're using for our PACT broker. He also would like to eventually get a tools.va.gov subdomain provisioned for stuff like this.

I think this new app would be greatly suited for Sinatra as it will be tiny (<100 LoC). We'd need to Dockerize this Sinatra app for deployment on ECS. Demian suggested we use EKS but he said it's not ready for production based deployments in the immediate future so it looks like ECS is our best bet. Once we've created a Dockerized app that submits metrics to Datadog (which works locally), we should reach out to ops/Demian for further direction on deployment.