Add producer to Live Event metadata

Fixes: PLAT-2371

Test-Plan:
 - spinup local live-event testing services
  - test out live-event spawning processes
    -- check live event docs for triggers of events
  - assert that the kinesis stream contains events with attributes
    containing `producer: 'canvas'`

Change-Id: I68789294005d60dc873a4316b60ff1a93a4e9b94
Reviewed-on: https://gerrit.instructure.com/105622
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Jayce Higgins <jhiggins@instructure.com>
This commit is contained in:
Jayce Higgins 2017-03-17 17:28:07 -05:00
parent 0ab8a61c2d
commit f0f0e7f5ec
4 changed files with 9 additions and 4 deletions

View File

@ -2146,8 +2146,6 @@ class ApplicationController < ActionController::Base
ctx[:user_id] = @current_user.global_id if @current_user ctx[:user_id] = @current_user.global_id if @current_user
ctx[:real_user_id] = @real_current_user.global_id if @real_current_user ctx[:real_user_id] = @real_current_user.global_id if @real_current_user
ctx[:user_login] = @current_pseudonym.unique_id if @current_pseudonym ctx[:user_login] = @current_pseudonym.unique_id if @current_pseudonym
ctx[:hostname] = request.host
ctx[:user_agent] = request.headers['User-Agent']
ctx[:context_type] = @context.class.to_s if @context ctx[:context_type] = @context.class.to_s if @context
ctx[:context_id] = @context.global_id if @context ctx[:context_id] = @context.global_id if @context
if @context_membership if @context_membership
@ -2166,6 +2164,10 @@ class ApplicationController < ActionController::Base
ctx[:session_id] = tctx[:session_id] ctx[:session_id] = tctx[:session_id]
end end
ctx[:hostname] = request.host
ctx[:user_agent] = request.headers['User-Agent']
ctx[:producer] = 'canvas'
StringifyIds.recursively_stringify_ids(ctx) StringifyIds.recursively_stringify_ids(ctx)
LiveEvents.set_context(ctx) LiveEvents.set_context(ctx)
end end

View File

@ -53,7 +53,8 @@ Delayed::Worker.lifecycle.around(:perform) do |worker, job, &block|
live_events_ctx = { live_events_ctx = {
:root_account_id => job.respond_to?(:global_account_id) ? job.global_account_id : nil, :root_account_id => job.respond_to?(:global_account_id) ? job.global_account_id : nil,
:job_id => job.global_id, :job_id => job.global_id,
:job_tag => job.tag :job_tag => job.tag,
:producer => 'canvas'
} }
StringifyIds.recursively_stringify_ids(live_events_ctx) StringifyIds.recursively_stringify_ids(live_events_ctx)
LiveEvents.set_context(live_events_ctx) LiveEvents.set_context(live_events_ctx)

View File

@ -46,6 +46,7 @@ event originated as part of a web request:
| `context_id` | String | The Canvas id of the current context. Always use the `context_type` when using this id to lookup the object. | | `context_id` | String | The Canvas id of the current context. Always use the `context_type` when using this id to lookup the object. |
| `role` | String | The role of the current user in the current context. | | `role` | String | The role of the current user in the current context. |
| `hostname` | String | The hostname of the current request | | `hostname` | String | The hostname of the current request |
| `producer` | String | The name of the producer of an event. Will always be 'canvas' when an event is originating in canvas. |
| `request_id` | String | The identifier for this request. | | `request_id` | String | The identifier for this request. |
| `session_id` | String | The session identifier for this request. Can be used to correlate events in the same session for a user. | | `session_id` | String | The session identifier for this request. Can be used to correlate events in the same session for a user. |

View File

@ -747,7 +747,8 @@ describe ApplicationController do
let(:non_conditional_values) do let(:non_conditional_values) do
{ {
hostname: 'test.host', hostname: 'test.host',
user_agent: 'Rails Testing' user_agent: 'Rails Testing',
producer: 'canvas'
} }
end end