appsignal 4.10.1-java → 5.0.0.rc.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Rakefile +87 -0
  4. data/appsignal.gemspec +8 -0
  5. data/build_matrix.yml +14 -1
  6. data/ext/appsignal_extension.c +14 -0
  7. data/lib/appsignal/backends.rb +55 -0
  8. data/lib/appsignal/config.rb +140 -1
  9. data/lib/appsignal/demo.rb +1 -1
  10. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +34 -22
  11. data/lib/appsignal/event_formatter/active_job/perform_formatter.rb +35 -0
  12. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +19 -0
  13. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +27 -0
  14. data/lib/appsignal/event_formatter/recorded_elsewhere.rb +17 -0
  15. data/lib/appsignal/event_formatter/rom/sql_formatter.rb +24 -0
  16. data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +5 -0
  17. data/lib/appsignal/event_formatter/view_component/render_formatter.rb +21 -10
  18. data/lib/appsignal/event_formatter.rb +78 -0
  19. data/lib/appsignal/extension.rb +4 -0
  20. data/lib/appsignal/helpers/instrumentation.rb +236 -20
  21. data/lib/appsignal/helpers/metrics.rb +3 -24
  22. data/lib/appsignal/hooks/action_cable.rb +18 -6
  23. data/lib/appsignal/hooks/active_job.rb +128 -39
  24. data/lib/appsignal/hooks/at_exit.rb +4 -1
  25. data/lib/appsignal/hooks/excon.rb +20 -0
  26. data/lib/appsignal/hooks/faraday.rb +16 -0
  27. data/lib/appsignal/hooks/http.rb +5 -0
  28. data/lib/appsignal/hooks/resque.rb +1 -1
  29. data/lib/appsignal/hooks/sequel.rb +32 -2
  30. data/lib/appsignal/hooks/shoryuken.rb +3 -3
  31. data/lib/appsignal/hooks/sidekiq.rb +1 -1
  32. data/lib/appsignal/integrations/action_cable.rb +5 -2
  33. data/lib/appsignal/integrations/active_support_notifications.rb +59 -14
  34. data/lib/appsignal/integrations/data_mapper.rb +14 -2
  35. data/lib/appsignal/integrations/delayed_job_plugin.rb +45 -5
  36. data/lib/appsignal/integrations/dry_monitor.rb +39 -15
  37. data/lib/appsignal/integrations/excon/appsignal_middleware.rb +21 -0
  38. data/lib/appsignal/integrations/excon.rb +52 -15
  39. data/lib/appsignal/integrations/faraday.rb +47 -12
  40. data/lib/appsignal/integrations/http.rb +43 -1
  41. data/lib/appsignal/integrations/mongo_ruby_driver.rb +73 -4
  42. data/lib/appsignal/integrations/net_http.rb +31 -2
  43. data/lib/appsignal/integrations/puma.rb +4 -1
  44. data/lib/appsignal/integrations/que.rb +224 -37
  45. data/lib/appsignal/integrations/railtie.rb +4 -1
  46. data/lib/appsignal/integrations/rake.rb +9 -3
  47. data/lib/appsignal/integrations/redis.rb +22 -1
  48. data/lib/appsignal/integrations/redis_client.rb +22 -1
  49. data/lib/appsignal/integrations/resque.rb +57 -10
  50. data/lib/appsignal/integrations/shoryuken.rb +140 -12
  51. data/lib/appsignal/integrations/sidekiq.rb +73 -16
  52. data/lib/appsignal/integrations/webmachine.rb +47 -4
  53. data/lib/appsignal/loaders/padrino.rb +2 -1
  54. data/lib/appsignal/logger/extension_backend.rb +24 -0
  55. data/lib/appsignal/logger/opentelemetry_backend.rb +66 -0
  56. data/lib/appsignal/logger.rb +13 -9
  57. data/lib/appsignal/metrics/extension_backend.rb +47 -0
  58. data/lib/appsignal/metrics/opentelemetry_backend.rb +89 -0
  59. data/lib/appsignal/opentelemetry/attributes.rb +31 -0
  60. data/lib/appsignal/opentelemetry/dependencies.rb +35 -0
  61. data/lib/appsignal/opentelemetry/error_type.rb +37 -0
  62. data/lib/appsignal/opentelemetry/http_client_request.rb +83 -0
  63. data/lib/appsignal/opentelemetry/http_method.rb +59 -0
  64. data/lib/appsignal/opentelemetry/http_response.rb +30 -0
  65. data/lib/appsignal/opentelemetry/http_server_request.rb +45 -0
  66. data/lib/appsignal/opentelemetry/messaging.rb +82 -0
  67. data/lib/appsignal/opentelemetry/rendering.rb +29 -0
  68. data/lib/appsignal/opentelemetry/sql_db_system.rb +89 -0
  69. data/lib/appsignal/opentelemetry.rb +337 -0
  70. data/lib/appsignal/rack/abstract_middleware.rb +63 -4
  71. data/lib/appsignal/rack/body_wrapper.rb +18 -5
  72. data/lib/appsignal/rack/event_handler.rb +36 -3
  73. data/lib/appsignal/rack/grape_middleware.rb +1 -0
  74. data/lib/appsignal/rack/hanami_middleware.rb +2 -1
  75. data/lib/appsignal/rack/instrumentation_middleware.rb +1 -0
  76. data/lib/appsignal/rack/rails_instrumentation.rb +1 -0
  77. data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -0
  78. data/lib/appsignal/rack.rb +39 -11
  79. data/lib/appsignal/sample_data.rb +4 -0
  80. data/lib/appsignal/transaction/base_backend.rb +107 -0
  81. data/lib/appsignal/transaction/extension_backend.rb +203 -0
  82. data/lib/appsignal/transaction/opentelemetry_backend.rb +796 -0
  83. data/lib/appsignal/transaction.rb +537 -144
  84. data/lib/appsignal/utils/stdout_and_logger_message.rb +9 -0
  85. data/lib/appsignal/version.rb +1 -1
  86. data/lib/appsignal.rb +9 -0
  87. data/sig/appsignal.rbi +426 -37
  88. data/sig/appsignal.rbs +386 -27
  89. metadata +23 -1
data/sig/appsignal.rbi CHANGED
@@ -8,7 +8,7 @@
8
8
  module Appsignal
9
9
  extend Appsignal::Helpers::Metrics
10
10
  extend Appsignal::Helpers::Instrumentation
11
- VERSION = T.let("4.10.1", T.untyped)
11
+ VERSION = T.let("5.0.0.rc.1", T.untyped)
12
12
 
13
13
  class << self
14
14
  # The loaded AppSignal configuration.
@@ -301,6 +301,14 @@ module Appsignal
301
301
  #
302
302
  # _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
303
303
  #
304
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
305
+ #
306
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
307
+ #
308
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
309
+ #
310
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
311
+ #
304
312
  # _@return_ — The value of the given block is returned.
305
313
  # Returns `nil` if there already is a transaction active and no block
306
314
  # was given.
@@ -391,8 +399,18 @@ module Appsignal
391
399
  # ```
392
400
  #
393
401
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
394
- sig { params(action: T.any(String, Symbol, NilClass), namespace: T.nilable(T.any(String, Symbol)), blk: T.proc.returns(Object)).returns(T.nilable(Object)) }
395
- def self.monitor(action:, namespace: nil, &blk); end
402
+ sig do
403
+ params(
404
+ action: T.any(String, Symbol, NilClass),
405
+ namespace: T.nilable(T.any(String, Symbol)),
406
+ opentelemetry_context: T.untyped,
407
+ opentelemetry_scope: T.nilable([String, String]),
408
+ opentelemetry_kind: T.nilable(Symbol),
409
+ opentelemetry_relationship: T.nilable(Symbol),
410
+ blk: T.proc.returns(Object)
411
+ ).returns(T.nilable(Object))
412
+ end
413
+ def self.monitor(action:, namespace: nil, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &blk); end
396
414
 
397
415
  # Instrument a block of code and stop AppSignal.
398
416
  #
@@ -406,11 +424,29 @@ module Appsignal
406
424
  #
407
425
  # _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
408
426
  #
427
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
428
+ #
429
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
430
+ #
431
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
432
+ #
433
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
434
+ #
409
435
  # _@return_ — The value of the given block is returned.
410
436
  #
411
437
  # _@see_ `monitor`
412
- sig { params(action: T.any(String, Symbol, NilClass), namespace: T.nilable(T.any(String, Symbol)), block: T.proc.returns(Object)).returns(T.nilable(Object)) }
413
- def self.monitor_and_stop(action:, namespace: nil, &block); end
438
+ sig do
439
+ params(
440
+ action: T.any(String, Symbol, NilClass),
441
+ namespace: T.nilable(T.any(String, Symbol)),
442
+ opentelemetry_context: T.untyped,
443
+ opentelemetry_scope: T.nilable([String, String]),
444
+ opentelemetry_kind: T.nilable(Symbol),
445
+ opentelemetry_relationship: T.nilable(Symbol),
446
+ block: T.proc.returns(Object)
447
+ ).returns(T.nilable(Object))
448
+ end
449
+ def self.monitor_and_stop(action:, namespace: nil, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
414
450
 
415
451
  # Send an error to AppSignal regardless of the context.
416
452
  #
@@ -429,6 +465,14 @@ module Appsignal
429
465
  #
430
466
  # _@param_ `error` — The error to send to AppSignal.
431
467
  #
468
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
469
+ #
470
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
471
+ #
472
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
473
+ #
474
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
475
+ #
432
476
  # Send an exception
433
477
  # ```ruby
434
478
  # begin
@@ -449,8 +493,17 @@ module Appsignal
449
493
  # ```
450
494
  #
451
495
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
452
- sig { params(error: Exception, block: T.proc.params(transaction: Transaction).void).void }
453
- def self.send_error(error, &block); end
496
+ sig do
497
+ params(
498
+ error: Exception,
499
+ opentelemetry_context: T.untyped,
500
+ opentelemetry_scope: T.nilable([String, String]),
501
+ opentelemetry_kind: T.nilable(Symbol),
502
+ opentelemetry_relationship: T.nilable(Symbol),
503
+ block: T.proc.params(transaction: Transaction).void
504
+ ).void
505
+ end
506
+ def self.send_error(error, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
454
507
 
455
508
  # Set an error on the current transaction.
456
509
  #
@@ -523,6 +576,14 @@ module Appsignal
523
576
  #
524
577
  # _@param_ `exception` — The error to add to the current transaction.
525
578
  #
579
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`. Only used when a new transaction is created.
580
+ #
581
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`. Only used when a new transaction is created.
582
+ #
583
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to. Only used when a new transaction is created.
584
+ #
585
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
586
+ #
526
587
  # ```ruby
527
588
  # class SomeController < ApplicationController
528
589
  # def create
@@ -544,8 +605,17 @@ module Appsignal
544
605
  # ```
545
606
  #
546
607
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
547
- sig { params(exception: Exception, block: T.proc.params(transaction: Transaction).void).void }
548
- def self.report_error(exception, &block); end
608
+ sig do
609
+ params(
610
+ exception: Exception,
611
+ opentelemetry_context: T.untyped,
612
+ opentelemetry_scope: T.nilable([String, String]),
613
+ opentelemetry_kind: T.nilable(Symbol),
614
+ opentelemetry_relationship: T.nilable(Symbol),
615
+ block: T.proc.params(transaction: Transaction).void
616
+ ).void
617
+ end
618
+ def self.report_error(exception, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
549
619
 
550
620
  # Set a custom action name for the current transaction.
551
621
  #
@@ -743,16 +813,65 @@ module Appsignal
743
813
  sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
744
814
  def self.add_params(params = nil, &block); end
745
815
 
816
+ # Add the request payload to the current transaction.
817
+ #
818
+ # The request payload is the parameters of an incoming request, such as
819
+ # the query string and the request body. In collector mode it maps to its
820
+ # own attribute, separate from the function parameters.
821
+ #
822
+ # Behaves like {#add_params}: merges when called multiple times, and a
823
+ # block takes precedence over the argument.
824
+ #
825
+ # _@param_ `params` — The request payload to add to the transaction.
826
+ #
827
+ # _@see_ `#add_function_parameters`
828
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
829
+ def self.add_request_payload(params = nil, &block); end
830
+
831
+ # Add the function parameters to the current transaction.
832
+ #
833
+ # The function parameters are the arguments a background job or function
834
+ # was called with. In collector mode they map to their own attribute,
835
+ # separate from the request payload.
836
+ #
837
+ # Behaves like {#add_params}: merges when called multiple times, and a
838
+ # block takes precedence over the argument.
839
+ #
840
+ # _@param_ `params` — The function parameters to add to the transaction.
841
+ #
842
+ # _@see_ `#add_request_payload`
843
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
844
+ def self.add_function_parameters(params = nil, &block); end
845
+
846
+ # Add the query parameters to the current transaction.
847
+ #
848
+ # The query parameters are the parameters parsed from an incoming
849
+ # request's query string. In collector mode they map to their own
850
+ # attribute, separate from the request payload and the function
851
+ # parameters.
852
+ #
853
+ # Behaves like {#add_params}: merges when called multiple times, and a
854
+ # block takes precedence over the argument.
855
+ #
856
+ # _@param_ `params` — The query parameters to add to the transaction.
857
+ #
858
+ # _@see_ `#add_request_payload`
859
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
860
+ def self.add_query_parameters(params = nil, &block); end
861
+
746
862
  # Mark the parameters sample data to be set as an empty value.
747
863
  #
748
- # Use this helper to unset request parameters / background job arguments
749
- # and not report any for this transaction.
864
+ # Use this helper to report no parameters for this transaction, whatever
865
+ # their source.
750
866
  #
751
- # If parameters would normally be added by AppSignal instrumentations of
752
- # libraries, these parameters will not be added to the Transaction.
867
+ # This suppresses every params channel. In collector mode, where the
868
+ # request payload and the function parameters (a background job's
869
+ # arguments) are tracked as separate attributes, it suppresses both, not
870
+ # only the request payload. Parameters that an AppSignal integration would
871
+ # otherwise add are not added.
753
872
  #
754
- # Calling {#add_params} after this helper will add new parameters to the
755
- # transaction.
873
+ # Calling {#add_params}, {#add_request_payload} or
874
+ # {#add_function_parameters} after this helper adds parameters again.
756
875
  #
757
876
  # _@see_ `Transaction#set_empty_params!`
758
877
  #
@@ -833,7 +952,7 @@ module Appsignal
833
952
  # Breadcrumbs can be used to trace what path a user has taken
834
953
  # before encountering an error.
835
954
  #
836
- # Only the last 20 added breadcrumbs will be saved.
955
+ # At most 20 of the added breadcrumbs will be saved.
837
956
  #
838
957
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
839
958
  #
@@ -891,6 +1010,10 @@ module Appsignal
891
1010
  #
892
1011
  # _@param_ `body_format` — Enum for the type of event that is instrumented. Accepted values are {EventFormatter::DEFAULT} and {EventFormatter::SQL_BODY_FORMAT}, but we recommend you use {.instrument_sql} instead of {EventFormatter::SQL_BODY_FORMAT}.
893
1012
  #
1013
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind for the event's span, such as `:client` for an outgoing HTTP request. Defaults to the OpenTelemetry default of `:internal`.
1014
+ #
1015
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record the event's span under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
1016
+ #
894
1017
  # _@return_ — Returns the block's return value.
895
1018
  #
896
1019
  # Simple instrumentation
@@ -922,10 +1045,12 @@ module Appsignal
922
1045
  title: T.nilable(String),
923
1046
  body: T.nilable(String),
924
1047
  body_format: Integer,
1048
+ opentelemetry_kind: T.nilable(Symbol),
1049
+ opentelemetry_scope: T.nilable([String, String]),
925
1050
  block: T.untyped
926
1051
  ).returns(Object)
927
1052
  end
928
- def self.instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT, &block); end
1053
+ def self.instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT, opentelemetry_kind: nil, opentelemetry_scope: nil, &block); end
929
1054
 
