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.rbs CHANGED
@@ -259,6 +259,14 @@ module Appsignal
259
259
  #
260
260
  # _@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.
261
261
  #
262
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
263
+ #
264
+ # _@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`.
265
+ #
266
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
267
+ #
268
+ # _@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.
269
+ #
262
270
  # _@return_ — The value of the given block is returned.
263
271
  # Returns `nil` if there already is a transaction active and no block
264
272
  # was given.
@@ -349,7 +357,14 @@ module Appsignal
349
357
  # ```
350
358
  #
351
359
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
352
- def self.monitor: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
360
+ def self.monitor: (
361
+ action: (String | Symbol | NilClass),
362
+ ?namespace: (String | Symbol)?,
363
+ ?opentelemetry_context: untyped,
364
+ ?opentelemetry_scope: [String, String]?,
365
+ ?opentelemetry_kind: Symbol?,
366
+ ?opentelemetry_relationship: Symbol?
367
+ ) ?{ () -> Object } -> Object?
353
368
 
354
369
  # Instrument a block of code and stop AppSignal.
355
370
  #
@@ -363,10 +378,25 @@ module Appsignal
363
378
  #
364
379
  # _@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.
365
380
  #
381
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
382
+ #
383
+ # _@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`.
384
+ #
385
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
386
+ #
387
+ # _@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.
388
+ #
366
389
  # _@return_ — The value of the given block is returned.
367
390
  #
368
391
  # _@see_ `monitor`
369
- def self.monitor_and_stop: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
392
+ def self.monitor_and_stop: (
393
+ action: (String | Symbol | NilClass),
394
+ ?namespace: (String | Symbol)?,
395
+ ?opentelemetry_context: untyped,
396
+ ?opentelemetry_scope: [String, String]?,
397
+ ?opentelemetry_kind: Symbol?,
398
+ ?opentelemetry_relationship: Symbol?
399
+ ) ?{ () -> Object } -> Object?
370
400
 
371
401
  # Send an error to AppSignal regardless of the context.
372
402
  #
@@ -385,6 +415,14 @@ module Appsignal
385
415
  #
386
416
  # _@param_ `error` — The error to send to AppSignal.
387
417
  #
418
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
419
+ #
420
+ # _@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`.
421
+ #
422
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
423
+ #
424
+ # _@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.
425
+ #
388
426
  # Send an exception
389
427
  # ```ruby
390
428
  # begin
@@ -405,7 +443,13 @@ module Appsignal
405
443
  # ```
406
444
  #
407
445
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
408
- def self.send_error: (Exception error) ?{ (Transaction transaction) -> void } -> void
446
+ def self.send_error: (
447
+ Exception error,
448
+ ?opentelemetry_context: untyped,
449
+ ?opentelemetry_scope: [String, String]?,
450
+ ?opentelemetry_kind: Symbol?,
451
+ ?opentelemetry_relationship: Symbol?
452
+ ) ?{ (Transaction transaction) -> void } -> void
409
453
 
410
454
  # Set an error on the current transaction.
411
455
  #
@@ -477,6 +521,14 @@ module Appsignal
477
521
  #
478
522
  # _@param_ `exception` — The error to add to the current transaction.
479
523
  #
524
+ # _@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.
525
+ #
526
+ # _@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.
527
+ #
528
+ # _@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.
529
+ #
530
+ # _@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.
531
+ #
480
532
  # ```ruby
481
533
  # class SomeController < ApplicationController
482
534
  # def create
@@ -498,7 +550,13 @@ module Appsignal
498
550
  # ```
499
551
  #
500
552
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
501
- def self.report_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
553
+ def self.report_error: (
554
+ Exception exception,
555
+ ?opentelemetry_context: untyped,
556
+ ?opentelemetry_scope: [String, String]?,
557
+ ?opentelemetry_kind: Symbol?,
558
+ ?opentelemetry_relationship: Symbol?
559
+ ) ?{ (Transaction transaction) -> void } -> void
502
560
 
503
561
  # Set a custom action name for the current transaction.
504
562
  #
@@ -691,16 +749,62 @@ module Appsignal
691
749
  # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-parameters.html` — Parameter filtering guide
692
750
  def self.add_params: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
693
751
 
752
+ # Add the request payload to the current transaction.
753
+ #
754
+ # The request payload is the parameters of an incoming request, such as
755
+ # the query string and the request body. In collector mode it maps to its
756
+ # own attribute, separate from the function parameters.
757
+ #
758
+ # Behaves like {#add_params}: merges when called multiple times, and a
759
+ # block takes precedence over the argument.
760
+ #
761
+ # _@param_ `params` — The request payload to add to the transaction.
762
+ #
763
+ # _@see_ `#add_function_parameters`
764
+ def self.add_request_payload: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
765
+
766
+ # Add the function parameters to the current transaction.
767
+ #
768
+ # The function parameters are the arguments a background job or function
769
+ # was called with. In collector mode they map to their own attribute,
770
+ # separate from the request payload.
771
+ #
772
+ # Behaves like {#add_params}: merges when called multiple times, and a
773
+ # block takes precedence over the argument.
774
+ #
775
+ # _@param_ `params` — The function parameters to add to the transaction.
776
+ #
777
+ # _@see_ `#add_request_payload`
778
+ def self.add_function_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
779
+
780
+ # Add the query parameters to the current transaction.
781
+ #
782
+ # The query parameters are the parameters parsed from an incoming
783
+ # request's query string. In collector mode they map to their own
784
+ # attribute, separate from the request payload and the function
785
+ # parameters.
786
+ #
787
+ # Behaves like {#add_params}: merges when called multiple times, and a
788
+ # block takes precedence over the argument.
789
+ #
790
+ # _@param_ `params` — The query parameters to add to the transaction.
791
+ #
792
+ # _@see_ `#add_request_payload`
793
+ def self.add_query_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
794
+
694
795
  # Mark the parameters sample data to be set as an empty value.
695
796
  #
696
- # Use this helper to unset request parameters / background job arguments
697
- # and not report any for this transaction.
797
+ # Use this helper to report no parameters for this transaction, whatever
798
+ # their source.
698
799
  #
699
- # If parameters would normally be added by AppSignal instrumentations of
700
- # libraries, these parameters will not be added to the Transaction.
800
+ # This suppresses every params channel. In collector mode, where the
801
+ # request payload and the function parameters (a background job's
802
+ # arguments) are tracked as separate attributes, it suppresses both, not
803
+ # only the request payload. Parameters that an AppSignal integration would
804
+ # otherwise add are not added.
701
805
  #
702
- # Calling {#add_params} after this helper will add new parameters to the
703
- # transaction.
806
+ # Calling {#add_params}, {#add_request_payload} or
807
+ # {#add_function_parameters} after this helper adds parameters again.
704
808
  #
705
809
  # _@see_ `Transaction#set_empty_params!`
706
810
  #
@@ -778,7 +882,7 @@ module Appsignal
778
882
  # Breadcrumbs can be used to trace what path a user has taken
779
883
  # before encountering an error.
780
884
  #
781
- # Only the last 20 added breadcrumbs will be saved.
885
+ # At most 20 of the added breadcrumbs will be saved.
782
886
  #
783
887
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
784
888
  #
@@ -833,6 +937,10 @@ module Appsignal
833
937
  #
834
938
  # _@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}.
835
939
  #
940
+ # _@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`.
941
+ #
942
+ # _@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.
943
+ #
836
944
  # _@return_ — Returns the block's return value.
837
945
  #
838
946
  # Simple instrumentation
@@ -862,7 +970,9 @@ module Appsignal
862
970
  String name,
863
971
  ?String? title,
864
972
  ?String? body,
865
- ?Integer body_format
973
+ ?Integer body_format,
974
+ ?opentelemetry_kind: Symbol?,
975
+ ?opentelemetry_scope: [String, String]?
866
976
  ) -> Object
867
977
 
868
978
  # Instrumentation helper for SQL queries.
@@ -875,6 +985,10 @@ module Appsignal
875
985
  #
876
986
  # _@param_ `body` — SQL query that's being executed.
877
987
  #
988
+ # _@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.
989
+ #
990
+ # _@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.
991
+ #
878
992
  # _@return_ — Returns the block's return value.
879
993
  #
880
994
  # SQL query instrumentation
@@ -898,7 +1012,13 @@ module Appsignal
898
1012
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
899
1013
  #
900
1014
  # _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
901
- def self.instrument_sql: (String name, ?String? title, ?String? body) -> Object
1015
+ def self.instrument_sql: (
1016
+ String name,
1017
+ ?String? title,
1018
+ ?String? body,
1019
+ ?opentelemetry_kind: Symbol,
1020
+ ?opentelemetry_scope: [String, String]?
1021
+ ) -> Object
902
1022
 
903
1023
  # Convenience method for ignoring instrumentation events in a block of
904
1024
  # code.
@@ -991,6 +1111,36 @@ module Appsignal
991
1111
  # _@return_ — True if valid and active for the current environment.
992
1112
  def active?: () -> bool
993
1113
 
1114
+ # Check if collector mode is configured.
1115
+ #
1116
+ # Returns true when a non-empty `collector_endpoint` is set and the
1117
+ # running Ruby version is at least {MIN_RUBY_VERSION_FOR_COLLECTOR_MODE}.
1118
+ # On older Rubies, `collector_endpoint` is ignored (with a warning) and
1119
+ # the AppSignal agent is used instead.
1120
+ #
1121
+ # This is the *intent* check — it answers "did the user ask for
1122
+ # collector mode, and could we honor it?". It does not say whether the
1123
+ # OpenTelemetry SDK actually booted. See {#collector_mode?} for that.
1124
+ #
1125
+ # Memoised: the result is cached on first call so hot paths avoid
1126
+ # re-running the string-strip predicate, and so the unsupported-Ruby
1127
+ # warning is emitted at most once per `Config` instance.
1128
+ #
1129
+ # _@return_ — True if collector mode is configured.
1130
+ def collector_mode_configured?: () -> bool
1131
+
1132
+ # Check if AppSignal is actively running in collector mode.
1133
+ #
1134
+ # True only if collector mode is {#collector_mode_configured? configured}
1135
+ # *and* `Appsignal::OpenTelemetry.configure` has successfully booted the
1136
+ # SDK in this process. Use this for backend dispatch on hot paths
1137
+ # (metric and log emits): if the OTel boot failed, callers fall back to
1138
+ # the agent backend rather than silently dropping data into no-op
1139
+ # providers.
1140
+ #
1141
+ # _@return_ — True if collector mode is configured and started.
1142
+ def collector_mode?: () -> bool
1143
+
994
1144
  def yml_config_file?: () -> bool
995
1145
 
996
1146
  # Configuration DSL for use in configuration blocks.
@@ -1526,7 +1676,21 @@ module Appsignal
1526
1676
  # transaction.
1527
1677
  #
1528
1678
  # _@param_ `namespace` — Namespace of the to be created transaction.
1529
- def self.create: (String namespace) -> Transaction
1679
+ #
1680
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
1681
+ #
1682
+ # _@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`.
1683
+ #
1684
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
1685
+ #
1686
+ # _@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.
1687
+ def self.create: (
1688
+ String namespace,
1689
+ ?opentelemetry_context: untyped,
1690
+ ?opentelemetry_scope: [String, String]?,
1691
+ ?opentelemetry_kind: Symbol?,
1692
+ ?opentelemetry_relationship: Symbol?
1693
+ ) -> Transaction
1530
1694
 
1531
1695
  # Returns currently active transaction or a {NilTransaction} if none is
1532
1696
  # active.
@@ -1558,6 +1722,49 @@ module Appsignal
1558
1722
  # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
1559
1723
  def add_params: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1560
1724
 
