Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Resource Download Stats #45

Open
5 tasks
steveoni opened this issue Apr 20, 2022 · 1 comment
Open
5 tasks

Add Resource Download Stats #45

steveoni opened this issue Apr 20, 2022 · 1 comment
Assignees

Comments

@steveoni
Copy link
Contributor

Acceptance

  • Resource Download stats is visible in Dataset Pages
  • Resource Download stats are included in package_search API

Task

  • install `google-analytics1 and enable resource download tracking
  • Analysis of extension to enable visibility of download stats in Dataset Page and package_search
  • Install the provided extension
@steveoni steveoni self-assigned this Apr 20, 2022
@steveoni
Copy link
Contributor Author

Analysis to see if it is possible to use azure application insight.

First, there was an investigation of how ckanext-googleanalytics works:

  1. A track id is generated which is firstly added to the page header
  2. Ckanext google analytics provides a custom function that is used to wrap all action functions and resource API
  3. Each API events are stored as a dictionary and sent to gooogleanalytics
  4. There is functionality to store event data from google analytics in package_stats and resource_stats table for easy query to enable download stats display

This investigation is used to guide what to look for in Azure application insight

To use azure application insight we need to:

  1. Setup application insights resource
  2. Obtain the credential key which will be used with Azure SDK
  3. Download Opencesus Python SDK
  4. Experiment with how to use this SDK to intercept API and emit results to the azure application monitor and also receive updates from the application monitor.

This link https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python shows how to use the Python SDK, but the example only shows how to use logger to emit log to azure to monitor the app.

Also after further investigation was able to obtain a version for the flask, which wrap the app with a flask middleware. This track all incoming request sent to our flask app https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python-request

ISSUES:

  1. The flask middleware can track incoming requests sent to the app, but no doc to sure how to create a custom tracking event as it is possible in google analytics. The custom event enables us to store events like a dictionary since we have different packages with resources, the custom event makes it possible to receive data for each of these packages.

  2. No detailed documentation, and no lot of examples on how to use the package. Google analytics seems to be the most used and easy to get more information on.

But with more experiments and testing we can figure out how to use it for our main purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant