Import this schema into your Spring beans definition file (namespace http://www.springframework.org/schema/beans) to configure behavior tracking.
Container for behavior tracking elements in a Spring configuration file. <bt:config> is "syntactic sugar" within a Spring bean configuration file and is entirely optional; you can include any of its allowed child elements directly in the file instead.
Typically a <bt:config> element will contain one or more <bt:manager> elements. Most applications will only need one <bt:manager> definition. Other elements like <bt:xml-persister> and <bt:session-context> will usually appear as children of a <bt:manager> element. It is useful to include them directly under <bt:config> when you want to make them public for injection into application beans that are not part of the behavior tracking framework, or if you have multiple <bt:manager> tags that share a persister, and so on.
<bt:config> Nested Elements
This is the fundamental element required to enable behavior tracking in an application: method call tracking, HTTP request tracking, and JDBC tracking all require this element to appear in Spring configuration.
If no "id" attribute is specified, the implicit name "defaultTrackingManager" is assumed. If there is more than one <bt:manager> defined, you must define a unique "id" value for each.
Attribute | Use | Description |
---|---|---|
application | required |
Arbitrary text string recorded as the "application" attribute of each logged event. |
flush-threshold | optional |
Maximum number of events recorded before data is automatically flushed to the persister. Default is 100 if unspecified. |
task-executor | optional |
Bean name of a task executor for performing event logging operations. If unspecified, a private thread pool is maintained for this purpose. The default behavior is strongly recommended, as unbounded memory growth is possible if events cannot be logged in a timely fashion as they are recorded. |
track-method-expression | optional |
An AspectJ AOP pointcut expression identifying methods that should generate behavior tracking events. This is a simplified alternative to using <bt:advice> in combination with standard Spring AOP configuration. |
flush-schedule | optional |
Quartz Cron expression describing how often events should be flushed to the persister. Default is every 5 minutes if unspecified. |
scheduler | optional |
Bean name of a Quartz scheduler bean to use for timed flush operations. If unspecified, a private instance will be created. The default behavior is strongly recommended. |
persister | optional |
Bean name of a BehaviorEventPersister implementation defined in the applicaton context. Use in place of a nested persister element (e.g. <bt:xml-persister>, <bt:jdbc-persister>). |
session-context | optional |
Bean name of a SessionContext implementation defined in the applicaton context. Use in place of a nested <bt:session-context> element. |
<bt:manager> Nested Elements
Configure XML logging for this manager. This is the default logging type if none is specified, so this is only necessary if you want to change any of the defaults, e.g. specify log file location or change the log rotation schedule.
Configure JDBC logging for this manager.
Configure a custom BehaviorEventPersister implementation for this manager.
Specify the bean name of a SessionContext implementation to use with this BehaviorTrackingManager. An alternative to a nested <bt:session-context> element.
Activate logging of http requests using this manager. Use of this element requires a servlet container supporting JSP 2.0 and higher. Older containers MUST use the servlet filter instead.
All parameters are logged unless the "parameters" attribute is specified. Similarly, all requests are logged, unless one or more "uri-patterns" are specified.
This element cannot be used in a web application that already has BehaviorTrackingFilter instance(s) configured in web.xml. BehaviorTrackingFilters are a more complex, but slightly more powerful alternative to configuration using this element. For example, BehaviorTrackingFilters add HTTP response code and error diagnostic information to the behavior tracking event. HTTP response codes are not logged if you use <bt:http-requests> in your Spring configuration.
However, the relatively more concise <bt:http-requests> tag in spring configuration may suffice in simple applications, with the added benefit of centralizing all behavior tracking configuration in your Spring bean definitions file.
Activate logging of http requests using this manager. Use of this element requires a servlet container supporting JSP 2.0 and higher. Older containers MUST use the servlet filter instead.
All parameters are logged unless the "parameters" attribute is specified. Similarly, all requests are logged, unless one or more "uri-patterns" are specified.
This element cannot be used in a web application that already has BehaviorTrackingFilter instance(s) configured in web.xml. BehaviorTrackingFilters are a more complex, but slightly more powerful alternative to configuration using this element. For example, BehaviorTrackingFilters add HTTP response code and error diagnostic information to the behavior tracking event. HTTP response codes are not logged if you use <bt:http-requests> in your Spring configuration.
However, the relatively more concise <bt:http-requests> tag in spring configuration may suffice in simple applications, with the added benefit of centralizing all behavior tracking configuration in your Spring bean definitions file.
Attribute | Use | Description |
---|---|---|
parameters | optional |
If specified, a comma-separated list of request parameters that should be logged with behavior events. If unspecified, all parameters are logged. |
uri-pattern | optional |
Equivalent to a single nested uri-pattern element, provided as an attribute for syntactic convenience. |
event-type | optional |
The value to log for event type when recording http requests. Defaults to "http-request" if unspecified. |
<bt:http-requests> Nested Elements
A regular expression identifying URIs that should be logged to the behavior event persister. The value of HttpServletRequest.getServletURI() will be matched against this expression.
This element has equivalent behavior to the uri-pattern attribute, but can appear multiple time.
Defines an AOP advisor that logs a behavior tracking event for each advised method call. Generally you can use the track-method-expression attribute of <bt:manager> to achieve the same result; <bt:advice> tags are not strictly necessary. <bt:advice> is provided for fine-grained integration of behavior tracking with other AOP advice. For example, you can control whether behavior tracking events occur inside or outside of transaction boundaries.
Attribute | Use | Description |
---|---|---|
tracking-manager | optional |
Java Bean Type:
com.mtgi.analytics.BehaviorTrackingManager
The bean name of the BehaviorTrackingManager instance that is to be used to register events. This attribute is usually optional, only required if there is more than one <bt:manager> defined by the application. |
Defines behavior tracking event persistence to a rotating XML log file. Support is provided for binary XML and GZIP compression. Generally this element will appear as a child of <bt:manager> without an "id", though it is possible to declare it as a top-level bean if you want to inject it into other application beans.
Attribute | Use | Description |
---|---|---|
file | optional |
Path to XML log file. Defaults to behavior-tracking.xml in the process working directory. |
rotate-schedule | optional |
Quartz Cron expression for the log file rotation schedule. Defaults to daily at midnight if unspecified. |
binary | optional |
Enable binary (FastInfoset) XML logging. Defaults to true. |
compress | optional |
Enable GZIP logfile compression. Defaults to true. |
Defines behavior tracking event persistence to a JDBC DataSource. Optional support is provided for JDBC batch fetching. Generally this element will appear as a child of <bt:manager> without an "id", though it is possible to declare it as a top-level bean if you want to inject it into other application beans.
Attribute | Use | Description |
---|---|---|
batch-size | optional |
Statement batch size for persistence operations, only used if underlying JDBC driver supports batching. Default is 25. |
<bt:jdbc-persister> Nested Elements
Specifies the data source to which events are persisted.
Overrides the default SQL statement used to retrieve new event IDs.
Specifies the data source to which events are persisted.
Attribute | Use | Description |
---|---|---|
ref | optional |
<bt:data-source> Nested Elements
Defines a custom com.mtgi.analytics.BehaviorEventPersister implementation. Generally this element will appear as a child of <bt:manager> without an "id", though it is possible to declare it as a top-level bean if you want to inject it into other application beans.
Specifies a custom SessionContext implementation, which provides the user ID and session ID for logged events. If no session-context is specified, then com.mtgi.analytics.servlet.SpringSessionContext is used if we are determined to be in a Spring web application; otherwise com.mtgi.analytics.JAASSessionContext is used.
This element has the syntax of a standard Spring bean definition; e.g. specify "id" and "class" attributes, as well as nested <property> elements.
Annotates a Spring bean definition for behavior tracking. The value of this attribute should be the ID of the <bt:manager> instance to use, or simply "defaultTrackingManager". Currently this attribute is only supported for DataSource bean definitions.