You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -294,6 +294,14 @@ See the [Auth Plugins](docs/auth_plugins.md) documentation for even more informa
294
294
295
295
See the [Handler Plugins](docs/handler_plugins.md) documentation for in-depth information about handler plugins and how you can create your own to extend the functionality of the Hooks framework for your own deployment.
296
296
297
+
### Lifecycle Plugins
298
+
299
+
See the [Lifecycle Plugins](docs/lifecycle_plugins.md) documentation for information on how to create lifecycle plugins that can hook into the request/response/error lifecycle of the Hooks framework, allowing you to add custom behavior at various stages of processing webhook requests.
300
+
301
+
### Instrument Plugins
302
+
303
+
See the [Instrument Plugins](docs/instrument_plugins.md) documentation for information on how to create instrument plugins that can be used to collect metrics or report exceptions during webhook processing. These plugins can be used to integrate with monitoring and alerting systems.
304
+
297
305
## Contributing 🤝
298
306
299
307
See the [Contributing](CONTRIBUTING.md) document for information on how to contribute to the Hooks project, including setting up your development environment, running tests, and releasing new versions.
Copy file name to clipboardExpand all lines: docs/instrument_plugins.md
+20-57Lines changed: 20 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,72 +1,35 @@
1
1
# Instrument Plugins
2
2
3
-
Instrument plugins provide global components for cross-cutting concerns like metrics collection and error reporting. The hooks framework includes two built-in instrument types: `stats` for metrics and `failbot` for error reporting.
3
+
Instrument plugins provide global components for cross-cutting concerns like metrics collection and error reporting. The hooks framework includes two built-in instrument types: `stats` for metrics and `failbot` for error reporting. By default, these instruments are no-op implementations that do not require any external dependencies. You can create custom implementations to integrate with your preferred monitoring and error reporting services.
4
4
5
5
## Overview
6
6
7
7
By default, the framework provides no-op stub implementations that do nothing. This allows you to write code that calls instrument methods without requiring external dependencies. You can replace these stubs with real implementations that integrate with your monitoring and error reporting services.
8
8
9
9
The instrument plugins are accessible throughout the entire application:
10
+
10
11
- In handlers via `stats` and `failbot` methods
11
12
- In auth plugins via `stats` and `failbot` class methods
12
13
- In lifecycle plugins via `stats` and `failbot` methods
13
14
14
-
## Built-in Instruments
15
-
16
-
### Stats
17
-
18
-
The stats instrument provides methods for metrics collection:
To actually have `stats` and `failbot` do something useful, you need to create custom classes that inherit from the base classes provided by the framework. Here’s an example of how to implement custom stats and failbot plugins.
51
20
52
-
# Report warnings
53
-
failbot.warning("Slow response time detected", { duration:2.5 })
21
+
You would then set the following attribute in your `hooks.yml` configuration file to point to these custom instrument plugins:
54
22
55
-
# Capture exceptions automatically
56
-
result = failbot.capture({ operation:"webhook_validation" }) do
57
-
validate_webhook_payload(payload)
58
-
end
23
+
```yaml
24
+
# hooks.yml
25
+
instruments_plugin_dir: ./plugins/instruments
59
26
```
60
27
61
-
## Creating Custom Instruments
62
-
63
-
To create custom instrument implementations, inherit from the appropriate base class and implement the required methods.
Place your instrument plugin files in the specified directory:
170
133
171
-
```
134
+
```text
172
135
plugins/
173
136
└── instruments/
174
-
├── custom_stats.rb
175
-
└── custom_failbot.rb
137
+
├── stats.rb
138
+
└── failbot.rb
176
139
```
177
140
178
141
## File Naming and Class Detection
@@ -183,11 +146,11 @@ The framework automatically detects which type of instrument you're creating bas
183
146
- Classes inheriting from `FailbotBase` become the `failbot` instrument
184
147
185
148
File naming follows snake_case to PascalCase conversion:
186
-
-`custom_stats.rb` → `CustomStats`
187
-
-`datadog_stats.rb` → `DatadogStats`
149
+
150
+
-`stats.rb` → `stats`
188
151
-`sentry_failbot.rb` → `SentryFailbot`
189
152
190
-
You can only have one stats plugin and one failbot plugin loaded. If multiple plugins of the same type are found, the last one loaded will be used.
153
+
You can only have one `stats` plugin and one `failbot` plugin loaded. If multiple plugins of the same type are found, the last one loaded will be used.
0 commit comments