Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@newrelic/apollo-server-plugin

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newrelic/apollo-server-plugin - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

74

lib/create-plugin.js

@@ -15,3 +15,2 @@ /*

const ANON_PLACEHOLDER = '<anonymous>'
const UNKNOWN_OPERATION = '<unknown>'

@@ -24,2 +23,4 @@ const CATEGORY = 'GraphQL'

const DEFAULT_OPERATION_NAME = `${OPERATION_PREFIX}/<unknown>`
const FIELD_NAME_ATTR = 'graphql.field.name'

@@ -91,3 +92,3 @@ const RETURN_TYPE_ATTR = 'graphql.field.returnType'

const operationSegment = instrumentationApi.createSegment(
UNKNOWN_OPERATION,
DEFAULT_OPERATION_NAME,
recordOperationSegment,

@@ -105,2 +106,34 @@ requestParent

return {
/**
* The document AST has been parsed so we can attempt to name the operation
* and update the transaction name based on operation
*/
validationDidStart(validationContext) {
const operationDetails = getOperationDetails(validationContext)
if (operationDetails) {
const { operationName, operationType, deepestUniquePath, cleanedQuery } =
operationDetails
operationSegment.addAttribute(OPERATION_QUERY_ATTR, cleanedQuery)
operationSegment.addAttribute(OPERATION_TYPE_ATTR, operationType)
if (operationName) {
operationSegment.addAttribute(OPERATION_NAME_ATTR, operationName)
}
const formattedName = operationName || ANON_PLACEHOLDER
let formattedOperation = `${operationType}/${formattedName}`
// Certain requests, such as introspection, won't hit any resolvers
if (deepestUniquePath) {
formattedOperation += `/${deepestUniquePath}`
}
const segmentName = formattedOperation
const transactionName = formattedOperation
setTransactionName(operationSegment.transaction, transactionName)
operationSegment.name = `${OPERATION_PREFIX}/${segmentName}`
}
},
didResolveOperation(resolveContext) {

@@ -191,35 +224,8 @@ if (shouldIgnoreTransaction(resolveContext.operation, config, logger)) {

},
willSendResponse(responseContext) {
// default. only used if failed to parse
let transactionName = '*'
let segmentName = UNKNOWN_OPERATION
const operationDetails = getOperationDetails(responseContext)
if (operationDetails) {
const { operationName, operationType, deepestUniquePath, cleanedQuery } =
operationDetails
operationSegment.addAttribute(OPERATION_QUERY_ATTR, cleanedQuery)
operationSegment.addAttribute(OPERATION_TYPE_ATTR, operationType)
if (operationName) {
operationSegment.addAttribute(OPERATION_NAME_ATTR, operationName)
}
const formattedName = operationName || ANON_PLACEHOLDER
let formattedOperation = `${operationType}/${formattedName}`
// Certain requests, such as introspection, won't hit any resolvers
if (deepestUniquePath) {
formattedOperation += `/${deepestUniquePath}`
}
segmentName = formattedOperation
transactionName = formattedOperation
willSendResponse() {
// check if operation segment was never updated from default name
// If so, update the transaction name to `*`
if (operationSegment.name === DEFAULT_OPERATION_NAME) {
setTransactionName(operationSegment.transaction, '*')
}
setTransactionName(operationSegment.transaction, transactionName)
operationSegment.name = `${OPERATION_PREFIX}/${segmentName}`
operationSegment.end()

@@ -226,0 +232,0 @@

@@ -32,2 +32,3 @@ /*

noticeError(instrumentationApi, error) {
error = error.originalError || error
const activeSegment = instrumentationApi.getActiveSegment()

@@ -34,0 +35,0 @@ const transaction = activeSegment && activeSegment.transaction

{
"name": "@newrelic/apollo-server-plugin",
"version": "1.2.1",
"version": "1.2.2",
"description": "Apollo Server plugin that adds New Relic Node.js agent instrumentation.",

@@ -5,0 +5,0 @@ "main": "./index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc