-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Logging feature harvesting and optimizations (#1064)
- Loading branch information
1 parent
9c43d2c
commit 9a9fad5
Showing
31 changed files
with
660 additions
and
110 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
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
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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import { handle } from '../../../common/event-emitter/handle' | ||
import { now } from '../../../common/timing/now' | ||
import { stringify } from '../../../common/util/stringify' | ||
import { FEATURE_NAMES } from '../../../loaders/features/features' | ||
import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants' | ||
import { LOGGING_EVENT_EMITTER_CHANNEL } from '../constants' | ||
import { LOGGING_EVENT_EMITTER_CHANNEL, LOG_LEVELS } from '../constants' | ||
|
||
/** | ||
* @param {ContextualEE} ee - The contextual ee tied to the instance | ||
* @param {string} message - the log message string | ||
* @param {{[key: string]: *}} customAttributes - The log's custom attributes if any | ||
* @param {enum} level - the log level enum | ||
*/ | ||
export function bufferLog (ee, message, customAttributes, level = 'info') { | ||
export function bufferLog (ee, message, customAttributes = {}, level = 'info') { | ||
if (typeof message !== 'string') message = stringify(message) | ||
handle(SUPPORTABILITY_METRIC_CHANNEL, [`API/logging/${level}/called`], undefined, FEATURE_NAMES.metrics, ee) | ||
handle(LOGGING_EVENT_EMITTER_CHANNEL, [now(), message, customAttributes, level], undefined, FEATURE_NAMES.logging, ee) | ||
} | ||
|
||
/** | ||
* Checks if a supplied log level is acceptable for use in generating a log event | ||
* @param {string} level | ||
* @returns {boolean} | ||
*/ | ||
export function isValidLogLevel (level) { | ||
if (typeof level !== 'string') return false | ||
return Object.values(LOG_LEVELS).some(logLevel => logLevel.toLowerCase() === level.toLowerCase()) | ||
} |
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
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,20 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2020 New Relic Corporation. | ||
PDX-License-Identifier: Apache-2.0 | ||
--> | ||
<html> | ||
<head> | ||
<title>Logs API Post Load</title> | ||
{init} {config} {loader} | ||
</head> | ||
<body>Logs API Post Load | ||
<script> | ||
const longMessage = 'x'.repeat(800*800) | ||
/** the combination of the two large messages pushes it past the MAX_PAYLOAD_SIZE, | ||
* causing the first valid one to get harvested before buffering the second one **/ | ||
newrelic.log(longMessage, {test: 1}) | ||
newrelic.log(longMessage, {test: 1}) | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.