930
1055
  # Instrumentation helper for SQL queries.
931
1056
  #
@@ -937,6 +1062,10 @@ module Appsignal
937
1062
  #
938
1063
  # _@param_ `body` — SQL query that's being executed.
939
1064
  #
1065
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind for the event's span. Defaults to `:client`, because a query is an outgoing call to a datastore. Pass `:internal` for a query that is not an outgoing call.
1066
+ #
1067
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record the event's span under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
1068
+ #
940
1069
  # _@return_ — Returns the block's return value.
941
1070
  #
942
1071
  # SQL query instrumentation
@@ -965,10 +1094,12 @@ module Appsignal
965
1094
  name: String,
966
1095
  title: T.nilable(String),
967
1096
  body: T.nilable(String),
1097
+ opentelemetry_kind: Symbol,
1098
+ opentelemetry_scope: T.nilable([String, String]),
968
1099
  block: T.untyped
969
1100
  ).returns(Object)
970
1101
  end
971
- def self.instrument_sql(name, title = nil, body = nil, &block); end
1102
+ def self.instrument_sql(name, title = nil, body = nil, opentelemetry_kind: :client, opentelemetry_scope: nil, &block); end
972
1103
 
973
1104
  # Convenience method for ignoring instrumentation events in a block of
974
1105
  # code.
@@ -1041,6 +1172,38 @@ module Appsignal
1041
1172
  sig { returns(T::Boolean) }
1042
1173
  def active?; end
1043
1174
 
1175
+ # Check if collector mode is configured.
1176
+ #
1177
+ # Returns true when a non-empty `collector_endpoint` is set and the
1178
+ # running Ruby version is at least {MIN_RUBY_VERSION_FOR_COLLECTOR_MODE}.
1179
+ # On older Rubies, `collector_endpoint` is ignored (with a warning) and
1180
+ # the AppSignal agent is used instead.
1181
+ #
1182
+ # This is the *intent* check — it answers "did the user ask for
1183
+ # collector mode, and could we honor it?". It does not say whether the
1184
+ # OpenTelemetry SDK actually booted. See {#collector_mode?} for that.
1185
+ #
1186
+ # Memoised: the result is cached on first call so hot paths avoid
1187
+ # re-running the string-strip predicate, and so the unsupported-Ruby
1188
+ # warning is emitted at most once per `Config` instance.
1189
+ #
1190
+ # _@return_ — True if collector mode is configured.
1191
+ sig { returns(T::Boolean) }
1192
+ def collector_mode_configured?; end
1193
+
1194
+ # Check if AppSignal is actively running in collector mode.
1195
+ #
1196
+ # True only if collector mode is {#collector_mode_configured? configured}
1197
+ # *and* `Appsignal::OpenTelemetry.configure` has successfully booted the
1198
+ # SDK in this process. Use this for backend dispatch on hot paths
1199
+ # (metric and log emits): if the OTel boot failed, callers fall back to
1200
+ # the agent backend rather than silently dropping data into no-op
1201
+ # providers.
1202
+ #
1203
+ # _@return_ — True if collector mode is configured and started.
1204
+ sig { returns(T::Boolean) }
1205
+ def collector_mode?; end
1206
+
1044
1207
  sig { returns(T::Boolean) }
