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

Collect SnippetsFilter information #2677

Merged
merged 11 commits into from
Oct 16, 2024

Conversation

bjee19
Copy link
Contributor

@bjee19 bjee19 commented Oct 10, 2024

Proposed changes

Collect SnippetsFilters count, the directive-context of each snippet, and the total count of each unique directive-context.

Problem: I want to know if SnippetsFilters are being used, and what are the most popular directives being used.

Solution: Collect SnippetsFilter count, the directive-context of each snippet, and the total count of each unique directive-context.

Testing: Manual testing and unit tests.

Output with the example SnippetsFilters.yaml deployed. (removed other telemetry points for easier reading)

{"level":"debug","ts":"2024-10-14T19:10:00Z","logger":"telemetryExporter","msg":"Exporting telemetry","data":{...,"SnippetsFiltersDirectives":["aio-http","allow-location","deny-location","worker_shutdown_timeout-main","auth_delay-server"],"SnippetsFiltersDirectivesCount":[1,1,1,1,1],..."SnippetsFilterCount":1}}

Output with no SnippetsFilters deployed.

{"level":"debug","ts":"2024-10-14T19:13:11Z","logger":"telemetryExporter","msg":"Exporting telemetry","data":{..."SnippetsFiltersDirectives":[],"SnippetsFiltersDirectivesCount":[],..."SnippetsFilterCount":0,}}

Closes #2373
Closes #2375

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.


@bjee19 bjee19 requested review from a team as code owners October 10, 2024 22:15
@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request tests Pull requests that update tests labels Oct 10, 2024
@bjee19
Copy link
Contributor Author

bjee19 commented Oct 10, 2024

Will add manual testing soon, though review of naming and logic can happen now.

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.80%. Comparing base (8dd553d) to head (ab3bcb7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2677      +/-   ##
==========================================
- Coverage   88.89%   88.80%   -0.10%     
==========================================
  Files         110      109       -1     
  Lines        8556     8386     -170     
  Branches       50        0      -50     
==========================================
- Hits         7606     7447     -159     
+ Misses        892      881      -11     
  Partials       58       58              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sjberman sjberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if the directive came first in the string, then the context. This goes for all variable/function names too.

internal/mode/static/telemetry/collector.go Outdated Show resolved Hide resolved
internal/mode/static/telemetry/collector.go Outdated Show resolved Hide resolved
internal/mode/static/telemetry/collector.go Outdated Show resolved Hide resolved
internal/mode/static/telemetry/collector.go Show resolved Hide resolved
internal/mode/static/telemetry/collector_test.go Outdated Show resolved Hide resolved
@bjee19 bjee19 requested a review from sjberman October 14, 2024 19:14
Copy link
Contributor

@salonichf5 salonichf5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@bjee19
Copy link
Contributor Author

bjee19 commented Oct 16, 2024

Verified data on xcdf side, will now merge.

@bjee19 bjee19 force-pushed the feature/collect-snippets-filter-usage branch from 1404777 to ab3bcb7 Compare October 16, 2024 21:56
@bjee19 bjee19 merged commit 0a4f0fb into nginxinc:main Oct 16, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request tests Pull requests that update tests
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

SnippetsFilter usage is reported via Telemetry Directives Used in Snippets are Reported via Telemetry
4 participants