Module: Aws::Xray
- Defined in:
- lib/aws/xray.rb,
lib/aws/xray/sql.rb,
lib/aws/xray/rack.rb,
lib/aws/xray/cause.rb,
lib/aws/xray/error.rb,
lib/aws/xray/rails.rb,
lib/aws/xray/trace.rb,
lib/aws/xray/client.rb,
lib/aws/xray/errors.rb,
lib/aws/xray/worker.rb,
lib/aws/xray/context.rb,
lib/aws/xray/faraday.rb,
lib/aws/xray/request.rb,
lib/aws/xray/segment.rb,
lib/aws/xray/sockets.rb,
lib/aws/xray/version.rb,
lib/aws/xray/response.rb,
lib/aws/xray/subsegment.rb,
lib/aws/xray/hooks/rsolr.rb,
lib/aws/xray/configuration.rb,
lib/aws/xray/header_parser.rb,
lib/aws/xray/caller_builder.rb,
lib/aws/xray/error_handlers.rb,
lib/aws/xray/hooks/net_http.rb,
lib/aws/xray/version_detector.rb,
lib/aws/xray/annotation_normalizer.rb
Defined Under Namespace
Modules: AnnotationNormalizer, CallerBuilder, HeaderParser, Hooks Classes: BaseError, CanNotSendAllByteError, Cause, Client, Configuration, Context, DefaultErrorHandler, Error, ErrorHandlerWithSentry, Faraday, IoSocket, MissingNameError, NotSetError, NullSocket, QueueIsFullError, Rack, Railtie, Request, Response, Segment, SegmentDidNotStartError, Sql, Subsegment, TestSocket, Trace, VersionDetector, Worker
Constant Summary collapse
- TRACE_HEADER =
'X-Amzn-Trace-Id'.freeze
- VERSION =
'0.39.0'.freeze
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.current_context ⇒ Aws::Xray::Context
Return current tracing context set to current thread.
-
.disable_trace(id, &block) ⇒ Object
Temporary disabling tracing for given id in given block.
-
.disabled?(id) ⇒ Boolean
Returns whether tracing is disabled with
.disable_tracefor givenid. -
.overwrite(name:, &block) ⇒ Object
Temporary overwrite subsegment with the name in the block.
-
.start_subsegment(name:, remote:) {|Aws::Xray::Subsegment| ... } ⇒ Object
Start subsegment if current thread has tracing context then send the subsegment to X-Ray daemon.
-
.started? ⇒ Boolean
Returns whether tracing context is started or not.
-
.trace(name: nil, trace: Trace.generate) ⇒ Object
Start new tracing context and segment.
-
.with_given_context(context, &block) ⇒ Object
Set tracing context to current thread with given context object.
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/aws/xray.rb', line 21 def config @config end |
Class Method Details
.current_context ⇒ Aws::Xray::Context
Return current tracing context set to current thread.
67 68 69 |
# File 'lib/aws/xray.rb', line 67 def current_context Context.current end |
.disable_trace(id, &block) ⇒ Object
Temporary disabling tracing for given id in given block. CAUTION: the disabling will NOT be propagated between threads!!
84 85 86 87 88 89 90 |
# File 'lib/aws/xray.rb', line 84 def disable_trace(id, &block) if started? current_context.disable_trace(id, &block) else block.call end end |
.disabled?(id) ⇒ Boolean
Returns whether tracing is disabled with .disable_trace for given id.
95 96 97 |
# File 'lib/aws/xray.rb', line 95 def disabled?(id) started? && current_context.disabled?(id) end |
.overwrite(name:, &block) ⇒ Object
Temporary overwrite subsegment with the name in the block. The overwriting will be occured only one time. If current context is not set to current thread, do nothing. CAUTION: the injection will NOT be propagated between threads!!
106 107 108 109 110 111 112 |
# File 'lib/aws/xray.rb', line 106 def overwrite(name:, &block) if started? current_context.overwrite(name: name, &block) else block.call end end |
.start_subsegment(name:, remote:) {|Aws::Xray::Subsegment| ... } ⇒ Object
Start subsegment if current thread has tracing context then send the subsegment to X-Ray daemon. Rescue all exceptions and record the exception to the subsegment. Then re-raise the exception.
48 49 50 51 52 53 54 |
# File 'lib/aws/xray.rb', line 48 def start_subsegment(name:, remote:, &block) if started? current_context.start_subsegment(name: name, remote: remote, &block) else block.call(Subsegment.build_null) end end |
.started? ⇒ Boolean
Returns whether tracing context is started or not.
58 59 60 |
# File 'lib/aws/xray.rb', line 58 def started? Context.started? end |
.trace(name: nil, trace: Trace.generate) ⇒ Object
Start new tracing context and segment. If trace is given it start tracing context following given trace. If name is omitted, it uses global application name. Rescue all exceptions and record the exception to the segment. Then re-raise the exception.
33 34 35 36 37 38 39 40 |
# File 'lib/aws/xray.rb', line 33 def trace(name: nil, trace: Trace.generate) name = name || config.name || raise(MissingNameError) Context.with_new_context(name, trace) do Context.current.start_segment do |seg| yield seg end end end |
.with_given_context(context, &block) ⇒ Object
Set tracing context to current thread with given context object.
75 76 77 |
# File 'lib/aws/xray.rb', line 75 def with_given_context(context, &block) Context.with_given_context(context, &block) end |