@envelop/prometheus
Advanced tools
Comparing version 9.3.1 to 9.4.0-alpha-20240313140050-1eb56cf5
@@ -17,13 +17,17 @@ "use strict"; | ||
let typeInfo = null; | ||
const parseHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'parse', 'graphql_envelop_phase_parse', 'Time spent on running GraphQL "parse" function'); | ||
const validateHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'validate', 'graphql_envelop_phase_validate', 'Time spent on running GraphQL "validate" function'); | ||
const contextBuildingHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'contextBuilding', 'graphql_envelop_phase_context', 'Time spent on building the GraphQL context'); | ||
const executeHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'execute', 'graphql_envelop_phase_execute', 'Time spent on running the GraphQL "execute" function'); | ||
const subscribeHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'subscribe', 'graphql_envelop_phase_subscribe', 'Time spent on running the GraphQL "subscribe" function'); | ||
const parseHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'parse', typeof config.parse === 'string' ? config.parse : 'graphql_envelop_phase_parse', 'Time spent on running GraphQL "parse" function'); | ||
const validateHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'validate', typeof config.validate === 'string' ? config.validate : 'graphql_envelop_phase_validate', 'Time spent on running GraphQL "validate" function'); | ||
const contextBuildingHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'contextBuilding', typeof config.contextBuilding === 'string' | ||
? config.contextBuilding | ||
: 'graphql_envelop_phase_context', 'Time spent on building the GraphQL context'); | ||
const executeHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'execute', typeof config.execute === 'string' ? config.execute : 'graphql_envelop_phase_execute', 'Time spent on running the GraphQL "execute" function'); | ||
const subscribeHistogram = (0, utils_js_1.getHistogramFromConfig)(config, 'subscribe', typeof config.subscribe === 'string' ? config.subscribe : 'graphql_envelop_phase_subscribe', 'Time spent on running the GraphQL "subscribe" function'); | ||
const resolversHistogram = typeof config.resolvers === 'object' | ||
? config.resolvers | ||
: config.resolvers === true | ||
: config.resolvers === true || typeof config.resolvers === 'string' | ||
? (0, utils_js_1.createHistogram)({ | ||
histogram: new prom_client_1.Histogram({ | ||
name: 'graphql_envelop_execute_resolver', | ||
name: typeof config.resolvers === 'string' | ||
? config.resolvers | ||
: 'graphql_envelop_execute_resolver', | ||
help: 'Time spent on running the GraphQL resolvers', | ||
@@ -50,6 +54,8 @@ labelNames: [ | ||
? config.requestTotalDuration | ||
: config.requestTotalDuration === true | ||
: config.requestTotalDuration === true || typeof config.requestTotalDuration === 'string' | ||
? (0, utils_js_1.createHistogram)({ | ||
histogram: new prom_client_1.Histogram({ | ||
name: 'graphql_envelop_request_duration', | ||
name: typeof config.requestTotalDuration === 'string' | ||
? config.requestTotalDuration | ||
: 'graphql_envelop_request_duration', | ||
help: 'Time spent on running the GraphQL operation from parse to execute', | ||
@@ -67,6 +73,8 @@ labelNames: ['operationType', 'operationName'].filter(label => (0, utils_js_1.labelExists)(config, label)), | ||
? config.requestSummary | ||
: config.requestSummary === true | ||
: config.requestSummary === true || typeof config.requestSummary === 'string' | ||
? (0, utils_js_1.createSummary)({ | ||
summary: new prom_client_1.Summary({ | ||
name: 'graphql_envelop_request_time_summary', | ||
name: typeof config.requestSummary === 'string' | ||
? config.requestSummary | ||
: 'graphql_envelop_request_time_summary', | ||
help: 'Summary to measure the time to complete GraphQL operations', | ||
@@ -84,6 +92,6 @@ labelNames: ['operationType', 'operationName'].filter(label => (0, utils_js_1.labelExists)(config, label)), | ||
? config.errors | ||
: config.errors === true | ||
: config.errors === true || typeof config.errors === 'string' | ||
? (0, utils_js_1.createCounter)({ | ||
counter: new prom_client_1.Counter({ | ||
name: 'graphql_envelop_error_result', | ||
name: typeof config.errors === 'string' ? config.errors : 'graphql_envelop_error_result', | ||
help: 'Counts the amount of errors reported from all phases', | ||
@@ -103,6 +111,8 @@ labelNames: ['operationType', 'operationName', 'path', 'phase'].filter(label => (0, utils_js_1.labelExists)(config, label)), | ||
? config.requestCount | ||
: config.requestCount === true | ||
: config.requestCount === true || typeof config.requestCount === 'string' | ||
? (0, utils_js_1.createCounter)({ | ||
counter: new prom_client_1.Counter({ | ||
name: 'graphql_envelop_request', | ||
name: typeof config.requestCount === 'string' | ||
? config.requestCount | ||
: 'graphql_envelop_request', | ||
help: 'Counts the amount of GraphQL requests executed through Envelop', | ||
@@ -120,6 +130,8 @@ labelNames: ['operationType', 'operationName'].filter(label => (0, utils_js_1.labelExists)(config, label)), | ||
? config.deprecatedFields | ||
: config.deprecatedFields === true | ||
: config.deprecatedFields === true || typeof config.deprecatedFields === 'string' | ||
? (0, utils_js_1.createCounter)({ | ||
counter: new prom_client_1.Counter({ | ||
name: 'graphql_envelop_deprecated_field', | ||
name: typeof config.deprecatedFields === 'string' | ||
? config.deprecatedFields | ||
: 'graphql_envelop_deprecated_field', | ||
help: 'Counts the amount of deprecated fields used in selection sets', | ||
@@ -139,6 +151,8 @@ labelNames: ['operationType', 'operationName', 'fieldName', 'typeName'].filter(label => (0, utils_js_1.labelExists)(config, label)), | ||
? config.schemaChangeCount | ||
: config.schemaChangeCount === true | ||
: config.schemaChangeCount === true || typeof config.schemaChangeCount === 'string' | ||
? (0, utils_js_1.createCounter)({ | ||
counter: new prom_client_1.Counter({ | ||
name: 'graphql_envelop_schema_change', | ||
name: typeof config.schemaChangeCount === 'string' | ||
? config.schemaChangeCount | ||
: 'graphql_envelop_schema_change', | ||
help: 'Counts the amount of schema changes', | ||
@@ -145,0 +159,0 @@ registers: [config.registry || prom_client_1.register], |
@@ -12,13 +12,17 @@ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ | ||
let typeInfo = null; | ||
const parseHistogram = getHistogramFromConfig(config, 'parse', 'graphql_envelop_phase_parse', 'Time spent on running GraphQL "parse" function'); | ||
const validateHistogram = getHistogramFromConfig(config, 'validate', 'graphql_envelop_phase_validate', 'Time spent on running GraphQL "validate" function'); | ||
const contextBuildingHistogram = getHistogramFromConfig(config, 'contextBuilding', 'graphql_envelop_phase_context', 'Time spent on building the GraphQL context'); | ||
const executeHistogram = getHistogramFromConfig(config, 'execute', 'graphql_envelop_phase_execute', 'Time spent on running the GraphQL "execute" function'); | ||
const subscribeHistogram = getHistogramFromConfig(config, 'subscribe', 'graphql_envelop_phase_subscribe', 'Time spent on running the GraphQL "subscribe" function'); | ||
const parseHistogram = getHistogramFromConfig(config, 'parse', typeof config.parse === 'string' ? config.parse : 'graphql_envelop_phase_parse', 'Time spent on running GraphQL "parse" function'); | ||
const validateHistogram = getHistogramFromConfig(config, 'validate', typeof config.validate === 'string' ? config.validate : 'graphql_envelop_phase_validate', 'Time spent on running GraphQL "validate" function'); | ||
const contextBuildingHistogram = getHistogramFromConfig(config, 'contextBuilding', typeof config.contextBuilding === 'string' | ||
? config.contextBuilding | ||
: 'graphql_envelop_phase_context', 'Time spent on building the GraphQL context'); | ||
const executeHistogram = getHistogramFromConfig(config, 'execute', typeof config.execute === 'string' ? config.execute : 'graphql_envelop_phase_execute', 'Time spent on running the GraphQL "execute" function'); | ||
const subscribeHistogram = getHistogramFromConfig(config, 'subscribe', typeof config.subscribe === 'string' ? config.subscribe : 'graphql_envelop_phase_subscribe', 'Time spent on running the GraphQL "subscribe" function'); | ||
const resolversHistogram = typeof config.resolvers === 'object' | ||
? config.resolvers | ||
: config.resolvers === true | ||
: config.resolvers === true || typeof config.resolvers === 'string' | ||
? createHistogram({ | ||
histogram: new Histogram({ | ||
name: 'graphql_envelop_execute_resolver', | ||
name: typeof config.resolvers === 'string' | ||
? config.resolvers | ||
: 'graphql_envelop_execute_resolver', | ||
help: 'Time spent on running the GraphQL resolvers', | ||
@@ -45,6 +49,8 @@ labelNames: [ | ||
? config.requestTotalDuration | ||
: config.requestTotalDuration === true | ||
: config.requestTotalDuration === true || typeof config.requestTotalDuration === 'string' | ||
? createHistogram({ | ||
histogram: new Histogram({ | ||
name: 'graphql_envelop_request_duration', | ||
name: typeof config.requestTotalDuration === 'string' | ||
? config.requestTotalDuration | ||
: 'graphql_envelop_request_duration', | ||
help: 'Time spent on running the GraphQL operation from parse to execute', | ||
@@ -62,6 +68,8 @@ labelNames: ['operationType', 'operationName'].filter(label => labelExists(config, label)), | ||
? config.requestSummary | ||
: config.requestSummary === true | ||
: config.requestSummary === true || typeof config.requestSummary === 'string' | ||
? createSummary({ | ||
summary: new Summary({ | ||
name: 'graphql_envelop_request_time_summary', | ||
name: typeof config.requestSummary === 'string' | ||
? config.requestSummary | ||
: 'graphql_envelop_request_time_summary', | ||
help: 'Summary to measure the time to complete GraphQL operations', | ||
@@ -79,6 +87,6 @@ labelNames: ['operationType', 'operationName'].filter(label => labelExists(config, label)), | ||
? config.errors | ||
: config.errors === true | ||
: config.errors === true || typeof config.errors === 'string' | ||
? createCounter({ | ||
counter: new Counter({ | ||
name: 'graphql_envelop_error_result', | ||
name: typeof config.errors === 'string' ? config.errors : 'graphql_envelop_error_result', | ||
help: 'Counts the amount of errors reported from all phases', | ||
@@ -98,6 +106,8 @@ labelNames: ['operationType', 'operationName', 'path', 'phase'].filter(label => labelExists(config, label)), | ||
? config.requestCount | ||
: config.requestCount === true | ||
: config.requestCount === true || typeof config.requestCount === 'string' | ||
? createCounter({ | ||
counter: new Counter({ | ||
name: 'graphql_envelop_request', | ||
name: typeof config.requestCount === 'string' | ||
? config.requestCount | ||
: 'graphql_envelop_request', | ||
help: 'Counts the amount of GraphQL requests executed through Envelop', | ||
@@ -115,6 +125,8 @@ labelNames: ['operationType', 'operationName'].filter(label => labelExists(config, label)), | ||
? config.deprecatedFields | ||
: config.deprecatedFields === true | ||
: config.deprecatedFields === true || typeof config.deprecatedFields === 'string' | ||
? createCounter({ | ||
counter: new Counter({ | ||
name: 'graphql_envelop_deprecated_field', | ||
name: typeof config.deprecatedFields === 'string' | ||
? config.deprecatedFields | ||
: 'graphql_envelop_deprecated_field', | ||
help: 'Counts the amount of deprecated fields used in selection sets', | ||
@@ -134,6 +146,8 @@ labelNames: ['operationType', 'operationName', 'fieldName', 'typeName'].filter(label => labelExists(config, label)), | ||
? config.schemaChangeCount | ||
: config.schemaChangeCount === true | ||
: config.schemaChangeCount === true || typeof config.schemaChangeCount === 'string' | ||
? createCounter({ | ||
counter: new Counter({ | ||
name: 'graphql_envelop_schema_change', | ||
name: typeof config.schemaChangeCount === 'string' | ||
? config.schemaChangeCount | ||
: 'graphql_envelop_schema_change', | ||
help: 'Counts the amount of schema changes', | ||
@@ -140,0 +154,0 @@ registers: [config.registry || defaultRegistry], |
{ | ||
"name": "@envelop/prometheus", | ||
"version": "9.3.1", | ||
"version": "9.4.0-alpha-20240313140050-1eb56cf5", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
import { Registry } from 'prom-client'; | ||
import { createCounter, createHistogram, createSummary } from './utils.js'; | ||
export type PrometheusTracingPluginConfig = { | ||
requestCount?: boolean | ReturnType<typeof createCounter>; | ||
requestTotalDuration?: boolean | ReturnType<typeof createHistogram>; | ||
requestSummary?: boolean | ReturnType<typeof createSummary>; | ||
parse?: boolean | ReturnType<typeof createHistogram>; | ||
validate?: boolean | ReturnType<typeof createHistogram>; | ||
contextBuilding?: boolean | ReturnType<typeof createHistogram>; | ||
execute?: boolean | ReturnType<typeof createHistogram>; | ||
subscribe?: boolean | ReturnType<typeof createHistogram>; | ||
errors?: boolean | ReturnType<typeof createCounter>; | ||
resolvers?: boolean | ReturnType<typeof createHistogram>; | ||
requestCount?: boolean | string | ReturnType<typeof createCounter>; | ||
requestTotalDuration?: boolean | string | ReturnType<typeof createHistogram>; | ||
requestSummary?: boolean | string | ReturnType<typeof createSummary>; | ||
parse?: boolean | string | ReturnType<typeof createHistogram>; | ||
validate?: boolean | string | ReturnType<typeof createHistogram>; | ||
contextBuilding?: boolean | string | ReturnType<typeof createHistogram>; | ||
execute?: boolean | string | ReturnType<typeof createHistogram>; | ||
subscribe?: boolean | string | ReturnType<typeof createHistogram>; | ||
errors?: boolean | string | ReturnType<typeof createCounter>; | ||
resolvers?: boolean | string | ReturnType<typeof createHistogram>; | ||
resolversWhitelist?: string[]; | ||
deprecatedFields?: boolean | ReturnType<typeof createCounter>; | ||
deprecatedFields?: boolean | string | ReturnType<typeof createCounter>; | ||
registry?: Registry; | ||
skipIntrospection?: boolean; | ||
schemaChangeCount?: boolean | ReturnType<typeof createCounter>; | ||
schemaChangeCount?: boolean | string | ReturnType<typeof createCounter>; | ||
labels?: { | ||
@@ -20,0 +20,0 @@ operationName?: boolean; |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
62270
1053
2