Skip to content

Commit

Permalink
Merge pull request #139 from osstotalsoft/feature/addConditionsForSub…
Browse files Browse the repository at this point in the history
…scription

added conditions for scubscriptions
  • Loading branch information
andra-sava authored Aug 21, 2024
2 parents 0738b5f + 2223fdb commit 95fc1ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
scalar Upload
type Query
type Mutation
<%_ if(addSubscriptions){ _%>
type Subscription

<%_}_%>

schema {
query: Query
mutation: Mutation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@ const requestDuration = meter.createHistogram('gql_request_duration', {
unit: 'milliseconds',
valueType: ValueType.INT
})

const requestDurationSeconds = meter.createHistogram('gql_request_duration_seconds', {
description: 'The total duration of a request (in seconds).',
unit: 'seconds',
valueType: ValueType.DOUBLE
})


<%_ if(addSubscriptions){ _%>
const subscriptionStarted =
meter.createCounter('gql_subscription_started', { description: 'The number of subscriptions.' });

<%_}_%>
async function startServer(logger) {
await exporter.startServer();
logger.info(
Expand Down Expand Up @@ -115,17 +116,19 @@ function recordRequestDuration(duration, context) {
})
}

<%_ if(addSubscriptions){ _%>
function recordSubscriptionStarted(context, message) {
subscriptionStarted.add(1, {
operationName: message?.payload?.operationName,
operationType: message?.type
});
}
<%_}_%>

module.exports = {
startServer,
recordRequestDuration,
recordRequestStarted,
recordRequestFailed,
recordSubscriptionStarted
recordRequestFailed <%_ if(addSubscriptions){ _%>,
recordSubscriptionStarted <%_}_%>
}

0 comments on commit 95fc1ed

Please sign in to comment.