🌻 📖 NewFangle::Transaction

NAME

NewFangle::Transaction - NewRelic application class

VERSION

version 0.09

SYNOPSIS

 use NewFangle;
 my $app = NewFangle::App->new;
 $app->start_web_transaction("txn_name");

DESCRIPTION

NewRelic transaction class

METHODS

start_segment

 my $seg = $txn->start_segment($name, $category);

Start a new segment. Returns NewFangle::Segment instance.

(csdk: newrelic_start_segment)

start_datastore_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)

start_external_segment

 my $seg = $txn->start_external_segment([$uri,$method,$library]);

Start a new external segment. Returns NewFangle::Segment instance.

(csdk: newrelic_start_external_segment)

add_attribute_int

 my $bool = $txn->add_attribute_int($key, $value);

(csdk: newrelic_add_attribute_int)

add_attribute_long

 my $bool = $txn->add_attribute_long($key, $value);

(csdk: newrelic_add_attribute_long)

add_attribute_double

 my $bool = $txn->add_attribute_double($key, $value);

(csdk: newrelic_add_attribute_double)

add_attribute_string

 my $bool = $txn->add_attribute_string($key, $value);

(csdk: newrelic_add_attribute_string)

notice_error

 $txn->notice_error($priority, $errmsg, $errclass);

For Perl you probably want to use notice_error_with_stacktrace, see below.

(csdk: newrelic_notice_error)

notice_error_with_stacktrace

 $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)

ignore

 my $bool = $txn->ignore;

(csdk: newrelic_ignore_transaction)

end

 my $bool = $txn->end;

Ends the transaction.

(csdk: newrelic_end_transaction)

record_custom_event

 $txn->record_custom_event($event);

$event should be an instance of NewFangle::CustomEvent.

(csdk: newrelic_record_custom_event)

record_custom_metric

 $txn->record_custom_metric($name, $milliseconds);

(csdk: newrelic_record_custom_metric)

set_name

 my $bool = $txn->set_name($name);

(csdk: newrelic_set_transaction_name)

create_distributed_trace_payload

 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)

create_distributed_trace_payload_httpsafe

 my $payload = $txn->create_distributed_trace_payload_httpsafe;
 my $payload = $txn->create_distributed_trace_payload_httpsafe($seg);

(csdk: newrelic_create_distributed_trace_payload_httpsafe)

accept_distributed_trace_payload

 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)

accept_distributed_trace_payload_httpsafe

 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)

SEE ALSO

NewFangle

AUTHOR

Author: Graham Ollis <plicease@cpan.org>

Contributors:

Owen Allsopp (ALLSOPP)

COPYRIGHT AND LICENSE

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.