Commit 61101ca7 authored by Matt Todd's avatar Matt Todd

Doc instrumenting pipelines

parent e8dcecca
......@@ -53,9 +53,7 @@ pipeline = [
result = <<-CODE
This is *great*:
``` ruby
......@@ -178,7 +176,7 @@ require 'uri'
class RootRelativeFilter < HTML::Pipeline::Filter
def call"img").each do |img|"img").each do |img|
next if img['src'].nil?
src = img['src'].strip
if src.start_with? '/'
......@@ -197,6 +195,36 @@ Now this filter can be used in a pipeline: [ RootRelativeFilter ], { :base_url => '' }
## Instrumenting
To instrument each filter, set an [ActiveSupport::Notifications]
( service
object on a pipeline object. New pipeline objects will default to the
`HTML::Pipeline.default_instrumentation_service` object.
``` ruby
# the AS::Notifications-compatible service object
service = ActiveSupport::Notifications
# instrument a specific pipeline
pipeline = [MarkdownFilter], context
pipeline.instrumentation_service = service
# or instrument all new pipelines
HTML::Pipeline.default_instrumentation_service = service
Filters are instrumented when they are run through the pipeline. A
`call_filter.html_pipeline` event is published once the filter finishes. The
`payload` should include the `filter` name. Each filter will trigger its own
instrumentation call.
``` ruby
service.subscribe "call_filter.html_pipeline" do |event, start, ending, transaction_id, payload|
payload[:filter] #=> "MarkdownFilter"
## Development
To see what has changed in recent versions, see the [CHANGELOG](
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment