Skip to content

Add toolkit package - #147

Closed
SuperQ wants to merge 1 commit into
masterfrom
superq/metricsPath
Closed

Add toolkit package#147
SuperQ wants to merge 1 commit into
masterfrom
superq/metricsPath

Conversation

@SuperQ

@SuperQ SuperQ commented Apr 1, 2023

Copy link
Copy Markdown
Member

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

SuperQ commented Apr 1, 2023

Copy link
Copy Markdown
Member Author

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

SuperQ commented Apr 5, 2023

Copy link
Copy Markdown
Member Author

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

@SuperQ
SuperQ force-pushed the superq/metricsPath branch from 6557753 to 6ae4ad8 Compare April 9, 2023 13:18
@SuperQ

SuperQ commented Apr 9, 2023

Copy link
Copy Markdown
Member Author

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

SuperQ commented Apr 9, 2023

Copy link
Copy Markdown
Member Author

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>
@ArthurSens

Copy link
Copy Markdown
Member

Hey hey, closing since #394 got merged :)

@ArthurSens ArthurSens closed this Aug 24, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Exporter Tracking Board Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants