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

TT-9873 Fix prometheus tracking path #716

Merged
merged 3 commits into from
Aug 23, 2023

Conversation

tbuchaillot
Copy link
Contributor

Description

This PR change fixes the tracking path behavior of Prometheus pump. It was tracking all the paths by default, ignoring if the API/analytic record has TrackPath enabled.
Now, when you don't have TrackPath enabled ( aka you are using Track Endpoint plugin), it will log the path as unknown.
This also adds a new configuration for prometheus pump track_all_paths - that enables the path tracking for ALL the APIs (similar to Mongo/SQL aggregate pumps) - but this can cause Tyk Pump malfunctioning and OOM.

Related Issue

https://tyktech.atlassian.net/browse/TT-9873

Motivation and Context

https://tyktech.atlassian.net/browse/TT-9873

How This Has Been Tested

Added tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If pulling from your own
    fork, don't request your master!
  • Make sure you are making a pull request against the master branch (left side). Also, you should start
    your branch off our latest master.
  • My change requires a change to the documentation.
    • If you've changed APIs, describe what needs to be updated in the documentation.
  • I have updated the documentation accordingly.
  • Modules and vendor dependencies have been updated; run go mod tidy && go mod vendor
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • go fmt -s
    • go vet

Copy link
Contributor

@sredxny sredxny 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, only fix the typo

@@ -42,6 +42,9 @@ type PrometheusConf struct {
AggregateObservations bool `json:"aggregate_observations" mapstructure:"aggregate_observations"`
// Metrics to exclude from exposition. Currently, excludes only the base metrics.
DisabledMetrics []string `json:"disabled_metrics" mapstructure:"disabled_metrics"`
// Specifies if it should expose aggregated metrics for all the endpoints. By default, `false`
// which means that all APIs endpoints will be counted as 'uknown' unless the API use track endpoint plugin.
Copy link
Contributor

Choose a reason for hiding this comment

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

fix typo unknown

@@ -245,6 +248,11 @@ func (p *PrometheusPump) WriteData(ctx context.Context, data []interface{}) erro
default:
}
record := item.(analytics.AnalyticsRecord)

if !(p.conf.TrackAllPaths || record.TrackPath) {
record.Path = "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a small comment: Setting a const here will make it easier to read and avoid typos if we need to work on this again in the future. I'd set a UnknowPath const and use it here and in the unit test, wdyt?

@tbuchaillot tbuchaillot merged commit 69f5f4a into master Aug 23, 2023
10 checks passed
@tbuchaillot tbuchaillot deleted the fix/TT-9873-prometheus-track-path branch August 23, 2023 13:54
@tbuchaillot
Copy link
Contributor Author

/release to release-1.8

@tykbot
Copy link

tykbot bot commented Aug 23, 2023

Working on it! Note that it can take a few minutes.

tykbot bot pushed a commit that referenced this pull request Aug 23, 2023
* Fix prometheus tracking path

* suggested fixes

(cherry picked from commit 69f5f4a)
@tykbot
Copy link

tykbot bot commented Aug 23, 2023

@tbuchaillot Succesfully merged PR

buger added a commit that referenced this pull request Aug 23, 2023
TT-9873 Fix prometheus tracking path (#716)

* Fix prometheus tracking path

* suggested fixes
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

Successfully merging this pull request may close these issues.

3 participants