1725
+ # Add the request payload to the transaction.
1726
+ #
1727
+ # These are the parameters of an incoming request, such as the query string
1728
+ # and the request body. In collector mode they map to the request payload
1729
+ # attribute. In agent mode they are the transaction's params.
1730
+ #
1731
+ # Behaves like {#add_params}: merges when called multiple times, and a
1732
+ # block takes precedence over the argument.
1733
+ #
1734
+ # _@param_ `given_params` — The parameters to add to the transaction.
1735
+ #
1736
+ # _@see_ `#add_function_parameters`
1737
+ def add_request_payload: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1738
+
1739
+ # Add the function parameters to the transaction.
1740
+ #
1741
+ # These are the arguments a background job or function was called with. In
1742
+ # collector mode they map to the function parameters attribute. In agent
1743
+ # mode they are the transaction's params.
1744
+ #
1745
+ # Behaves like {#add_params}: merges when called multiple times, and a
1746
+ # block takes precedence over the argument.
1747
+ #
1748
+ # _@param_ `given_params` — The parameters to add to the transaction.
1749
+ #
1750
+ # _@see_ `#add_request_payload`
1751
+ def add_function_parameters: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1752
+
1753
+ # Add the query parameters to the transaction.
1754
+ #
1755
+ # These are the parameters parsed from an incoming request's query string.
1756
+ # In collector mode they map to their own attribute, separate from the
1757
+ # request payload and the function parameters. In agent mode they are the
1758
+ # transaction's params.
1759
+ #
1760
+ # Behaves like {#add_params}: merges when called multiple times, and a
1761
+ # block takes precedence over the argument.
1762
+ #
1763
+ # _@param_ `given_params` — The parameters to add to the transaction.
1764
+ #
1765
+ # _@see_ `#add_request_payload`
1766
+ def add_query_parameters: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1767
+
1561
1768
  # Add tags to the transaction.
1562
1769
  #
1563
1770
  # When this method is called multiple times, it will merge the tags.
@@ -1658,6 +1865,35 @@ module Appsignal
1658
1865
  #
1659
1866
  # _@param_ `start` — Queue start time in milliseconds.
1660
1867
  def set_queue_start: (Integer start) -> void
1868
+
1869
+ # Add OpenTelemetry attributes to the span AppSignal is currently
1870
+ # recording.
1871
+ #
1872
+ # In collector mode, AppSignal records a transaction as an OpenTelemetry
1873
+ # span, and every instrumented event as a child span. This adds attributes
1874
+ # to whichever of those spans is open right now: the innermost event
1875
+ # started by {Appsignal::Helpers::Instrumentation#instrument}, or the
1876
+ # transaction's own span when no event is open.
1877
+ #
1878
+ # Use this to describe what is being instrumented in OpenTelemetry's own
1879
+ # terms, following the OpenTelemetry semantic conventions where they apply.
1880
+ # Attributes have no equivalent outside collector mode, so this does
1881
+ # nothing when collector mode is not active.
1882
+ #
1883
+ # _@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.
1884
+ #
1885
+ # Describing a database query
1886
+ # ```ruby
1887
+ # Appsignal.instrument("query.my_database") do
1888
+ # Appsignal::Transaction.current.add_opentelemetry_attributes(
1889
+ # "db.system.name" => "mysql"
1890
+ # )
1891
+ # run_the_query
1892
+ # end
1893
+ # ```
1894
+ #
1895
+ # _@see_ `https://opentelemetry.io/docs/specs/semconv/` — OpenTelemetry semantic conventions
1896
+ def add_opentelemetry_attributes: (?::Hash[String, Object]? attributes) -> void
1661
1897
  end
1662
1898
 
1663
1899
  # Custom markers are used on AppSignal.com to indicate events in an
@@ -1799,6 +2035,14 @@ module Appsignal
1799
2035
  #
1800
2036
  # _@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.
1801
2037
  #
2038
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2039
+ #
2040
+ # _@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`.
2041
+ #
2042
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2043
+ #
2044
+ # _@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.
2045
+ #
1802
2046
  # _@return_ — The value of the given block is returned.
1803
2047
  # Returns `nil` if there already is a transaction active and no block
1804
2048
  # was given.
@@ -1889,7 +2133,14 @@ module Appsignal
1889
2133
  # ```
1890
2134
  #
1891
2135
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
1892
- def monitor: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
2136
+ def monitor: (
2137
+ action: (String | Symbol | NilClass),
2138
+ ?namespace: (String | Symbol)?,
2139
+ ?opentelemetry_context: untyped,
2140
+ ?opentelemetry_scope: [String, String]?,
2141
+ ?opentelemetry_kind: Symbol?,
2142
+ ?opentelemetry_relationship: Symbol?
2143
+ ) ?{ () -> Object } -> Object?
1893
2144
 
1894
2145
  # Instrument a block of code and stop AppSignal.
1895
2146
  #
@@ -1903,10 +2154,25 @@ module Appsignal
1903
2154
  #
1904
2155
  # _@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.
1905
2156
  #
2157
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2158
+ #
2159
+ # _@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`.
2160
+ #
2161
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2162
+ #
2163
+ # _@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.
2164
+ #
1906
2165
  # _@return_ — The value of the given block is returned.
1907
2166
  #
1908
2167
  # _@see_ `monitor`
1909
- def monitor_and_stop: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
2168
+ def monitor_and_stop: (
2169
+ action: (String | Symbol | NilClass),
2170
+ ?namespace: (String | Symbol)?,
2171
+ ?opentelemetry_context: untyped,
2172
+ ?opentelemetry_scope: [String, String]?,
2173
+ ?opentelemetry_kind: Symbol?,
2174
+ ?opentelemetry_relationship: Symbol?
2175
+ ) ?{ () -> Object } -> Object?
1910
2176
 
1911
2177
  # Send an error to AppSignal regardless of the context.
1912
2178
  #
@@ -1925,6 +2191,14 @@ module Appsignal
1925
2191
  #
1926
2192
  # _@param_ `error` — The error to send to AppSignal.
1927
2193
  #
2194
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2195
+ #
2196
+ # _@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`.
2197
+ #
2198
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2199
+ #
2200
+ # _@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.
2201
+ #
1928
2202
  # Send an exception
1929
2203
  # ```ruby
1930
2204
  # begin
@@ -1945,7 +2219,13 @@ module Appsignal
1945
2219
  # ```
1946
2220
  #
1947
2221
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
1948
- def send_error: (Exception error) ?{ (Transaction transaction) -> void } -> void
2222
+ def send_error: (
2223
+ Exception error,
2224
+ ?opentelemetry_context: untyped,
2225
+ ?opentelemetry_scope: [String, String]?,
2226
+ ?opentelemetry_kind: Symbol?,
2227
+ ?opentelemetry_relationship: Symbol?
2228
+ ) ?{ (Transaction transaction) -> void } -> void
1949
2229
 
1950
2230
  # Set an error on the current transaction.
1951
2231
  #
@@ -2017,6 +2297,14 @@ module Appsignal
2017
2297
  #
2018
2298
  # _@param_ `exception` — The error to add to the current transaction.
2019
2299
  #
2300
+ # _@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.
2301
+ #
2302
+ # _@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.
2303
+ #
2304
+ # _@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.
2305
+ #
2306
+ # _@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.
2307
+ #
2020
2308
  # ```ruby
2021
2309
  # class SomeController < ApplicationController
2022
2310
  # def create
@@ -2038,7 +2326,13 @@ module Appsignal
2038
2326
  # ```
2039
2327
  #
2040
2328
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
2041
- def report_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
2329
+ def report_error: (
2330
+ Exception exception,
2331
+ ?opentelemetry_context: untyped,
2332
+ ?opentelemetry_scope: [String, String]?,
2333
+ ?opentelemetry_kind: Symbol?,
2334
+ ?opentelemetry_relationship: Symbol?
2335
+ ) ?{ (Transaction transaction) -> void } -> void
2042
2336
 
2043
2337
  # Set a custom action name for the current transaction.
2044
2338
  #
@@ -2231,16 +2525,62 @@ module Appsignal
2231
2525
  # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-parameters.html` — Parameter filtering guide
2232
2526
  def add_params: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2233
2527
 
2528
+ # Add the request payload to the current transaction.
2529
+ #
2530
+ # The request payload is the parameters of an incoming request, such as
2531
+ # the query string and the request body. In collector mode it maps to its
2532
+ # own attribute, separate from the function parameters.
2533
+ #
2534
+ # Behaves like {#add_params}: merges when called multiple times, and a
2535
+ # block takes precedence over the argument.
2536
+ #
2537
+ # _@param_ `params` — The request payload to add to the transaction.
2538
+ #
2539
+ # _@see_ `#add_function_parameters`
2540
+ def add_request_payload: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2541
+
2542
+ # Add the function parameters to the current transaction.
2543
+ #
2544
+ # The function parameters are the arguments a background job or function
2545
+ # was called with. In collector mode they map to their own attribute,
2546
+ # separate from the request payload.
2547
+ #
2548
+ # Behaves like {#add_params}: merges when called multiple times, and a
2549
+ # block takes precedence over the argument.
2550
+ #
2551
+ # _@param_ `params` — The function parameters to add to the transaction.
2552
+ #
2553
+ # _@see_ `#add_request_payload`
2554
+ def add_function_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2555
+
2556
+ # Add the query parameters to the current transaction.
2557
+ #
2558
+ # The query parameters are the parameters parsed from an incoming
2559
+ # request's query string. In collector mode they map to their own
2560
+ # attribute, separate from the request payload and the function
2561
+ # parameters.
2562
+ #
2563
+ # Behaves like {#add_params}: merges when called multiple times, and a
2564
+ # block takes precedence over the argument.
2565
+ #
2566
+ # _@param_ `params` — The query parameters to add to the transaction.
2567
+ #
2568
+ # _@see_ `#add_request_payload`
2569
+ def add_query_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2570
+
2234
2571
  # Mark the parameters sample data to be set as an empty value.
