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 Prometheus Remote Write Exporter supporting Cortex - Factory and Config #1524

Closed
wants to merge 116 commits into from

Conversation

dabangarang
Copy link
Contributor

Description:
This PR implements the config, config YAML, and factory structs, the prwExporter struct. It also includes the README.md for a sample configuration to run this Prometheus remote-write exporter. The config and factory structs are fully compatible with the Collector component interfaces.

Link to tracking Issue:
#1150
Related issues are:
Metrics aggregation proposal: #1422
Prometheus exporter not functional: #1255
Related spec discussion: #731

Testing:
The unit tests coverage is currently at 86.2% for this pull request. However combining this PR with other related PRs increases the coverage to 92.1%.

Documentation:

cc: @huyan0 @danielbang907 @alolita @markcartertm @sonofachamp @morigs
Request for review: @jmacd @bogdandrutu @annanay25 @gouthamve @open-telemetry/collector-approvers @open-telemetry/collector-maintainers

@bogdandrutu
Copy link
Member

Please fix lint errors

@dabangarang
Copy link
Contributor Author

Hi @bogdandrutu, will do! I will also add that the PR #1525 actually contains the total codebase (everything in this PR + logic for the exporter) Yang and I worked on, so there is no need to pull this codebase, should the other PR gets merged.

@bogdandrutu
Copy link
Member

@danielbang907 would prefer to merge this separated, easier to review

Namespace string `mapstructure:"namespace"`

// Optional headers configuration for authorization and security/extra metadata
Headers map[string]string `mapstructure:"headers"`
Copy link
Member

Choose a reason for hiding this comment

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

This can be added to HTTPClientSettings

// Optional headers configuration for authorization and security/extra metadata
Headers map[string]string `mapstructure:"headers"`

HTTPClientSettings confighttp.HTTPClientSettings `mapstructure:"http_setting"`
Copy link
Member

Choose a reason for hiding this comment

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

Most likely this can be squashed without a name

exporterhelper.WithMetrics(createMetricsExporter))
}

// Instantiates a pseudo-Cortex Exporter that adheres to the component MetricsExporter interface
Copy link
Member

Choose a reason for hiding this comment

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

Comments in golang should start with the func name:
"// createMetricsExporter instantiates ... "


// Instantiates the default version of a Remote Write Exporter config struct to
// be used by the factory to build Exporter instances
func createDefaultConfig() configmodels.Exporter {
Copy link
Member

Choose a reason for hiding this comment

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

Same for func names

//Tests whether or not the default Exporter factory can instantiate a properly interfaced Exporter with default conditions
func TestCreateDefaultConfig(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
Copy link
Member

Choose a reason for hiding this comment

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

can call directly createDefaultConfig


//Tests whether or not a correct Metrics Exporter from the default Config parameters
func TestCreateMetricsExporter(t *testing.T) {
factory := NewFactory()
Copy link
Member

Choose a reason for hiding this comment

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

same no need to have a factory

Comment on lines +40 to +48
File structure:

- `cortex.go`: exporter implementation. Converts and sends OTLP metrics

- `helper.go`: helper functions that cortex.go uses. Performs tasks such as sanitizing label and generating signature string

- `config.go`: configuration struct of the exporter

- `factory.go`: initialization methods for creating default configuration and the exporter
Copy link
Member

Choose a reason for hiding this comment

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

This will soon get outdated, recommend to not have it here.

@dabangarang
Copy link
Contributor Author

Closing this PR as @huyan0 is filing one that addresses the current comments and CI checks.

MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
* fix: grpc reconnection fixed

* chore: changelog update

* fix: grpc reconnection issue - red test

* fix: grpc reconnection open-telemetry#1524

* fix: grpc reconnection issue cleanup
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
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