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

Replace provider with typescript client for querying prometheus data #60

Merged
merged 7 commits into from
Jul 31, 2023

Conversation

brettimus
Copy link
Collaborator

This PR swaps out the prometheus.ts file, removes the provider runtime, and adds fiberplane-prometheus-query as a dependency.

The Prometheus client exported by prometheus.ts still exposes the same interface, so there weren't many changes outside of that file.

Motivation for this PR was that the provider didn't seem to like using the URL http://localhost:9090/prometheus, i.e., the path to prometheus data exposed by am.

I tested locally, but would appreciate a second set of eyes.

"*.json"
]
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What you did to my newline? :p

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was just on vacation it's coming back

* At first, I needed to copy it here to fix an issue with the url.
* But then I realized that we would need to polyfill fetch to use it,
* so I think we'll just keep this version here for now, and
* rely on the utilities to transform the request/response into the format we need.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might be a nice solution to add this to fiberplane-prometheus-query instead:

export type QueryPrometheusOptions = RequestInit & {
  /**
   * Base URL to the Prometheus service, without trailing slash.
   */
  baseUrl: string;
  
  /**
   * Custom `fetch` function to use instead of the global `fetch`.
   *
   * May be used to support environments that don't support `fetch`, or to inject `fetch` during tests.
   */
  fetch?: typeof fetch;
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah agreed — i was a little hesitant in this case because node-fetch is subtly different than browser fetch (e.g., it doesn't accept a cors parameter, but i don't think typescript would complain about that)

@brettimus brettimus merged commit eccde4c into main Jul 31, 2023
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.

2 participants