NewFangle::Transaction - NewRelic application class
version 0.09
use NewFangle; my $app = NewFangle::App->new; $app->start_web_transaction("txn_name");
NewRelic transaction class
my $seg = $txn->start_segment($name, $category);
Start a new segment. Returns NewFangle::Segment instance.
(csdk: newrelic_start_segment)
my $seg = $txn->start_datastore_segment([$product, $collection, $operation, $host, $port_path_or_id, $database_name, $query]);
Start a new datastore segment. Returns NewFangle::Segment instance.
(csdk: newrelic_start_datastore_segment)
my $seg = $txn->start_external_segment([$uri,$method,$library]);
Start a new external segment. Returns NewFangle::Segment instance.
(csdk: newrelic_start_external_segment)
my $bool = $txn->add_attribute_int($key, $value);
(csdk: newrelic_add_attribute_int)
my $bool = $txn->add_attribute_long($key, $value);
(csdk: newrelic_add_attribute_long)
my $bool = $txn->add_attribute_double($key, $value);
(csdk: newrelic_add_attribute_double)
my $bool = $txn->add_attribute_string($key, $value);
(csdk: newrelic_add_attribute_string)
$txn->notice_error($priority, $errmsg, $errclass);
For Perl you probably want to use notice_error_with_stacktrace
, see below.
(csdk: newrelic_notice_error)
$txn->notice_error_with_stacktrace($priority, $errmsg, $errorclass, $errstacktrace);
This works like notice_error above, except it lets you specify the stack trace instead of using the C stack trace, which is likely not helpful for a Perl application.
This method requires a patch that hasn't currently been applied to the official NewRelic C-SDK. Alien::libnewrelic should apply this fro you, but if you are building the C-SDK yourself and need this method then you will need to apply this patch.
(csdk: notice_error_with_stacktrace)
my $bool = $txn->ignore;
(csdk: newrelic_ignore_transaction)
my $bool = $txn->end;
Ends the transaction.
(csdk: newrelic_end_transaction)
$txn->record_custom_event($event);
$event
should be an instance of NewFangle::CustomEvent.
(csdk: newrelic_record_custom_event)
$txn->record_custom_metric($name, $milliseconds);
(csdk: newrelic_record_custom_metric)
my $bool = $txn->set_name($name);
(csdk: newrelic_set_transaction_name)
my $payload = $txn->create_distributed_trace_payload; my $payload = $txn->create_distributed_trace_payload($seg);
Note that to use distributed tracing the NewFangle::App instance must have it enabled in the configuration. You can do this like:
my $app = NewFangle::App->new({ distributed_tracing => { enabled => 1 } });
(csdk: newrelic_create_distributed_trace_payload)
my $payload = $txn->create_distributed_trace_payload_httpsafe; my $payload = $txn->create_distributed_trace_payload_httpsafe($seg);
(csdk: newrelic_create_distributed_trace_payload_httpsafe)
my $bool = $txn->accept_distributed_trace_payload($payload, $transport_type);
$transport_type
the recommended values are:
Unknown
HTTP
HTTPS
Kafka
JMS
IronMQ
AMQP
Queue
Other
undef
can also be used in place of Unknown
, but an info-level message will be logged.
(csdk: newrelic_accept_distributed_trace_payload)
my $bool = $txn->accept_distributed_trace_payload_httpsafe($payload, $transport_type);
Same as accept_distributed_trace_payload
above, but uses the payload from create_distributed_trace_payload_httpsafe
.
(csdk: newrelic_accept_distributed_trace_payload_httpsafe)
Author: Graham Ollis <plicease@cpan.org>
Contributors:
Owen Allsopp (ALLSOPP)
This software is copyright (c) 2020-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.