-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into iain/multi-region-config
- Loading branch information
Showing
32 changed files
with
351 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/server/assets/multiregion/typedefs/multiregion.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
type ServerRegionItem { | ||
id: String! | ||
key: String! | ||
name: String! | ||
description: String! | ||
} | ||
|
||
input CreateServerRegionInput { | ||
key: String! | ||
name: String! | ||
description: String! | ||
} | ||
|
||
type ServerRegionMutations { | ||
create(input: CreateServerRegionInput!): ServerRegionItem! | ||
} | ||
|
||
type ServerInfoMutations { | ||
multiRegion: ServerRegionMutations! | ||
} | ||
|
||
extend type Mutation { | ||
serverInfoMutations: ServerInfoMutations! | ||
@hasServerRole(role: SERVER_ADMIN) | ||
@hasScope(scope: "server:setup") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* istanbul ignore file */ | ||
import { logger } from '@/logging/logging' | ||
import type { Nullable } from '@speckle/shared' | ||
import prometheusClient from 'prom-client' | ||
import type express from 'express' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let metricErrorCount: Nullable<prometheusClient.Counter<any>> = null | ||
|
||
export const errorLoggingMiddleware: express.ErrorRequestHandler = ( | ||
err, | ||
req, | ||
res, | ||
next | ||
) => { | ||
if (metricErrorCount === null) { | ||
metricErrorCount = new prometheusClient.Counter({ | ||
name: 'speckle_server_request_errors', | ||
help: 'Number of requests that threw exceptions', | ||
labelNames: ['route'] | ||
}) | ||
} | ||
|
||
logger.error(err, `Error when handling ${req.originalUrl} from ${req.ip}`) | ||
let route = 'unknown' | ||
if (req.route && req.route.path) route = req.route.path | ||
metricErrorCount.labels(route).inc() | ||
next(err) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* istanbul ignore file */ | ||
import type { Nullable } from '@speckle/shared' | ||
import prometheusClient from 'prom-client' | ||
import type http from 'http' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let metricActiveConnections: Nullable<prometheusClient.Gauge<any>> = null | ||
|
||
export const monitorActiveConnections = (httpServer: http.Server) => { | ||
if (metricActiveConnections !== null) { | ||
prometheusClient.register.removeSingleMetric('speckle_server_active_connections') | ||
} | ||
|
||
metricActiveConnections = new prometheusClient.Gauge({ | ||
name: 'speckle_server_active_connections', | ||
help: 'Number of active http connections', | ||
async collect() { | ||
let connectionCount = await new Promise<number>((resolve) => { | ||
httpServer.getConnections(function (error, count) { | ||
if (error) resolve(-1) | ||
else resolve(count) | ||
}) | ||
}) | ||
if (isNaN(connectionCount)) connectionCount = -1 | ||
this.set(connectionCount) | ||
} | ||
}) | ||
} |
21 changes: 9 additions & 12 deletions
21
packages/server/logging/index.js → packages/server/logging/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.