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 toolkit package #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add toolkit package #147

wants to merge 1 commit into from

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Apr 1, 2023

Implement a top level package to make it easy to bootstrap an exporter.

  • Move the flag package to the top level.
  • Add support for --web.telemetry-path flag. Defaults to/metrics.
  • Add a self-check function to the web FlagConfig.

@SuperQ SuperQ requested a review from roidelapluie April 1, 2023 07:47
@SuperQ SuperQ force-pushed the superq/metricsPath branch 3 times, most recently from 6782d2c to 6557753 Compare April 1, 2023 08:30
@SuperQ
Copy link
Member Author

SuperQ commented Apr 1, 2023

Here's what a basic startup looks like:

	landingConfig := web.LandingConfig{
		Name:        "Node Exporter",
		Description: "Prometheus Node Exporter",
		Version:     version.Info(),
	}
	toolkitConfig := toolkit.Config{
		MetricsHandler: newHandler(!*disableExporterMetrics, *maxRequests, logger),
		FlagConfig:     toolkitFlags,
		LandingConfig:  landingConfig,
		Logger:         logger,
	}
	if err := toolkit.Run(toolkitConfig); err != nil {
		level.Error(logger).Log("err", err)
		os.Exit(1)
	}

@SuperQ SuperQ requested a review from juliusv April 5, 2023 07:05
@SuperQ
Copy link
Member Author

SuperQ commented Apr 5, 2023

Still some work to do, tests, etc. But what do you think of this concept so far?

@SuperQ
Copy link
Member Author

SuperQ commented Apr 9, 2023

Ok, new example setup. There's an annoying chicken-and-egg problem with the MetricsHandler, since if we want to pass a logger to the handler, we need to New() first.

  toolkitConfig := toolkit.Config{
    Name:           "Node Exporter",
    Description:    "Prometheus Node Exporter",
    DefaultAddress: ":9100",
  }
  t := toolkit.New(toolkitConfig)
  t.SetMetricsHandler(newHandler(!*disableExporterMetrics, *maxRequests, t.Logger))

  if err := t.Run(); err != nil {
    level.Error(t.Logger).Log("err", err)
    os.Exit(1)
  }

@SuperQ SuperQ force-pushed the superq/metricsPath branch 2 times, most recently from 02608de to aa26aca Compare April 9, 2023 13:34
@SuperQ
Copy link
Member Author

SuperQ commented Apr 9, 2023

One solution, I could implement part of the node_exporter's handler into this. One of the nice features is that it would implement the --web.disable-exporter-metrics flag by default, which would make a lot of users happy.

Implement a top level package to make it easy to bootstrap an exporter.
* Move the flag package to the top level.
* Add support for `--web.telemetry-path` flag. Defaults to`/metrics`.
* Add a self-check function to the web FlagConfig.

Signed-off-by: SuperQ <superq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant