Skip to content

Commit c7d2753

Browse files
committed
money_trace: allow to run global, custom header name, create if none.
This enhances the money_trace to allow it to run globally, with the ability to override the global with a remap plugin. Adds in better logging support for the current transaction's trace header. Also allows passthru mode which passes along the client trace header without modification making ATS transparent.
1 parent bfd5265 commit c7d2753

File tree

8 files changed

+887
-293
lines changed

8 files changed

+887
-293
lines changed

doc/admin-guide/plugins/money_trace.en.rst

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,54 @@
1818

1919

2020
Money Trace Plugin
21-
==================
21+
******************
2222

23-
This is a remap plugin that allows ATS to participate in a distributed tracing system based upon
24-
the Comcast "Money" distributed tracing and monitoring library. The Comcast "Money" library has
25-
its roots in Google's Dapper and Twitters Zipkin systems. A money trace header or session id, is
26-
attached to transaction and allows an operator with the appropriate logging systems in place,
27-
to determine where errors and/or latency may exit.
23+
Description
24+
===========
2825

29-
Use of the library enables the tracing of a transaction through all systems that participate in
30-
handling the request. See the documentation on this open source library at
31-
https://github.com/Comcast/money.
26+
This plugin allows ATS to participate in a distributed tracing system
27+
based upon the Comcast "Money" distributed tracing and monitoring library.
28+
The Comcast "Money" library has its roots in Google's Dapper and Twitters
29+
Zipkin systems. A money trace header or session id, is attached to
30+
transaction and allows an operator with the appropriate logging systems
31+
in place, to determine where errors and/or latency may exit.
32+
33+
Use of the library enables the tracing of a transaction through all
34+
systems that participate in handling the request. See the documentation
35+
on this open source library at https://github.com/Comcast/money.
3236

3337
How it Works
34-
------------
35-
36-
This plugin checks incoming requests for the "X-MoneyTrace" header. If the header is not present
37-
no further processing takes place. However if the header is present, the plugin will check to
38-
to see if the request has been cached. If so, the plugin will add the "X-Moneytrace" header from the
39-
incoming request to the cached response returned to the client as required by the money_trace
40-
protocol. If the request has not been cached, the plugin will extends the trace context by creating a new
41-
"X-MoneyTrace" header for inclusion in the outgoing request to a parent cache or origin server.
42-
The extended header includes the 'trace-id' from the incoming request, the incoming span-id
43-
becomes the outgoing parent-id and the plugin generates a new random long span id for the outgoing request.
44-
See the documentation at the link above for a complete description on the "X-MoneyTrace" header and how
45-
to use and extend it in a distributed tracing system.
38+
============
39+
40+
This plugin checks incoming requests for the "X-MoneyTrace" header.
41+
If the header is not present no further processing takes place.
42+
However if the header is present, the plugin will check to to see if the
43+
request has been cached. If so, the plugin will add the "X-Moneytrace"
44+
header from the incoming request to the cached response returned to the
45+
client as required by the money_trace protocol. If the request has not
46+
been cached, the plugin will extends the trace context by creating a new
47+
"X-MoneyTrace" header for inclusion in the outgoing request to a parent
48+
cache or origin server. The extended header includes the 'trace-id'
49+
from the incoming request, the incoming span-id becomes the outgoing
50+
parent-id and the plugin generates a new span id for the
51+
outgoing request using the current state machine id.
52+
53+
See the documentation at the link above for a complete description on
54+
the "X-MoneyTrace" header and how to use and extend it in a distributed
55+
tracing system.
56+
57+
A sample money-trace header:
58+
59+
::
60+
61+
X-MoneyTrace: trace-id=aa234a23-189e-4cc4-98ed-b5327b1ec231-3;parent-id=0;span-id=4303691729133364974
4662

4763
Installation
48-
------------
64+
============
4965

50-
The `Money Trace` plugin is a :term:`remap plugin`. Enable it by adding
51-
``money_trace.so`` to your :file:`remap.config` file. There are no options.
66+
The `Money Trace` plugin can be either a :term:`remap plugin` or
67+
:term:`global plugin`. Enable it by adding ``money_trace.so`` to your
68+
:file:`remap.config` file or :file:`plugin.config`.
5269

5370
Here is an example remap.config entry:
5471

@@ -57,3 +74,53 @@ Here is an example remap.config entry:
5774
map http://vod.foobar.com http://origin.vod.foobar.com @plugin=money_trace.so
5875

5976
.. _MoneyTrace: https://github.com/Comcast/money
77+
78+
Configuration
79+
=============
80+
81+
The plugin supports the following options:
82+
83+
* ``--create-if-none=[true|false]`` (default: ``false``)
84+
85+
If no X-MoneyTrace header is found in the client request one will
86+
be manufactured using the transaction UUID as trace-id,
87+
the transaction state machine id as span-id and parent-id set to '0'.
88+
89+
* ``--global-skip-header=[header name]`` (default: null/disable)
90+
91+
This setting only applies to a :term:`global plugin` instance
92+
and allows remap plugin instances to override :term:`global plugin`
93+
behavior by disabling the :term:`global plugin`
94+
95+
Because a :term:`global plugin` runs before any :term:`remap plugin`
96+
in the remap phase a pregen header may still be created by the
97+
:term:`global plugin` if configured to do so.
98+
99+
The global skip check is performed during the post remap phase in order
100+
to allow remap plugins (like `header rewrite`) to set this skip header.
101+
102+
It is strongly suggested to use a private ATS header (begins with '@')
103+
as this value.
104+
105+
* ``--header=[header name]`` (default: ``X-MoneyTrace``)
106+
107+
Allows the money trace header to be overridden.
108+
109+
* ``--passthru=[true|false]`` (default: ``false``)
110+
111+
In this mode ATS acts transparently and only passes the money trace header
112+
through to the parent. This option ignores the --create-if-none setting.
113+
114+
* ``--pregen-header=[header name]`` (default: null/disable)
115+
116+
Normally the money trace header for a transaction is only added to the
117+
transaction server request headers. If this argument is supplied the
118+
header will be generated earlier in the transaction and added to the
119+
client request headers. Use this for debug or for logging the current
120+
transaction's money trace header. It is suggested to use a private
121+
ATS header (begins with a '@') for this value. A :file:`logging.yaml`
122+
entry with pregen-header=@MoneyTrace might look like:
123+
124+
::
125+
126+
%<{@MoneyTrace}cqh>

plugins/experimental/money_trace/README

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11

22
Money trace plugin
3-
This is a remap plugin that allows ATS to participate in a distributed tracing system based upon
4-
the Comcast "Money" distributed tracing and monitoring library. The Comcast "Money" library has
5-
its roots in Google's Dapper and Twitters Zipkin systems. A money trace header or session id, is
6-
attached to transaction and allows an operator with the appropriate logging systems in place,
7-
to determine where errors and/or latency may exit.
3+
This is a remap plugin that allows ATS to participate in a distributed
4+
tracing system based upon the Comcast "Money" distributed tracing
5+
and monitoring library. The Comcast "Money" library has its roots in
6+
Google's Dapper and Twitters Zipkin systems. A money trace header or
7+
session id, is attached to transaction and allows an operator with
8+
the appropriate logging systems in place, to determine where errors
9+
and/or latency may exit.
810

9-
Use of the library enables the tracing of a transaction through all systems that participate in
10-
handling the request. See the documentation on this open source library at
11-
https://github.com/Comcast/money/wiki.
11+
Use of the library enables the tracing of a transaction through all
12+
systems that participate in handling the request. See the documentation
13+
on this open source library at https://github.com/Comcast/money/wiki.
1214

13-
This plugin checks incoming requests for the "X-MoneyTrace" header. If the header is not present
14-
no further processing takes place. However if the header is present, the plugin will check to
15-
to see if the request has been cached. If so, the plugin will add the "X-Moneytrace" header from the
16-
incoming request to the cached response returned to the client as required by the money_trace
17-
protocol. If the request has not been cached, the plugin will extends the trace context by creating a new
18-
"X-MoneyTrace" header for inclusion in the outgoing request to a parent cache or origin server.
19-
The extended header includes the 'trace-id' from the incoming request, the incoming span-id
20-
becomes the outgoing parent-id and the plugin generates a new random long span id for the outgoing request.
21-
See the documentation at the link above for a complete description on the "X-MoneyTrace" header and how
22-
to use and extend it in a distributed tracing system.
15+
This plugin checks incoming requests for the "X-MoneyTrace" header.
16+
If the header is not present no further processing takes place.
17+
However if the header is present, the plugin will check to to
18+
see if the request has been cached. If so, the plugin will add the
19+
"X-Moneytrace" header from the incoming request to the cached response
20+
returned to the client as required by the money_trace protocol.
21+
If the request has not been cached, the plugin will extends the trace
22+
context by creating a new "X-MoneyTrace" header for inclusion in the
23+
outgoing request to a parent cache or origin server. The extended
24+
header includes the 'trace-id' from the incoming request, the incoming
25+
span-id becomes the outgoing parent-id and the plugin generates a new
26+
random long span id for the outgoing request. See the documentation
27+
at the link above for a complete description on the "X-MoneyTrace"
28+
header and how to use and extend it in a distributed tracing system.
2329

24-
To configure and use this plugin, simply add it in the remap.config file where needed. EXAMPLE:
30+
To configure and use this plugin, simply add it in the remap.config
31+
file where needed. EXAMPLE:
2532

2633
map http://vod.foobar.com http://origin.vod.foobar.com @plugin=money_trace.so
2734

0 commit comments

Comments
 (0)