Class: Cybertrain::Test::SentryEnvelope

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/test/sentry_receiver.rb

Overview

One envelope as the receiver read it: the request’s path, its X-Sentry-Auth and Content-Type, and the envelope’s text.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sentry_auth ⇒ String (readonly)

The X-Sentry-Auth header.

Returns:

  • (String)


28
29
30
# File 'cybertrain/test/sentry_receiver.rb', line 28

def sentry_auth
  @sentry_auth
end

#sentry_body ⇒ String (readonly)

The envelope as sent: the envelope header, the item header and the event, one JSON object per line.

Returns:

  • (String)


39
40
41
# File 'cybertrain/test/sentry_receiver.rb', line 39

def sentry_body
  @sentry_body
end

#sentry_content_type ⇒ String (readonly)

The Content-Type header (application/x-sentry-envelope).

Returns:

  • (String)


33
34
35
# File 'cybertrain/test/sentry_receiver.rb', line 33

def sentry_content_type
  @sentry_content_type
end

#sentry_path ⇒ String (readonly)

The request’s path: /api/<project id>/envelope/, after the DSN’s path when it has one.

Returns:

  • (String)


23
24
25
# File 'cybertrain/test/sentry_receiver.rb', line 23

def sentry_path
  @sentry_path
end

Instance Method Details

#sentry_field(path) ⇒ String

A field of the event (the envelope’s third line) by its dotted path: "exception.values.0.type", an Array’s elements by their index. In an object, the longest run of the path’s remaining parts that is a key is taken first, so a key with dots in it (a job report’s extra, "job.attempt") is read whole: "extra.job.attempt". A String is itself, a number or a boolean its JSON text; "" when the field is absent, null, an object or an array.

Examples:

env.sentry_field("tags.request_id")   # => "4f1c..."
env.sentry_field("extra.job.attempt") # => "2"

Parameters:

  • path (String)

Returns:

  • (String)


67
68
69
# File 'cybertrain/test/sentry_receiver.rb', line 67

def sentry_field(path)
  SentryEnvelope.json_field(SentryEnvelope.envelope_line(@sentry_body, 2), path)
end

#sentry_header_field(name) ⇒ String

A field of the envelope header (its first line): "event_id", "sent_at", "dsn"; read as #sentry_field reads the event.

Parameters:

  • name (String)

Returns:

  • (String)


76
77
78
# File 'cybertrain/test/sentry_receiver.rb', line 76

def sentry_header_field(name)
  SentryEnvelope.json_field(SentryEnvelope.envelope_line(@sentry_body, 0), name)
end