-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(agent): Adds another test for log forwarded labels using defaults
- Loading branch information
Showing
1 changed file
with
208 additions
and
0 deletions.
There are no files selected for viewing
208 changes: 208 additions & 0 deletions
208
tests/integration/logging/monolog3/test_monolog_labels_forwarding_disabled_04.php
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,208 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
Test that Monolog3 instrumentation will NOT forward logs with labels when: | ||
- default INI values are used for logging except logleve set to DEBUG | ||
- newrelic.labels set to "label1:value1;label2:value2" | ||
Expect: | ||
- NO labels to be forwarded with the log events in the "common" attribute | ||
- "Supportability/Logging/Labels/PHP/disabled" to exist and have a value of 1 | ||
*/ | ||
|
||
/*SKIPIF | ||
<?php | ||
require('skipif.inc'); | ||
*/ | ||
|
||
/*INI | ||
newrelic.application_logging.forwarding.log_level = DEBUG | ||
newrelic.labels = "label1:value1;label2:value2" | ||
*/ | ||
|
||
/*EXPECT | ||
monolog3.DEBUG: debug [] | ||
monolog3.INFO: info [] | ||
monolog3.NOTICE: notice [] | ||
monolog3.WARNING: warning [] | ||
monolog3.ERROR: error [] | ||
monolog3.CRITICAL: critical [] | ||
monolog3.ALERT: alert [] | ||
monolog3.EMERGENCY: emergency [] | ||
*/ | ||
|
||
/*EXPECT_METRICS | ||
[ | ||
"?? agent run id", | ||
"?? timeframe start", | ||
"?? timeframe stop", | ||
[ | ||
[{"name": "DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines"}, [8, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/ALERT"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/CRITICAL"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/DEBUG"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/EMERGENCY"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/ERROR"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/INFO"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/NOTICE"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Logging/lines/WARNING"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/Logging/PHP/Monolog/enabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/PHP/package/monolog/monolog/3/detected"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/library/Monolog/detected"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name": "Supportability/Logging/Labels/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] | ||
] | ||
] | ||
*/ | ||
|
||
|
||
/*EXPECT_LOG_EVENTS | ||
[ | ||
{ | ||
"common": { | ||
"attributes": {} | ||
}, | ||
"logs": [ | ||
{ | ||
"message": "error", | ||
"level": "ERROR", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "critical", | ||
"level": "CRITICAL", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "notice", | ||
"level": "NOTICE", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "warning", | ||
"level": "WARNING", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "info", | ||
"level": "INFO", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "alert", | ||
"level": "ALERT", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "emergency", | ||
"level": "EMERGENCY", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
}, | ||
{ | ||
"message": "debug", | ||
"level": "DEBUG", | ||
"timestamp": "??", | ||
"trace.id": "??", | ||
"span.id": "??", | ||
"entity.guid": "??", | ||
"entity.name": "tests/integration/logging/monolog3__FILE__", | ||
"hostname": "__HOST__" | ||
} | ||
] | ||
} | ||
] | ||
*/ | ||
|
||
require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php'); | ||
require_once(realpath(dirname(__FILE__)) . '/../../../include/monolog.php'); | ||
require_monolog(3); | ||
|
||
use Monolog\Logger; | ||
use Monolog\Level; | ||
use Monolog\Handler\StreamHandler; | ||
use Monolog\Formatter\LineFormatter; | ||
|
||
|
||
function test_logging() { | ||
$logger = new Logger('monolog3'); | ||
|
||
$logfmt = "%channel%.%level_name%: %message% %context%\n"; | ||
$formatter = new LineFormatter($logfmt); | ||
|
||
$stdoutHandler = new StreamHandler('php://stdout', LOGGER::DEBUG); | ||
$stdoutHandler->setFormatter($formatter); | ||
|
||
$logger->pushHandler($stdoutHandler); | ||
|
||
// insert delays between log messages to allow priority sampling | ||
// to resolve that later messages have higher precedence | ||
// since timestamps are only millisecond resolution | ||
// without delays sometimes order in output will reflect | ||
// all having the same timestamp. | ||
$logger->debug("debug"); | ||
usleep(10000); | ||
$logger->info("info"); | ||
usleep(10000); | ||
$logger->notice("notice"); | ||
usleep(10000); | ||
$logger->warning("warning"); | ||
usleep(10000); | ||
$logger->error("error"); | ||
usleep(10000); | ||
$logger->critical("critical"); | ||
usleep(10000); | ||
$logger->alert("alert"); | ||
usleep(10000); | ||
$logger->emergency("emergency"); | ||
} | ||
|
||
test_logging(); |