UNPKG

newrelic

Version:
923 lines (886 loc) 28.1 kB
/* * Copyright 2020 New Relic Corporation. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ 'use strict' /** * This file includes all of the configuration variables used by the Node.js * module. If there's a configurable element of the module and it's not * described in here, there's been a terrible mistake. */ exports.config = () => ({ /** * Array of application names. * * @env NEW_RELIC_APP_NAME */ app_name: [], /** * The user's license key. Must be set by per-app configuration file. * * @env NEW_RELIC_LICENSE_KEY */ license_key: '', /** * * Enables/Disables security politices. Paste your security policies * token from the New Relic Admin below. * * @env NEW_RELIC_SECURITY_POLICIES_TOKEN */ security_policies_token: '', /** * Hostname for the New Relic collector proxy. * * You shouldn't need to change this. * * @env NEW_RELIC_HOST */ host: '', /** * The port on which the collector proxy will be listening. * * You shouldn't need to change this. * * @env NEW_RELIC_PORT */ port: 443, /** * Whether or not to use SSL to connect to New Relic's servers. * * NOTE: This option can no longer be disabled. * * @env NEW_RELIC_USE_SSL */ ssl: true, /** * Proxy url * * A proxy url can be used in place of setting * proxy_host, proxy_port, proxy_user, and proxy_pass. * * e.g. http://user:pass@host:port/ * * Setting proxy will override other proxy settings. * * @env NEW_RELIC_PROXY_URL */ proxy: '', /** * Proxy host to use to connect to the internet. * * @env NEW_RELIC_PROXY_HOST */ proxy_host: '', /** * Proxy port to use to connect to the internet. * * @env NEW_RELIC_PROXY_PORT */ proxy_port: '', /** * Proxy user name when required. * * @env NEW_RELIC_PROXY_USER */ proxy_user: '', /** * Proxy password when required. * * @env NEW_RELIC_PROXY_PASS */ proxy_pass: '', // Serverless DT config defaults trusted_account_key: null, primary_application_id: null, account_id: null, /** * Custom SSL certificates * * If your proxy uses a custom SSL certificate, you can add the CA text to * this array, one entry per certificate. * * The easiest way to do this is with `fs.readFileSync` e.g. * * certificates: [ * require('fs').readFileSync('custom.crt', 'utf8') // don't forget the utf8 * ] * */ certificates: [], /** * Whether the module is enabled. * * @env NEW_RELIC_ENABLED */ agent_enabled: true, /** * The default Apdex tolerating / threshold value for applications, in * seconds. The default for Node is apdexT to 100 milliseconds, which is * lower than New Relic standard, but Node.js applications tend to be more * latency-sensitive than most. * * NOTE: This setting can not be modified locally. Use server-side configuration * to change your application's apdex. * * @see https://docs.newrelic.com/docs/apm/new-relic-apm/apdex/changing-your-apdex-settings */ apdex_t: 0.100, /** * When true, all request headers except for those listed in attributes.exclude * will be captured for all traces, unless otherwise specified in a destination's * attributes include/exclude lists. */ allow_all_headers: false, /** * Attributes are key-value pairs containing information that determines * the properties of an event or transaction. */ attributes: { /** * If `true`, enables capture of attributes for all destinations. * If there are specific parameters you want ignored, use `attributes.exclude`. * * @env NEW_RELIC_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude from all destinations. Allows * as wildcard at end. * * NOTE: If excluding headers, they must be in camelCase form to be filtered. * * @env NEW_RELIC_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in all destinations. Allows * as wildcard at end. * * NOTE: If including headers, they must be in camelCase form to be filtered. * * @env NEW_RELIC_ATTRIBUTES_INCLUDE */ include: [], /** * If `true`, patterns may be added to the `attributes.include` * list. * * @env NEW_RELIC_ATTRIBUTES_INCLUDE_ENABLED */ include_enabled: true, /** * Controls how many attribute include/exclude rule results are cached by * the filter. Increasing this limit will cause greater memory usage and is * only necessary if you have an extremely high variety of attributes. */ filter_cache_limit: 1000 }, logging: { /** * Verbosity of the module's logging. This module uses bunyan * (https://github.com/trentm/node-bunyan) for its logging, and as such the * valid logging levels are 'fatal', 'error', 'warn', 'info', 'debug' and * 'trace'. Logging at levels 'info' and higher is very terse. For support * requests, attaching logs captured at 'trace' level are extremely helpful * in chasing down bugs. * * @env NEW_RELIC_LOG_LEVEL */ level: 'info', /** * Where to put the log file -- by default just uses process.cwd + * 'newrelic_agent.log'. A special case is a filepath of 'stdout', * in which case all logging will go to stdout, or 'stderr', in which * case all logging will go to stderr. * * @env NEW_RELIC_LOG */ filepath: require('path').join(process.cwd(), 'newrelic_agent.log'), /** * Whether to write to a log file at all * * @env NEW_RELIC_LOG_ENABLED */ enabled: true, /** * Enables extra debugging at `warn` level. No need to enable except under * specific debugging conditions. */ diagnostics: false }, audit_log: { /** * Enables logging of out bound traffic from the Agent to the Collector. * This field is ignored if trace level logging is enabled. * With trace logging, all traffic is logged. * * @env NEW_RELIC_AUDIT_LOG_ENABLED */ enabled: false, /** * Specify which methods are logged. Used in conjunction with the audit_log flag * If audit_log is enabled and this property is empty, all methods will be logged * Otherwise, if the audit log is enabled, only the methods specified * in the filter will be logged * Methods include: error_data, metric_data, and analytic_event_data * * @env NEW_RELIC_AUDIT_LOG_ENDPOINTS */ endpoints: [] }, /** * Whether to collect & submit error traces to New Relic. * * @env NEW_RELIC_ERROR_COLLECTOR_ENABLED */ error_collector: { attributes: { /** * If `true`, the agent captures attributes from error collection. * * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude from error collection. * Allows * as wildcard at end. * * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in error collection. * Allows * as wildcard at end. * * @env NEW_RELIC_ERROR_COLLECTOR_ATTRIBUTES_INCLUDE */ include: [] }, /** * Disabling the error tracer just means that errors aren't collected * and sent to New Relic -- it DOES NOT remove any instrumentation. */ enabled: true, /** * List of HTTP error status codes the error tracer should disregard. * Ignoring a status code means that the transaction is not renamed to * match the code, and the request is not treated as an error by the error * collector. * * NOTE: This configuration value has no effect on errors recorded using * `noticeError()`. * * Defaults to 404 NOT FOUND. * * @env NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERROR_CODES */ ignore_status_codes: [404], /** * Whether error events are collected. */ capture_events: true, /** * The agent will collect all error events up to this number per minute. * If there are more than that, a statistical sampling will be collected. * Currently this uses a priority sampling algorithm. * * By increasing this setting you are both increasing the memory * requirements of the agent as well as increasing the payload to the New * Relic servers. The memory concerns are something you should consider for * your own server's sake. The payload of events is compressed, but if it * grows too large the New Relic servers may reject it. */ max_event_samples_stored: 100, expected_classes: [], expected_messages: {}, expected_status_codes: [], ignore_classes:[], ignore_messages:{} }, /** * Error message redaction * * Options regarding how the agent handles the redaction of error messages. * */ strip_exception_messages: { /** * When `true`, the agent will redact the messages of captured * errors. * * @env NEW_RELIC_STRIP_EXCEPTION_MESSAGES_ENABLED */ enabled: false }, /** * Options regarding collecting system information. Used for system * utilization based pricing scheme. */ utilization: { /** * This flag dictates whether the agent attempts to reach out to AWS * to get info about the vm the process is running on. * * @env NEW_RELIC_UTILIZATION_DETECT_AWS */ detect_aws: true, /** * This flag dictates whether the agent attempts to detect if the * the process is running on Pivotal Cloud Foundry. * * @env NEW_RELIC_UTILIZATION_DETECT_PCF */ detect_pcf: true, /** * This flag dictates whether the agent attempts to reach out to Azure to * get info about the vm the process is running on. * * @env NEW_RELIC_UTILIZATION_DETECT_AZURE */ detect_azure: true, /** * This flag dictates whether the agent attempts to read files * to get info about the container the process is running in. * * @env NEW_RELIC_UTILIZATION_DETECT_DOCKER */ detect_docker: true, /** * This flag dictates whether the agent attempts to reach out to GCP * to get info about the vm the process is running on. * * @env NEW_RELIC_UTILIZATION_DETECT_GCP */ detect_gcp: true, /** * This flag dictates whether the agent attempts to reach out to * Kubernetes to get info about the container the process is running on. * * @env NEW_RELIC_UTILIZATION_DETECT_KUBERNETES */ detect_kubernetes: true }, transaction_tracer: { attributes: { /** * If `true`, the agent captures attributes from transaction traces. * * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude from transaction traces. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in transaction traces. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_TRACER_ATTRIBUTES_INCLUDE */ include: [] }, /** * Whether to collect & submit slow transaction traces to New Relic. The * instrumentation is loaded regardless of this setting, as it's necessary * to gather metrics. Disable the agent to prevent the instrumentation from * loading. * * @env NEW_RELIC_TRACER_ENABLED */ enabled: true, /** * The duration at below which the slow transaction tracer should collect a * transaction trace. If set to 'apdex_f', the threshold will be set to * 4 * apdex_t, which with a default apdex_t value of 500 milliseconds will * be 2 seconds. * * If a time is provided, it is set in seconds. * * @env NEW_RELIC_TRACER_THRESHOLD */ transaction_threshold: 'apdex_f', /** * Increase this parameter to increase the diversity of the slow * transaction traces recorded by your application over time. Confused? * Read on. * * Transactions are named based on the request (see the README for the * details of how requests are mapped to transactions), and top_n refers to * the "top n slowest transactions" grouped by these names. The module will * only replace a recorded trace with a new trace if the new trace is * slower than the previous slowest trace of that name. The default value * for this setting is 20, as the transaction trace view page also defaults * to showing the 20 slowest transactions. * * If you want to record the absolute slowest transaction over the last * minute, set top_n to 0 or 1. This used to be the default, and has a * problem in that it will allow one very slow route to dominate your slow * transaction traces. * * The module will always record at least 5 different slow transactions in * the reporting periods after it starts up, and will reset its internal * slow trace aggregator if no slow transactions have been recorded for the * last 5 harvest cycles, restarting the aggregation process. * * @env NEW_RELIC_TRACER_TOP_N */ top_n: 20, /** * This option affects both slow-queries and record_sql for transaction * traces. It can have one of 3 values: 'off', 'obfuscated' or 'raw' * When it is 'off' no slow queries will be captured, and backtraces * and sql will not be included in transaction traces. If it is 'raw' * or 'obfuscated' and other criteria (slow_sql.enabled etc) are met * for a query. The raw or obfuscated sql will be included in the * transaction trace and a slow query sample will be collected. * * @env NEW_RELIC_RECORD_SQL */ record_sql: 'off', /** * This option affects both slow-queries and record_sql for transaction * traces. This is the minimum duration a query must take (in ms) for it * to be considered for for slow query and inclusion in transaction traces. */ explain_threshold: 500, /** * This option controls the enumerability of internal properties the agent * puts on application objects such as requests and promises while tracing. * When `true`, these properties will be configured with `enumerable: false` * using `Object.defineProperty`. * * XXX: This can have a significant impact on application performance, so if * this is not necessary for your application we recommend disabling the * feature. * * @env NEW_RELIC_HIDE_INTERNALS */ hide_internals: true }, /** * Rules for naming or ignoring transactions. */ rules: { /** * A list of rules of the format {pattern: 'pattern', name: 'name'} for * matching incoming request URLs and naming the associated New Relic * transactions. Both pattern and name are required. Additional attributes * are ignored. Patterns may have capture groups (following JavaScript * conventions), and names will use $1-style replacement strings. See * the documentation for addNamingRule for important caveats. * * @env NEW_RELIC_NAMING_RULES */ name: [], /** * A list of patterns for matching incoming request URLs to be ignored by * the agent. Patterns may be strings or regular expressions. * * By default, socket.io long-polling is ignored. * * @env NEW_RELIC_IGNORING_RULES */ ignore: [ '^\/socket\.io\/.*\/xhr-polling/' ] }, /** * By default, any transactions that are not affected by other bits of * naming logic (the API, rules, or metric normalization rules) will * have their names set to 'NormalizedUri/*'. Setting this value to * false will set them instead to Uri/path/to/resource. Don't change * this setting unless you understand the implications of New Relic's * metric grouping issues and are confident your application isn't going * to run afoul of them. Your application could end up getting blocked! * Nobody wants that. * * @env NEW_RELIC_ENFORCE_BACKSTOP */ enforce_backstop: true, /** * Browser Monitoring * * Browser monitoring lets you correlate transactions between the server and browser * giving you accurate data on how long a page request takes, from request, * through the server response, up until the actual page render completes. */ browser_monitoring: { attributes: { /** * If `true`, the agent captures attributes from browser monitoring. * * @env NEW_RELIC_BROWSER_MONITOR_ATTRIBUTES */ enabled: false, /** * Prefix of attributes to exclude from browser monitoring. * Allows * as wildcard at end. * * @env NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in browser monitoring. * Allows * as wildcard at end. * * @env NEW_RELIC_BROWSER_MONITORING_ATTRIBUTES_INCLUDE */ include: [] }, /** * Enable browser monitoring header generation. * * This does not auto-instrument, rather it enables the agent to generate headers. * The newrelic module can generate the appropriate <script> header, but you must * inject the header yourself, or use a module that does so. * * Usage: * * var newrelic = require('newrelic'); * * router.get('/', function (req, res) { * var header = newrelic.getBrowserTimingHeader(); * res.write(header) * // write the rest of the page * }); * * This generates the <script>...</script> header necessary for Browser Monitoring * This script must be manually injected into your templates, as high as possible * in the header, but _after_ any X-UA-COMPATIBLE HTTP-EQUIV meta tags. * Otherwise you may hurt IE! * * This method must be called _during_ a transaction, and must be called every * time you want to generate the headers. * * Do *not* reuse the headers between users, or even between requests. * * @env NEW_RELIC_BROWSER_MONITOR_ENABLE */ enable: true, /** * Request un-minified sources from the server. * * @env NEW_RELIC_BROWSER_MONITOR_DEBUG */ debug: false }, /** * API Configuration * * Some API end points can be turned off via configuration settings to * allow for more flexible security options. All API configuration * options are disabled when high-security mode is enabled. */ api: { /** * Controls for the `API.addCustomAttribute` method. * * @env NEW_RELIC_API_CUSTOM_ATTRIBUTES */ custom_attributes_enabled: true, /** * Controls for the `API.recordCustomEvent` method. * * @env NEW_RELIC_API_CUSTOM_EVENTS */ custom_events_enabled: true, /** * Controls for the `API.noticeError` method. * * @env NEW_RELIC_API_NOTICE_ERROR */ notice_error_enabled: true, }, /** * Transaction Events * * Transaction events are sent to New Relic Insights. This event data * includes transaction timing, transaction name, and any custom parameters. * * Read more here: http://newrelic.com/insights */ transaction_events: { attributes: { /** * If `true`, the agent captures attributes from transaction events. * * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude in transaction events. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in transaction events. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_INCLUDE */ include: [] }, /** * If this is disabled, the agent does not collect, nor try to send, * analytic data. */ enabled: true, /** * The agent will collect all events up to this number per minute. If * there are more than that, a statistical sampling will be collected. */ max_samples_stored: 10000 }, /** * Custom Insights Events * * Custom insights events are JSON object that are sent to New Relic * Insights. You can tell the agent to send your custom events via the * `newrelic.recordCustomEvent()` API. These events are sampled once the max * queue size is reached. You can tune this setting below. * * Read more here: http://newrelic.com/insights */ custom_insights_events: { /** * If this is disabled, the agent does not collect, nor try to send, custom * event data. */ enabled: true, /** * The agent will collect all events up to this number per minute. If there * are more than that, a statistical sampling will be collected. Currently * this uses a priority sampling algorithm. * * By increasing this setting you are both increasing the memory * requirements of the agent as well as increasing the payload to the New * Relic servers. The memory concerns are something you should consider for * your own server's sake. The payload of events is compressed, but if it * grows too large the New Relic servers may reject it. */ max_samples_stored: 1000 }, /** * This is used to configure properties about the user's host name. */ process_host: { /** * Configurable display name for hosts * * @env NEW_RELIC_PROCESS_HOST_DISPLAY_NAME */ display_name: '', /** * ip address preference when creating hostnames * * @env NEW_RELIC_IPV_PREFERENCE */ ipv_preference: '4' }, /** * High Security * * High security mode (v2) is a setting which prevents any sensitive data from * being sent to New Relic. The local setting must match the server setting. * If there is a mismatch the agent will log a message and act as if it is * disabled. * * Attributes of high security mode (when enabled): * * requires SSL * * does not allow capturing of http params * * does not allow custom params * * To read more see: https://docs.newrelic.com/docs/subscriptions/high-security */ high_security: false, /** * Labels * * An object of label names and values that will be applied to the data sent * from this agent. Both label names and label values have a maximum length of * 255 characters. This object should contain at most 64 labels. */ labels: {}, /** * These options control behavior for slow queries, but do not affect sql * nodes in transaction traces. */ slow_sql: { /** * Enables and disables `slow_sql` recording. * * @env NEW_RELIC_SLOW_SQL_ENABLED */ enabled: false, /** * Sets the maximum number of slow query samples that will be collected in a * single harvest cycle. * * @env NEW_RELIC_MAX_SQL_SAMPLES */ max_samples: 10 }, /** * Controls behavior of datastore instance metrics. * * @property {bool} [instance_reporting.enabled=true] * Enables reporting the host and port/path/id of database servers. Default * is `true`. * * @property {bool} [database_name_reporting.enabled=true] * Enables reporting of database/schema names. Default is `true`. */ datastore_tracer: { instance_reporting: {enabled: true}, database_name_reporting: {enabled: true} }, /** * Controls the behavior of span events produced by the agent. */ span_events: { /** * Enables/disables span event generation * * @env NEW_RELIC_SPAN_EVENTS_ENABLED */ enabled: true, attributes: { /** * If `true`, the agent captures attributes from span events. * * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude in span events. * Allows * as wildcard at end. * * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in span events. * Allows * as wildcard at end. * * @env NEW_RELIC_SPAN_EVENTS_ATTRIBUTES_INCLUDE */ include: [] } }, /** * Controls the behavior of transaction segments produced by the agent. */ transaction_segments: { attributes: { /** * If `true`, the agent captures attributes from transaction segments. * * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_ENABLED */ enabled: true, /** * Prefix of attributes to exclude in transaction segments. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_EXCLUDE */ exclude: [], /** * Prefix of attributes to include in transaction segments. * Allows * as wildcard at end. * * @env NEW_RELIC_TRANSACTION_SEGMENTS_ATTRIBUTES_INCLUDE */ include: [] } }, /** * Controls the method of cross agent tracing in the agent. * Distributed tracing lets you see the path that a request takes through your * distributed system. Enabling distributed tracing changes the behavior of some * New Relic features, so carefully consult the transition guide before you enable * this feature: https://docs.newrelic.com/docs/transition-guide-distributed-tracing * Default is false. */ distributed_tracing: { /** * Enables/disables distributed tracing. * * @env NEW_RELIC_DISTRIBUTED_TRACING_ENABLED */ enabled: false, /** * Excludes New Relic format distributed tracing header (`newrelic`) on * outbound requests when set to `true`. By default (when false) * both W3C TraceContext (`traceparent`, `tracecontext`) and * New Relic formats will be sent. * * @env NEW_RELIC_DISTRIBUTED_TRACING_EXCLUDE_NEWRELIC_HEADER */ exclude_newrelic_header: false }, /** * Controls the use of cross-application tracing. * * @property {bool} [enabled=true] * Enables tracing transactions across multiple applications. Default is `true`. */ cross_application_tracer: {enabled: true}, /** * Controls behavior of message broker tracing. * * @property {bool} [segment_parameters.enabled=true] * Enables reporting parameters on message broker segments. */ message_tracer: { segment_parameters: {enabled: true} }, /** * Controls the use of infinite tracing. */ infinite_tracing: { trace_observer: { /** * The URI HOST of the observer. Setting this enables infinite tracing. * * @env NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST */ host: '', /** * The URI PORT of the observer. * * @env NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_PORT */ port: '443' }, span_events: { /** * The amount of spans to hold onto before dropping them * * @env NEW_RELIC_INFINITE_TRACING_SPAN_EVENTS_QUEUE_SIZE */ queue_size: 10000 } }, /** * Specifies whether the agent will be used to monitor serverless functions. * For example: AWS Lambda * * @env NEW_RELIC_SERVERLESS_MODE_ENABLED */ serverless_mode: { enabled: process.env.AWS_LAMBDA_FUNCTION_NAME != null }, plugins: { /** * Controls usage of the native metrics module which samples VM and event * loop data. */ native_metrics: {enabled: true} } })