2235
2572
  #
2236
- # Use this helper to unset request parameters / background job arguments
2237
- # and not report any for this transaction.
2573
+ # Use this helper to report no parameters for this transaction, whatever
2574
+ # their source.
2238
2575
  #
2239
- # If parameters would normally be added by AppSignal instrumentations of
2240
- # libraries, these parameters will not be added to the Transaction.
2576
+ # This suppresses every params channel. In collector mode, where the
2577
+ # request payload and the function parameters (a background job's
2578
+ # arguments) are tracked as separate attributes, it suppresses both, not
2579
+ # only the request payload. Parameters that an AppSignal integration would
2580
+ # otherwise add are not added.
2241
2581
  #
2242
- # Calling {#add_params} after this helper will add new parameters to the
2243
- # transaction.
2582
+ # Calling {#add_params}, {#add_request_payload} or
2583
+ # {#add_function_parameters} after this helper adds parameters again.
2244
2584
  #
2245
2585
  # _@see_ `Transaction#set_empty_params!`
2246
2586
  #
@@ -2318,7 +2658,7 @@ module Appsignal
2318
2658
  # Breadcrumbs can be used to trace what path a user has taken
2319
2659
  # before encountering an error.
2320
2660
  #
2321
- # Only the last 20 added breadcrumbs will be saved.
2661
+ # At most 20 of the added breadcrumbs will be saved.
2322
2662
  #
2323
2663
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
2324
2664
  #
@@ -2373,6 +2713,10 @@ module Appsignal
2373
2713
  #
2374
2714
  # _@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}.
2375
2715
  #
2716
+ # _@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`.
2717
+ #
2718
+ # _@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.
2719
+ #
2376
2720
  # _@return_ — Returns the block's return value.
2377
2721
  #
2378
2722
  # Simple instrumentation
@@ -2402,7 +2746,9 @@ module Appsignal
2402
2746
  String name,
2403
2747
  ?String? title,
2404
2748
  ?String? body,
2405
- ?Integer body_format
2749
+ ?Integer body_format,
2750
+ ?opentelemetry_kind: Symbol?,
2751
+ ?opentelemetry_scope: [String, String]?
2406
2752
  ) -> Object
2407
2753
 
2408
2754
  # Instrumentation helper for SQL queries.
@@ -2415,6 +2761,10 @@ module Appsignal
2415
2761
  #
2416
2762
  # _@param_ `body` — SQL query that's being executed.
2417
2763
  #
2764
+ # _@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.
2765
+ #
2766
+ # _@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.
2767
+ #
2418
2768
  # _@return_ — Returns the block's return value.
2419
2769
  #
2420
2770
  # SQL query instrumentation
@@ -2438,7 +2788,13 @@ module Appsignal
2438
2788
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
2439
2789
  #
2440
2790
  # _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
2441
- def instrument_sql: (String name, ?String? title, ?String? body) -> Object
2791
+ def instrument_sql: (
2792
+ String name,
2793
+ ?String? title,
2794
+ ?String? body,
2795
+ ?opentelemetry_kind: Symbol,
2796
+ ?opentelemetry_scope: [String, String]?
2797
+ ) -> Object
2442
2798
 
2443
2799
  # Convenience method for ignoring instrumentation events in a block of
2444
2800
  # code.
@@ -2477,6 +2833,9 @@ module Appsignal
2477
2833
  class NotStartedError < Appsignal::InternalError
2478
2834
  def message: () -> String
2479
2835
  end
2836
+
2837
+ module Metrics
2838
+ end
2480
2839
  end
2481
2840
 
2482
2841
  # Extensions to Object for AppSignal method instrumentation.