Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Commit ff4581b

Browse files
committed
Remove omniauth integration
1 parent 5a0cc17 commit ff4581b

File tree

3 files changed

+45
-101
lines changed

3 files changed

+45
-101
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Changed
10+
11+
- Omniauth integration was removed since it only captures user context during the Authentication
12+
phase. Omniauth does not persist sessions. As such, the integration is extremely low value
13+
and could cause unintended issues.
914

1015
## [2.2.0] - 2017-09-13
11-
## Changed
16+
### Changed
1217

1318
- The default HTTP log device queue type was switched to a
1419
`Timber::LogDevices::HTTP::FlushableDroppingSizedQueue` instead of a `::SizedQueue`. In the

README.md

Lines changed: 35 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
[![Build Status](https://travis-ci.org/timberio/timber-ruby.svg?branch=master)](https://travis-ci.org/timberio/timber-ruby)
66
[![Code Climate](https://codeclimate.com/github/timberio/timber-ruby/badges/gpa.svg)](https://codeclimate.com/github/timberio/timber-ruby)
77

8-
[Timber](https://timber.io) is a cloud-based logging system that integrates directly with your Ruby
9-
app through this library, capturing context and metadata without parsing. This produces rich, clean,
10-
readable logs that are easier to search and use:
8+
Timber for Ruby is a drop in replacement for your Ruby logger that
9+
[unobtrusively augments](https://timber.io/docs/concepts/structuring-through-augmentation) your
10+
logs with [rich metadata and context](https://timber.io/docs/concepts/metadata-context-and-events)
11+
making them [easier to search, use, and read](#get-things-done-with-your-logs). It pairs with the
12+
[Timber console](#the-timber-console) to deliver a tailored Ruby logging experience designed to make
13+
you more productive.
1114

1215
1. [**Installation** - One command: `bundle exec timber install`](#installation)
13-
2. [**Usage** - Simple yet powerful API](#usage)
16+
2. [**Usage** - Simple & powerful API](#usage)
1417
3. [**Integrations** - Automatic context and metadata for your existing logs](#integrations)
15-
4. [**The Timber Console** - Designed for Ruby developers](#the-timber-console)
18+
4. [**The Timber Console** - Designed for applications & developers](#the-timber-console)
1619
5. [**Get things done with your logs 💪**](#get-things-done-with-your-logs)
1720

1821

@@ -24,9 +27,11 @@ readable logs that are easier to search and use:
2427
gem 'timber', '~> 2.1'
2528
```
2629

27-
2. In your `shell`, run `bundle install`
30+
2. In your `shell`, run:
2831

29-
3. In your `shell`, run `bundle exec timber install`
32+
```
33+
bundle install && bundle exec timber install
34+
```
3035

3136

3237
## Usage
@@ -43,51 +48,37 @@ logger.error("Error message")
4348
logger.fatal("Fatal message")
4449
```
4550

46-
We encourage standard / traditional log messages for non-meaningful events. And because Timber
47-
[augments](https://timber.io/docs/concepts/structuring-through-augmentation) your logs with
48-
metadata, you don't have to worry about making every log structured!
51+
1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `error message`
52+
2. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
53+
3. [View this event's metadata and context](https://timber.io/docs/app/console/view-metdata-and-context)
54+
55+
[...read more in our docs](https://timber.io/docs/languages/ruby/usage/basic-logging)
4956
5057
---
5158
5259
</p></details>
5360
5461
<details><summary><strong>Logging events (structured data)</strong></summary><p>
5562
56-
Logging events allows you to log structured data without sacrificing readability or worrying about
57-
structured data name or type conflicts. Keep in mind, Timber defines common events in the
58-
[`Timber::Events`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Events) namespace,
59-
which are automatically logged for you through our [integrations](#integrations). You should not
60-
have to maually log events defined there except in special circumstances.
61-
62-
### How to use it
63+
Log structured data without sacrificing readability:
6364
6465
```ruby
6566
logger.warn "Payment rejected", payment_rejected: {customer_id: "abcd1234", amount: 100, reason: "Card expired"}
6667
```
6768
6869
1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `type:payment_rejected` or `payment_rejected.amount:>100`
6970
2. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
70-
3. [Graph & visualize it](https://timber.io/docs/app/console/graphing)
7171
4. [View this event's data and context](https://timber.io/docs/app/console/view-metdata-and-context)
72-
5. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/custom-events)
72+
73+
...[read more in our docs](https://timber.io/docs/languages/ruby/usage/custom-events)
7374

7475
---
7576

7677
</p></details>
7778

7879
<details><summary><strong>Setting context</strong></summary><p>
7980

80-
Context is amazingly powerful, think of it like join data for your logs. It represents the
81-
environment when the log was written, allowing you to relate logs so you can easily segment them.
82-
It's how Timber is able to accomplish features like
83-
[tailing users](https://timber.io/docs/app/console/tail-a-user) and
84-
[tracing HTTP requests](https://timber.io/docs/app/console/trace-http-requests).
85-
Keep in mind, Timber defines common contexts in the
86-
[`Timber::Contexts`](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts) namespace,
87-
which are automatically set for you through our [integrations](#integrations). You should not
88-
have to maually set these contexts except in special circumstances.
89-
90-
### How to use it
81+
Add shared structured data across your logs:
9182

9283
```ruby
9384
Timber.with_context(job: {id: 123}) do
@@ -99,38 +90,24 @@ end
9990

10091
1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `job.id:123`
10192
2. [View this context when viewing a log's metadata](https://timber.io/docs/app/console/view-metdata-and-context)
102-
3. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/custom-context)
93+
94+
...[read more in our docs](https://timber.io/docs/languages/ruby/usage/custom-context)
10395
10496
---
10597
10698
</p></details>
10799
108-
<details><summary><strong>Metrics & Timings</strong></summary><p>
100+
<details><summary><strong>Metrics, Timings, & Tracing</strong></summary><p>
109101
110-
Aggregates destroy details, events tell stories. With Timber, logging metrics and timings is simply
111-
[logging an event](https://timber.io/docs/languages/ruby/usage/custom-events). Timber is based on
112-
modern big-data principles and can aggregate inordinately large data sets in seconds. Logging
113-
events (raw data as it exists), gives you the flexibility in the future to segment and aggregate
114-
your data any way you see fit. This is superior to choosing specific paradigms before hand, when
115-
you are unsure how you'll need to use your data in the future.
116-
117-
### How to use it
118-
119-
Below is a contrived example of timing a background job:
102+
Time code blocks:
120103
121104
```ruby
122105
timer = Timber.start_timer
123106
# ... code to time ...
124107
logger.info("Processed background job", background_job: {time_ms: timer})
125108
```
126109
127-
And of course, `time_ms` can also take a `Float` or `Fixnum`:
128-
129-
```ruby
130-
logger.info("Processed background job", background_job: {time_ms: 45.6})
131-
```
132-
133-
Lastly, metrics aren't limited to timings. You can capture any metric you want:
110+
Log generic metrics:
134111
135112
```ruby
136113
logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
@@ -139,8 +116,8 @@ logger.info("Credit card charged", credit_card_charge: {amount: 123.23})
139116
1. [Search it](https://timber.io/docs/app/console/searching) with queries like: `background_job.time_ms:>500`
140117
2. [Alert on it](https://timber.io/docs/app/console/alerts) with threshold based alerts
141118
3. [View this log's metadata in the console](https://timber.io/docs/app/console/view-metdata-and-context)
142-
4. ...read more in our [docs](https://timber.io/docs/languages/ruby/usage/metrics-and-timings)
143119

120+
...[read more in our docs](https://timber.io/docs/languages/ruby/usage/metrics-and-timings)
144121

145122
</p></details>
146123

@@ -152,20 +129,14 @@ Below are a few popular configuration options, for a comprehensive list, see
152129

153130
<details><summary><strong>Logrageify. Silence noisy logs.</strong></summary><p>
154131

155-
Timber allows you to silence noisy logs that aren't of value to you, just like
156-
[lograge](https://github.com/roidrage/lograge). As such, we've provided a convenience configuration
157-
option for anyone transitioning from lograge.
158-
159-
### How to use it
132+
Silence noisy logs that aren't of value to you, just like
133+
[lograge](https://github.com/roidrage/lograge):
160134
161135
```ruby
162136
# config/initializers/timber.rb
163-
164137
Timber.config.logrageify!()
165138
```
166139
167-
### How it works
168-
169140
It turns this:
170141
171142
```
@@ -182,18 +153,7 @@ Completed 200 OK in 79ms (Views: 78.8ms | ActiveRecord: 0.0ms)
182153
Into this:
183154
184155
```
185-
Get "/" sent 200 OK in 79ms @metadata {...}
186-
```
187-
188-
Internally this is equivalent to:
189-
190-
```ruby
191-
# config/initializers/timber.rb
192-
193-
Timber.config.integrations.action_controller.silence = true
194-
Timber.config.integrations.action_view.silence = true
195-
Timber.config.integrations.active_record.silence = true
196-
Timber.config.integrations.rack.http_events.collapse_into_single_event = true
156+
Get "/" sent 200 OK in 79ms
197157
```
198158
199159
### Pro-tip: Keep controller call logs (recommended)
@@ -222,11 +182,8 @@ For a full list of integration settings, see
222182
<details><summary><strong>Silence specific requests (LB health checks, etc)</strong></summary><p>
223183
224184
Silencing noisy requests can be helpful for silencing load balance health checks, bot scanning,
225-
or activity that generally is not meaningful to you.
226-
227-
### How to use it
228-
229-
The following will silence all `[GET] /_health` requests:
185+
or activity that generally is not meaningful to you. The following will silence all
186+
`[GET] /_health` requests:
230187
231188
```ruby
232189
# config/initializers/timber.rb
@@ -247,12 +204,10 @@ The first parameter being the traditional Rack env hash, the second being a
247204
<details><summary><strong>Capture custom user context</strong></summary><p>
248205
249206
By default Timber automatically captures user context for most of the popular authentication
250-
libraries (Devise, Omniauth, and Clearance). See
207+
libraries (Devise, and Clearance). See
251208
[Timber::Integrations::Rack::UserContext](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Integrations/Rack/UserContext)
252209
for a complete list.
253210
254-
### How to use it
255-
256211
In cases where you Timber doesn't support your strategy, or you want to customize it further,
257212
you can do so like:
258213

@@ -284,8 +239,6 @@ end
284239
[Timber::Contexts::Release](http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Contexts/Release)
285240
tracks the current application release and version.
286241

287-
### How to use it
288-
289242
If you're on Heroku, simply enable the
290243
[dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) feature. If you are not,
291244
set the following environment variables and this context will be added automatically:
@@ -304,7 +257,7 @@ All variables are optional, but at least one must be present.
304257
## Integrations
305258
306259
Timber integrates with popular frameworks and libraries to capture context and metadata you
307-
couldn't otherwise. This automatically upgrades logs produced by these libraries, making them
260+
couldn't otherwise. This automatically augments logs produced by these libraries, making them
308261
[easier to search and use](#do-amazing-things-with-your-logs). Below is a list of libraries we
309262
support:
310263

@@ -313,7 +266,6 @@ support:
313266
* [**Rack**](https://timber.io/docs/languages/ruby/integrations/rack)
314267
* [**Devise**](https://timber.io/docs/languages/ruby/integrations/devise)
315268
* [**Clearance**](https://timber.io/docs/languages/ruby/integrations/clearnace)
316-
* [**Omniauth**](https://timber.io/docs/languages/ruby/integrations/omniauth)
317269
* [**Warden**](https://timber.io/docs/languages/ruby/integrations/devise)
318270
* Platforms
319271
* [**Heroku**](https://timber.io/docs/languages/ruby/integrations/heroku)
@@ -324,7 +276,7 @@ support:
324276

325277
## Get things done with your logs
326278

327-
Logging features every developer needs:
279+
Logging features designed to help developers get more done:
328280

329281
1. [**Powerful searching.** - Find what you need faster.](https://timber.io/docs/app/console/searching)
330282
2. [**Live tail users.** - Easily solve customer issues.](https://timber.io/docs/app/console/tail-a-user)

lib/timber/integrations/rack/user_context.rb

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Rack
88
# This is a Rack middleware responsible for setting the user context.
99
# See {Timber::Contexts::User} for more information on the user context.
1010
#
11+
# ## Why a Rack middleware?
12+
#
1113
# We use a Rack middleware because we want to set the user context as early as
1214
# possible, and before the initial incoming request log line:
1315
#
@@ -29,7 +31,6 @@ module Rack
2931
# automatically set the user context for you.
3032
#
3133
# * Devise, or any Warden based authentication strategy
32-
# * Omniauth
3334
# * Clearance
3435
#
3536
# Or, you can use your own custom authentication, see the {.custom_user_context}
@@ -47,7 +48,7 @@ class << self
4748
#
4849
# @example Setting your own custom user context
4950
# Timber::Integrations::Rack::UserContext.custom_user_hash = lambda do |rack_env|
50-
# rach_env['my_custom_key'].user
51+
# rack_env['my_custom_key'].user
5152
# end
5253
def custom_user_hash=(proc)
5354
if proc && !proc.is_a?(Proc)
@@ -78,14 +79,10 @@ def call(env)
7879
private
7980
def get_user_hash(env)
8081
# The order is relevant here. The 'warden' key can be set, but
81-
# not return a user, in which case the user data might be in the omniauth
82-
# data.
82+
# not return a user, in which case the user data might be in another key.
8383
if self.class.custom_user_hash.is_a?(Proc)
8484
Timber::Config.instance.debug { "Obtaining user context from the custom user hash" }
8585
self.class.custom_user_hash.call(env)
86-
elsif (auth_hash = env['omniauth.auth'])
87-
Timber::Config.instance.debug { "Obtaining user context from the omniauth auth hash" }
88-
get_omniauth_user_hash(auth_hash)
8986
elsif env[:clearance] && env[:clearance].signed_in?
9087
Timber::Config.instance.debug { "Obtaining user context from the clearance user" }
9188
user = env[:clearance].current_user
@@ -99,16 +96,6 @@ def get_user_hash(env)
9996
end
10097
end
10198

102-
def get_omniauth_user_hash(auth_hash)
103-
info = auth_hash['info']
104-
105-
{
106-
id: auth_hash['uid'],
107-
name: info['name'],
108-
email: info['email']
109-
}
110-
end
111-
11299
def get_user_object_hash(user)
113100
id = try_user_id(user)
114101
name = try_user_name(user)

0 commit comments

Comments
 (0)