1045
1208
  def yml_config_file?; end
1046
1209
 
@@ -1662,8 +1825,24 @@ module Appsignal
1662
1825
  # transaction.
1663
1826
  #
1664
1827
  # _@param_ `namespace` — Namespace of the to be created transaction.
1665
- sig { params(namespace: String).returns(Transaction) }
1666
- def self.create(namespace); end
1828
+ #
1829
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
1830
+ #
1831
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
1832
+ #
1833
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
1834
+ #
1835
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
1836
+ sig do
1837
+ params(
1838
+ namespace: String,
1839
+ opentelemetry_context: T.untyped,
1840
+ opentelemetry_scope: T.nilable([String, String]),
1841
+ opentelemetry_kind: T.nilable(Symbol),
1842
+ opentelemetry_relationship: T.nilable(Symbol)
1843
+ ).returns(Transaction)
1844
+ end
1845
+ def self.create(namespace, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil); end
1667
1846
 
1668
1847
  # Returns currently active transaction or a {NilTransaction} if none is
1669
1848
  # active.
@@ -1699,6 +1878,52 @@ module Appsignal
1699
1878
  sig { params(given_params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
1700
1879
  def add_params(given_params = nil, &block); end
1701
1880
 
1881
+ # Add the request payload to the transaction.
1882
+ #
1883
+ # These are the parameters of an incoming request, such as the query string
1884
+ # and the request body. In collector mode they map to the request payload
1885
+ # attribute. In agent mode they are the transaction's params.
1886
+ #
1887
+ # Behaves like {#add_params}: merges when called multiple times, and a
1888
+ # block takes precedence over the argument.
1889
+ #
1890
+ # _@param_ `given_params` — The parameters to add to the transaction.
1891
+ #
1892
+ # _@see_ `#add_function_parameters`
1893
+ sig { params(given_params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
1894
+ def add_request_payload(given_params = nil, &block); end
1895
+
1896
+ # Add the function parameters to the transaction.
1897
+ #
1898
+ # These are the arguments a background job or function was called with. In
1899
+ # collector mode they map to the function parameters attribute. In agent
1900
+ # mode they are the transaction's params.
1901
+ #
1902
+ # Behaves like {#add_params}: merges when called multiple times, and a
1903
+ # block takes precedence over the argument.
1904
+ #
1905
+ # _@param_ `given_params` — The parameters to add to the transaction.
1906
+ #
1907
+ # _@see_ `#add_request_payload`
1908
+ sig { params(given_params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
1909
+ def add_function_parameters(given_params = nil, &block); end
1910
+
1911
+ # Add the query parameters to the transaction.
1912
+ #
1913
+ # These are the parameters parsed from an incoming request's query string.
1914
+ # In collector mode they map to their own attribute, separate from the
1915
+ # request payload and the function parameters. In agent mode they are the
1916
+ # transaction's params.
1917
+ #
1918
+ # Behaves like {#add_params}: merges when called multiple times, and a
1919
+ # block takes precedence over the argument.
1920
+ #
1921
+ # _@param_ `given_params` — The parameters to add to the transaction.
1922
+ #
1923
+ # _@see_ `#add_request_payload`
1924
+ sig { params(given_params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
1925
+ def add_query_parameters(given_params = nil, &block); end
1926
+
1702
1927
  # Add tags to the transaction.
1703
1928
  #
1704
1929
  # When this method is called multiple times, it will merge the tags.
@@ -1809,6 +2034,36 @@ module Appsignal
1809
2034
  # _@param_ `start` — Queue start time in milliseconds.
1810
2035
  sig { params(start: Integer).void }
1811
2036
  def set_queue_start(start); end
2037
+
2038
+ # Add OpenTelemetry attributes to the span AppSignal is currently
2039
+ # recording.
2040
+ #
2041
+ # In collector mode, AppSignal records a transaction as an OpenTelemetry
2042
+ # span, and every instrumented event as a child span. This adds attributes
2043
+ # to whichever of those spans is open right now: the innermost event
2044
+ # started by {Appsignal::Helpers::Instrumentation#instrument}, or the
2045
+ # transaction's own span when no event is open.
2046
+ #
2047
+ # Use this to describe what is being instrumented in OpenTelemetry's own
2048
+ # terms, following the OpenTelemetry semantic conventions where they apply.
2049
+ # Attributes have no equivalent outside collector mode, so this does
2050
+ # nothing when collector mode is not active.
2051
+ #
2052
+ # _@param_ `attributes` — Attributes to add to the current span. Values that are not a String, Integer, Float or boolean are converted to a String. Nothing is added when this is nil or empty.
2053
+ #
2054
+ # Describing a database query
2055
+ # ```ruby
2056
+ # Appsignal.instrument("query.my_database") do
2057
+ # Appsignal::Transaction.current.add_opentelemetry_attributes(
2058
+ # "db.system.name" => "mysql"
2059
+ # )
2060
+ # run_the_query
2061
+ # end
2062
+ # ```
2063
+ #
2064
+ # _@see_ `https://opentelemetry.io/docs/specs/semconv/` — OpenTelemetry semantic conventions
2065
+ sig { params(attributes: T.nilable(T::Hash[String, Object])).void }
2066
+ def add_opentelemetry_attributes(attributes = {}); end
1812
2067
  end
1813
2068
 
1814
2069
  # Custom markers are used on AppSignal.com to indicate events in an
@@ -1957,6 +2212,14 @@ module Appsignal
1957
2212
  #
1958
2213
  # _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
1959
2214
  #
2215
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2216
+ #
2217
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
2218
+ #
2219
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2220
+ #
2221
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2222
+ #
1960
2223
  # _@return_ — The value of the given block is returned.
1961
2224
  # Returns `nil` if there already is a transaction active and no block
1962
2225
  # was given.
@@ -2047,8 +2310,18 @@ module Appsignal
2047
2310
  # ```
2048
2311
  #
2049
2312
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
2050
- sig { params(action: T.any(String, Symbol, NilClass), namespace: T.nilable(T.any(String, Symbol)), blk: T.proc.returns(Object)).returns(T.nilable(Object)) }
2051
- def monitor(action:, namespace: nil, &blk); end
2313
+ sig do
2314
+ params(
2315
+ action: T.any(String, Symbol, NilClass),
2316
+ namespace: T.nilable(T.any(String, Symbol)),
2317
+ opentelemetry_context: T.untyped,
2318
+ opentelemetry_scope: T.nilable([String, String]),
2319
+ opentelemetry_kind: T.nilable(Symbol),
2320
+ opentelemetry_relationship: T.nilable(Symbol),
2321
+ blk: T.proc.returns(Object)
2322
+ ).returns(T.nilable(Object))
2323
+ end
2324
+ def monitor(action:, namespace: nil, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &blk); end
2052
2325
 
2053
2326
  # Instrument a block of code and stop AppSignal.
2054
2327
  #
@@ -2062,11 +2335,29 @@ module Appsignal
2062
2335
  #
2063
2336
  # _@param_ `action` — The action name for the transaction. The action name is required to be set for the transaction to be reported. The argument can be set to `nil` or `:set_later` if the action is set within the block with {#set_action}. This will not update the active transaction's action if {.monitor} is called when another transaction is already active.
2064
2337
  #
2338
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2339
+ #
2340
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
2341
+ #
2342
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2343
+ #
2344
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2345
+ #
2065
2346
  # _@return_ — The value of the given block is returned.
2066
2347
  #
2067
2348
  # _@see_ `monitor`
2068
- sig { params(action: T.any(String, Symbol, NilClass), namespace: T.nilable(T.any(String, Symbol)), block: T.proc.returns(Object)).returns(T.nilable(Object)) }
2069
- def monitor_and_stop(action:, namespace: nil, &block); end
2349
+ sig do
2350
+ params(
2351
+ action: T.any(String, Symbol, NilClass),
2352
+ namespace: T.nilable(T.any(String, Symbol)),
2353
+ opentelemetry_context: T.untyped,
2354
+ opentelemetry_scope: T.nilable([String, String]),
2355
+ opentelemetry_kind: T.nilable(Symbol),
2356
+ opentelemetry_relationship: T.nilable(Symbol),
2357
+ block: T.proc.returns(Object)
2358
+ ).returns(T.nilable(Object))
2359
+ end
2360
+ def monitor_and_stop(action:, namespace: nil, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
2070
2361
 
2071
2362
  # Send an error to AppSignal regardless of the context.
2072
2363
  #
@@ -2085,6 +2376,14 @@ module Appsignal
2085
2376
  #
2086
2377
  # _@param_ `error` — The error to send to AppSignal.
2087
2378
  #
2379
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2380
+ #
2381
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`.
2382
+ #
2383
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2384
+ #
2385
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2386
+ #
2088
2387
  # Send an exception
2089
2388
  # ```ruby
2090
2389
  # begin
@@ -2105,8 +2404,17 @@ module Appsignal
2105
2404
  # ```
2106
2405
  #
2107
2406
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
2108
- sig { params(error: Exception, block: T.proc.params(transaction: Transaction).void).void }
2109
- def send_error(error, &block); end
2407
+ sig do
2408
+ params(
2409
+ error: Exception,
2410
+ opentelemetry_context: T.untyped,
2411
+ opentelemetry_scope: T.nilable([String, String]),
2412
+ opentelemetry_kind: T.nilable(Symbol),
2413
+ opentelemetry_relationship: T.nilable(Symbol),
2414
+ block: T.proc.params(transaction: Transaction).void
2415
+ ).void
2416
+ end
2417
+ def send_error(error, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
2110
2418
 
2111
2419
  # Set an error on the current transaction.
2112
2420
  #
@@ -2179,6 +2487,14 @@ module Appsignal
2179
2487
  #
2180
2488
  # _@param_ `exception` — The error to add to the current transaction.
2181
2489
  #
2490
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`. Only used when a new transaction is created.
2491
+ #
2492
+ # _@param_ `opentelemetry_relationship` — In collector mode, how an incoming `opentelemetry_context` relates to this transaction's span: one of `:parent`, `:link`, `:both` or `:none`. Defaults to `:parent`. Only used when a new transaction is created.
2493
+ #
2494
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to. Only used when a new transaction is created.
2495
+ #
2496
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record this transaction's spans under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2497
+ #
2182
2498
  # ```ruby
2183
2499
  # class SomeController < ApplicationController
2184
2500
  # def create
@@ -2200,8 +2516,17 @@ module Appsignal
2200
2516
  # ```
2201
2517
  #
2202
2518
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
2203
- sig { params(exception: Exception, block: T.proc.params(transaction: Transaction).void).void }
2204
- def report_error(exception, &block); end
2519
+ sig do
2520
+ params(
2521
+ exception: Exception,
2522
+ opentelemetry_context: T.untyped,
2523
+ opentelemetry_scope: T.nilable([String, String]),
2524
+ opentelemetry_kind: T.nilable(Symbol),
2525
+ opentelemetry_relationship: T.nilable(Symbol),
2526
+ block: T.proc.params(transaction: Transaction).void
2527
+ ).void
2528
+ end
2529
+ def report_error(exception, opentelemetry_context: nil, opentelemetry_scope: nil, opentelemetry_kind: nil, opentelemetry_relationship: nil, &block); end
2205
2530
 
2206
2531
  # Set a custom action name for the current transaction.
2207
2532
  #
@@ -2399,16 +2724,65 @@ module Appsignal
2399
2724
  sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
2400
2725
  def add_params(params = nil, &block); end
2401
2726
 
2727
+ # Add the request payload to the current transaction.
2728
+ #
2729
+ # The request payload is the parameters of an incoming request, such as
2730
+ # the query string and the request body. In collector mode it maps to its
2731
+ # own attribute, separate from the function parameters.
2732
+ #
2733
+ # Behaves like {#add_params}: merges when called multiple times, and a
2734
+ # block takes precedence over the argument.
2735
+ #
2736
+ # _@param_ `params` — The request payload to add to the transaction.
2737
+ #
2738
+ # _@see_ `#add_function_parameters`
2739
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
2740
+ def add_request_payload(params = nil, &block); end
2741
+
2742
+ # Add the function parameters to the current transaction.
2743
+ #
2744
+ # The function parameters are the arguments a background job or function
2745
+ # was called with. In collector mode they map to their own attribute,
2746
+ # separate from the request payload.
2747
+ #
2748
+ # Behaves like {#add_params}: merges when called multiple times, and a
2749
+ # block takes precedence over the argument.
2750
+ #
2751
+ # _@param_ `params` — The function parameters to add to the transaction.
2752
+ #
2753
+ # _@see_ `#add_request_payload`
2754
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
2755
+ def add_function_parameters(params = nil, &block); end
2756
+
2757
+ # Add the query parameters to the current transaction.
2758
+ #
2759
+ # The query parameters are the parameters parsed from an incoming
2760
+ # request's query string. In collector mode they map to their own
2761
+ # attribute, separate from the request payload and the function
2762
+ # parameters.
2763
+ #
2764
+ # Behaves like {#add_params}: merges when called multiple times, and a
2765
+ # block takes precedence over the argument.
2766
+ #
2767
+ # _@param_ `params` — The query parameters to add to the transaction.
2768
+ #
2769
+ # _@see_ `#add_request_payload`
2770
+ sig { params(params: T.nilable(T.any(T::Hash[String, Object], T::Array[Object])), block: T.proc.returns(T.any(T::Hash[String, Object], T::Array[Object]))).void }
2771
+ def add_query_parameters(params = nil, &block); end
2772
+
2402
2773
  # Mark the parameters sample data to be set as an empty value.
2403
2774
  #
2404
- # Use this helper to unset request parameters / background job arguments
2405
- # and not report any for this transaction.
2775
+ # Use this helper to report no parameters for this transaction, whatever
2776
+ # their source.
2406
2777
  #
2407
- # If parameters would normally be added by AppSignal instrumentations of
2408
- # libraries, these parameters will not be added to the Transaction.
2778
+ # This suppresses every params channel. In collector mode, where the
2779
+ # request payload and the function parameters (a background job's
2780
+ # arguments) are tracked as separate attributes, it suppresses both, not
2781
+ # only the request payload. Parameters that an AppSignal integration would
2782
+ # otherwise add are not added.
2409
2783
  #
2410
- # Calling {#add_params} after this helper will add new parameters to the
2411
- # transaction.
2784
+ # Calling {#add_params}, {#add_request_payload} or
2785
+ # {#add_function_parameters} after this helper adds parameters again.
2412
2786
  #
2413
2787
  # _@see_ `Transaction#set_empty_params!`
2414
2788
  #
@@ -2489,7 +2863,7 @@ module Appsignal
2489
2863
  # Breadcrumbs can be used to trace what path a user has taken
2490
2864
  # before encountering an error.
2491
2865
  #
2492
- # Only the last 20 added breadcrumbs will be saved.
2866
+ # At most 20 of the added breadcrumbs will be saved.
2493
2867
  #
2494
2868
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
2495
2869
  #
@@ -2547,6 +2921,10 @@ module Appsignal
2547
2921
  #
2548
2922
  # _@param_ `body_format` — Enum for the type of event that is instrumented. Accepted values are {EventFormatter::DEFAULT} and {EventFormatter::SQL_BODY_FORMAT}, but we recommend you use {.instrument_sql} instead of {EventFormatter::SQL_BODY_FORMAT}.
2549
2923
  #
2924
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind for the event's span, such as `:client` for an outgoing HTTP request. Defaults to the OpenTelemetry default of `:internal`.
2925
+ #
2926
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record the event's span under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2927
+ #
2550
2928
  # _@return_ — Returns the block's return value.
2551
2929
  #
2552
2930
  # Simple instrumentation
@@ -2578,10 +2956,12 @@ module Appsignal
2578
2956
  title: T.nilable(String),
2579
2957
  body: T.nilable(String),
2580
2958
  body_format: Integer,
2959
+ opentelemetry_kind: T.nilable(Symbol),
2960
+ opentelemetry_scope: T.nilable([String, String]),
2581
2961
  block: T.untyped
2582
2962
  ).returns(Object)
2583
2963
  end
2584
- def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT, &block); end
2964
+ def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT, opentelemetry_kind: nil, opentelemetry_scope: nil, &block); end
2585
2965
 
2586
2966
  # Instrumentation helper for SQL queries.
2587
2967
  #
@@ -2593,6 +2973,10 @@ module Appsignal
2593
2973
  #
2594
2974
  # _@param_ `body` — SQL query that's being executed.
2595
2975
  #
2976
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind for the event's span. Defaults to `:client`, because a query is an outgoing call to a datastore. Pass `:internal` for a query that is not an outgoing call.
2977
+ #
2978
+ # _@param_ `opentelemetry_scope` — In collector mode, the OpenTelemetry instrumentation scope to record the event's span under, given as a `[name, version]` pair. Defaults to the AppSignal scope.
2979
+ #
2596
2980
  # _@return_ — Returns the block's return value.
2597
2981
  #
2598
2982
  # SQL query instrumentation
@@ -2621,10 +3005,12 @@ module Appsignal
2621
3005
  name: String,
2622
3006
  title: T.nilable(String),
2623
3007
  body: T.nilable(String),
3008
+ opentelemetry_kind: Symbol,
3009
+ opentelemetry_scope: T.nilable([String, String]),
2624
3010
  block: T.untyped
2625
3011
  ).returns(Object)
2626
3012
  end
2627
- def instrument_sql(name, title = nil, body = nil, &block); end
3013
+ def instrument_sql(name, title = nil, body = nil, opentelemetry_kind: :client, opentelemetry_scope: nil, &block); end
2628
3014
 
2629
3015
  # Convenience method for ignoring instrumentation events in a block of
2630
3016
  # code.
@@ -2665,6 +3051,9 @@ module Appsignal
2665
3051
  sig { returns(String) }
2666
3052
  def message; end
2667
3053
  end
3054
+
3055
+ module Metrics
3056
+ end
2668
3057
  end
2669
3058
 
2670
3059
  # Extensions to Object for AppSignal method instrumentation.