MCPcopy Index your code
hub / github.com/prometheus/prometheus / NewAPI

Function NewAPI

web/api/v1/api.go:271–379  ·  view source on GitHub ↗

NewAPI returns an initialized API type.

(
	qe promql.QueryEngine,
	q storage.SampleAndChunkQueryable,
	ap storage.Appendable, apV2 storage.AppendableV2,
	eq storage.ExemplarQueryable,
	spsr func(context.Context) ScrapePoolsRetriever,
	tr func(context.Context) TargetRetriever,
	ar func(context.Context) AlertmanagerRetriever,
	configFunc func() config.Config,
	flagsMap map[string]string,
	globalURLOptions GlobalURLOptions,
	readyFunc func(http.HandlerFunc) http.HandlerFunc,
	db TSDBAdminStats,
	dbDir string,
	enableAdmin bool,
	enableSearch bool,
	maxSearchLimit int,
	logger *slog.Logger,
	rr func(context.Context) RulesRetriever,
	remoteReadSampleLimit int,
	remoteReadConcurrencyLimit int,
	remoteReadMaxBytesInFrame int,
	isAgent bool,
	corsOrigin *regexp.Regexp,
	runtimeInfo func() (RuntimeInfo, error),
	buildInfo *PrometheusVersion,
	notificationsGetter func() []notifications.Notification,
	notificationsSub func() (<-chan notifications.Notification, func(), bool),
	gatherer prometheus.Gatherer,
	registerer prometheus.Registerer,
	statsRenderer StatsRenderer,
	rwEnabled bool,
	acceptRemoteWriteProtoMsgs remoteapi.MessageTypes,
	otlpEnabled, otlpDeltaToCumulative, otlpNativeDeltaIngestion bool,
	stZeroIngestionEnabled bool,
	lookbackDelta time.Duration,
	enableTypeAndUnitLabels bool,
	appendMetadata bool,
	overrideErrorCode OverrideErrorCode,
	featureRegistry features.Collector,
	openAPIOptions OpenAPIOptions,
	promqlParser parser.Parser,
)

Source from the content-addressed store, hash-verified

269
270// NewAPI returns an initialized API type.
271func NewAPI(
272 qe promql.QueryEngine,
273 q storage.SampleAndChunkQueryable,
274 ap storage.Appendable, apV2 storage.AppendableV2,
275 eq storage.ExemplarQueryable,
276 spsr func(context.Context) ScrapePoolsRetriever,
277 tr func(context.Context) TargetRetriever,
278 ar func(context.Context) AlertmanagerRetriever,
279 configFunc func() config.Config,
280 flagsMap map[string]string,
281 globalURLOptions GlobalURLOptions,
282 readyFunc func(http.HandlerFunc) http.HandlerFunc,
283 db TSDBAdminStats,
284 dbDir string,
285 enableAdmin bool,
286 enableSearch bool,
287 maxSearchLimit int,
288 logger *slog.Logger,
289 rr func(context.Context) RulesRetriever,
290 remoteReadSampleLimit int,
291 remoteReadConcurrencyLimit int,
292 remoteReadMaxBytesInFrame int,
293 isAgent bool,
294 corsOrigin *regexp.Regexp,
295 runtimeInfo func() (RuntimeInfo, error),
296 buildInfo *PrometheusVersion,
297 notificationsGetter func() []notifications.Notification,
298 notificationsSub func() (<-chan notifications.Notification, func(), bool),
299 gatherer prometheus.Gatherer,
300 registerer prometheus.Registerer,
301 statsRenderer StatsRenderer,
302 rwEnabled bool,
303 acceptRemoteWriteProtoMsgs remoteapi.MessageTypes,
304 otlpEnabled, otlpDeltaToCumulative, otlpNativeDeltaIngestion bool,
305 stZeroIngestionEnabled bool,
306 lookbackDelta time.Duration,
307 enableTypeAndUnitLabels bool,
308 appendMetadata bool,
309 overrideErrorCode OverrideErrorCode,
310 featureRegistry features.Collector,
311 openAPIOptions OpenAPIOptions,
312 promqlParser parser.Parser,
313) *API {
314 a := &API{
315 QueryEngine: qe,
316 Queryable: q,
317 ExemplarQueryable: eq,
318
319 scrapePoolsRetriever: spsr,
320 targetRetriever: tr,
321 alertmanagerRetriever: ar,
322
323 now: time.Now,
324 config: configFunc,
325 flagsMap: flagsMap,
326 ready: readyFunc,
327 globalURLOptions: globalURLOptions,
328 db: db,

Callers 2

newTestAPIFunction · 0.85
createPrometheusAPIFunction · 0.85

Calls 6

InstallCodecMethod · 0.95
NewReadHandlerFunction · 0.92
NewParserFunction · 0.92
NewWriteHandlerFunction · 0.92
NewOTLPWriteHandlerFunction · 0.92
NewOpenAPIBuilderFunction · 0.85

Tested by 2

newTestAPIFunction · 0.68
createPrometheusAPIFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…