Skip to content

Support registry as Pushgateway second argument#769

Open
bugprone wants to merge 1 commit into
prometheus:mainfrom
bugprone:fix-pushgateway-registry-argument
Open

Support registry as Pushgateway second argument#769
bugprone wants to merge 1 commit into
prometheus:mainfrom
bugprone:fix-pushgateway-registry-argument

Conversation

@bugprone

@bugprone bugprone commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

Pushgateway accepts an optional options argument before the registry argument. In TypeScript, new Pushgateway(url, registry) was accepted because options was typed as any, but at runtime that registry object was treated as request options and the Pushgateway fell back to the global registry.

This makes the two-argument registry form work at runtime and declares it explicitly in the TypeScript definitions.

Fixes #652.

Changes

  • Treat a Registry passed as the second Pushgateway constructor argument as the registry
  • Add constructor overloads for new Pushgateway(url, registry) and new Pushgateway(url, options, registry)
  • Add a small Pushgateway.Options type with requireJobName plus request option passthrough
  • Add runtime coverage for pushing metrics from a second-argument registry
  • Add TypeScript compile coverage for the supported constructor forms
  • Update the unreleased changelog

Testing

  • npm test -- --runInBand --forceExit
  • Manual smoke check with a local HTTP server verifying new Pushgateway(url, registry).push() sends metrics from the provided registry

Signed-off-by: Jace <bugprone@gmail.com>
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.

Problem in .d.ts definition, -> logical errors when using typescript code

1 participant