appsignal 4.10.4-java → 5.0.0-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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +108 -0
  3. data/Rakefile +195 -4
  4. data/appsignal.gemspec +8 -0
  5. data/build_matrix.yml +12 -0
  6. data/ext/appsignal_extension.c +14 -0
  7. data/lib/appsignal/backends.rb +55 -0
  8. data/lib/appsignal/cli/diagnose.rb +2 -10
  9. data/lib/appsignal/config.rb +377 -13
  10. data/lib/appsignal/demo.rb +12 -10
  11. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +34 -22
  12. data/lib/appsignal/event_formatter/active_job/perform_formatter.rb +35 -0
  13. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +19 -0
  14. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +27 -0
  15. data/lib/appsignal/event_formatter/recorded_elsewhere.rb +17 -0
  16. data/lib/appsignal/event_formatter/rom/sql_formatter.rb +24 -0
  17. data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +5 -0
  18. data/lib/appsignal/event_formatter/view_component/render_formatter.rb +21 -10
  19. data/lib/appsignal/event_formatter.rb +78 -0
  20. data/lib/appsignal/extension.rb +4 -0
  21. data/lib/appsignal/helpers/instrumentation.rb +324 -20
  22. data/lib/appsignal/helpers/metrics.rb +3 -24
  23. data/lib/appsignal/hooks/action_cable.rb +26 -8
  24. data/lib/appsignal/hooks/active_job.rb +184 -47
  25. data/lib/appsignal/hooks/at_exit.rb +4 -1
  26. data/lib/appsignal/hooks/excon.rb +20 -0
  27. data/lib/appsignal/hooks/faraday.rb +16 -0
  28. data/lib/appsignal/hooks/http.rb +5 -0
  29. data/lib/appsignal/hooks/resque.rb +1 -1
  30. data/lib/appsignal/hooks/sequel.rb +32 -2
  31. data/lib/appsignal/hooks/shoryuken.rb +3 -3
  32. data/lib/appsignal/hooks/sidekiq.rb +1 -1
  33. data/lib/appsignal/integrations/action_cable.rb +5 -2
  34. data/lib/appsignal/integrations/active_support_notifications.rb +59 -19
  35. data/lib/appsignal/integrations/data_mapper.rb +14 -2
  36. data/lib/appsignal/integrations/delayed_job_plugin.rb +81 -8
  37. data/lib/appsignal/integrations/dry_monitor.rb +39 -15
  38. data/lib/appsignal/integrations/excon/appsignal_middleware.rb +21 -0
  39. data/lib/appsignal/integrations/excon.rb +52 -15
  40. data/lib/appsignal/integrations/faraday.rb +47 -12
  41. data/lib/appsignal/integrations/http.rb +43 -1
  42. data/lib/appsignal/integrations/mongo_ruby_driver.rb +73 -4
  43. data/lib/appsignal/integrations/net_http.rb +31 -2
  44. data/lib/appsignal/integrations/puma.rb +4 -1
  45. data/lib/appsignal/integrations/que.rb +256 -37
  46. data/lib/appsignal/integrations/railtie.rb +4 -1
  47. data/lib/appsignal/integrations/rake.rb +9 -3
  48. data/lib/appsignal/integrations/redis.rb +22 -1
  49. data/lib/appsignal/integrations/redis_client.rb +22 -1
  50. data/lib/appsignal/integrations/resque.rb +81 -11
  51. data/lib/appsignal/integrations/shoryuken.rb +159 -12
  52. data/lib/appsignal/integrations/sidekiq.rb +94 -16
  53. data/lib/appsignal/integrations/webmachine.rb +56 -5
  54. data/lib/appsignal/loaders/padrino.rb +2 -1
  55. data/lib/appsignal/logger/extension_backend.rb +24 -0
  56. data/lib/appsignal/logger/opentelemetry_backend.rb +66 -0
  57. data/lib/appsignal/logger.rb +13 -9
  58. data/lib/appsignal/metrics/extension_backend.rb +47 -0
  59. data/lib/appsignal/metrics/opentelemetry_backend.rb +89 -0
  60. data/lib/appsignal/opentelemetry/attributes.rb +31 -0
  61. data/lib/appsignal/opentelemetry/dependencies.rb +35 -0
  62. data/lib/appsignal/opentelemetry/error_type.rb +37 -0
  63. data/lib/appsignal/opentelemetry/http_client_request.rb +83 -0
  64. data/lib/appsignal/opentelemetry/http_method.rb +59 -0
  65. data/lib/appsignal/opentelemetry/http_response.rb +30 -0
  66. data/lib/appsignal/opentelemetry/http_server_request.rb +79 -0
  67. data/lib/appsignal/opentelemetry/messaging.rb +82 -0
  68. data/lib/appsignal/opentelemetry/proxied_exporter.rb +83 -0
  69. data/lib/appsignal/opentelemetry/rendering.rb +29 -0
  70. data/lib/appsignal/opentelemetry/sql_db_system.rb +89 -0
  71. data/lib/appsignal/opentelemetry.rb +495 -0
  72. data/lib/appsignal/rack/abstract_middleware.rb +66 -4
  73. data/lib/appsignal/rack/body_wrapper.rb +18 -5
  74. data/lib/appsignal/rack/event_handler.rb +44 -4
  75. data/lib/appsignal/rack/grape_middleware.rb +1 -0
  76. data/lib/appsignal/rack/hanami_middleware.rb +2 -1
  77. data/lib/appsignal/rack/instrumentation_middleware.rb +1 -0
  78. data/lib/appsignal/rack/rails_instrumentation.rb +1 -0
  79. data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -0
  80. data/lib/appsignal/rack.rb +68 -12
  81. data/lib/appsignal/sample_data.rb +4 -0
  82. data/lib/appsignal/transaction/base_backend.rb +128 -0
  83. data/lib/appsignal/transaction/extension_backend.rb +229 -0
  84. data/lib/appsignal/transaction/opentelemetry_backend.rb +847 -0
  85. data/lib/appsignal/transaction.rb +714 -164
  86. data/lib/appsignal/utils/request_headers.rb +78 -0
  87. data/lib/appsignal/utils/stdout_and_logger_message.rb +9 -0
  88. data/lib/appsignal/utils.rb +1 -0
  89. data/lib/appsignal/version.rb +1 -1
  90. data/lib/appsignal.rb +10 -0
  91. data/sig/appsignal.rbi +630 -37
  92. data/sig/appsignal.rbs +582 -27
  93. metadata +25 -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
  #
@@ -768,17 +872,92 @@ module Appsignal
768
872
  # # { "PATH_INFO" => "/some-path", "HTTP_USER_AGENT" => "Firefox" }
769
873
  # ```
770
874
  #
875
+ # _@deprecated_ — Use {#add_request_headers} for request headers and
876
+ # {#add_request_environment} for the values a Rack environment holds
877
+ # that are not request headers. This method takes both kinds at once,
878
+ # so it has to work out which of them each value is.
879
+ #
880
+ # _@see_ `#add_request_headers`
881
+ #
882
+ # _@see_ `#add_request_environment`
883
+ #
771
884
  # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
772
885
  #
773
886
  # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
774
887
  def self.add_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
775
888
 
889
+ # Add request headers to the current transaction.
890
+ #
891
+ # Request headers are automatically added by most of our integrations. It
892
+ # should not be necessary to call this method unless you want to also
893
+ # report different request headers.
894
+ #
895
+ # Name each header the way OpenTelemetry names it, in lowercase and with
896
+ # dashes. In agent mode the names are converted to the Rack spellings the
897
+ # environment uses, so `accept` is reported as `HTTP_ACCEPT`.
898
+ #
899
+ # To filter request headers, see our request header filtering guide.
900
+ #
901
+ # When both the `headers` argument and a block is given to this method,
902
+ # the block is leading and the argument will _not_ be used.
903
+ #
904
+ # _@param_ `headers` — The request headers to add to the transaction.
905
+ #
906
+ # Add request headers
907
+ # ```ruby
908
+ # Appsignal.add_request_headers("accept" => "text/html")
909
+ # # The request headers will include:
910
+ # # { "accept" => "text/html" }
911
+ # ```
912
+ #
913
+ # Calling `add_request_headers` multiple times merges the values
914
+ # ```ruby
915
+ # Appsignal.add_request_headers("accept" => "text/html")
916
+ # Appsignal.add_request_headers("user-agent" => "Firefox")
917
+ # # The request headers will include:
918
+ # # { "accept" => "text/html", "user-agent" => "Firefox" }
919
+ # ```
920
+ #
921
+ # _@see_ `#add_request_environment`
922
+ #
923
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
924
+ #
925
+ # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
926
+ def self.add_request_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
927
+
928
+ # Add values from the request environment to the current transaction.
929
+ #
930
+ # These are the values a Rack environment holds that are not request
931
+ # headers, such as `REMOTE_ADDR` and `QUERY_STRING`. Name each one the
932
+ # way Rack names it. Use {#add_request_headers} for the request headers.
933
+ #
934
+ # The request environment is automatically added by most of our
935
+ # integrations. It should not be necessary to call this method unless you
936
+ # want to also report different values.
937
+ #
938
+ # When both the `environment` argument and a block is given to this
939
+ # method, the block is leading and the argument will _not_ be used.
940
+ #
941
+ # _@param_ `environment` — The request environment values to add to the transaction.
942
+ #
943
+ # Add request environment values
944
+ # ```ruby
945
+ # Appsignal.add_request_environment("REMOTE_ADDR" => "127.0.0.1")
946
+ # # The request environment will include:
947
+ # # { "REMOTE_ADDR" => "127.0.0.1" }
948
+ # ```
949
+ #
950
+ # _@see_ `#add_request_headers`
951
+ #
952
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
953
+ def self.add_request_environment: (?::Hash[String, Object]? environment) ?{ () -> ::Hash[String, Object] } -> void
954
+
776
955
  # Add breadcrumbs to the transaction.
777
956
  #
778
957
  # Breadcrumbs can be used to trace what path a user has taken
779
958
  # before encountering an error.
780
959
  #
781
- # Only the last 20 added breadcrumbs will be saved.
960
+ # At most 20 of the added breadcrumbs will be saved.
782
961
  #
783
962
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
784
963
  #
@@ -833,6 +1012,10 @@ module Appsignal
833
1012
  #
834
1013
  # _@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
1014
  #
1015
+ # _@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`.
1016
+ #
1017
+ # _@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.
1018
+ #
836
1019
  # _@return_ — Returns the block's return value.
837
1020
  #
838
1021
  # Simple instrumentation
@@ -862,7 +1045,9 @@ module Appsignal
862
1045
  String name,
863
1046
  ?String? title,
864
1047
  ?String? body,
865
- ?Integer body_format
1048
+ ?Integer body_format,
1049
+ ?opentelemetry_kind: Symbol?,
1050
+ ?opentelemetry_scope: [String, String]?
866
1051
  ) -> Object
867
1052
 
868
1053
  # Instrumentation helper for SQL queries.
@@ -875,6 +1060,10 @@ module Appsignal
875
1060
  #
876
1061
  # _@param_ `body` — SQL query that's being executed.
877
1062
  #
1063
+ # _@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.
1064
+ #
1065
+ # _@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.
1066
+ #
878
1067
  # _@return_ — Returns the block's return value.
879
1068
  #
880
1069
  # SQL query instrumentation
@@ -898,7 +1087,13 @@ module Appsignal
898
1087
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
899
1088
  #
900
1089
  # _@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
1090
+ def self.instrument_sql: (
1091
+ String name,
1092
+ ?String? title,
1093
+ ?String? body,
1094
+ ?opentelemetry_kind: Symbol,
1095
+ ?opentelemetry_scope: [String, String]?
1096
+ ) -> Object
902
1097
 
903
1098
  # Convenience method for ignoring instrumentation events in a block of
904
1099
  # code.
@@ -991,6 +1186,36 @@ module Appsignal
991
1186
  # _@return_ — True if valid and active for the current environment.
992
1187
  def active?: () -> bool
993
1188
 
1189
+ # Check if collector mode is configured.
1190
+ #
1191
+ # Returns true when a non-empty `collector_endpoint` is set and the
1192
+ # running Ruby version is at least {MIN_RUBY_VERSION_FOR_COLLECTOR_MODE}.
1193
+ # On older Rubies, `collector_endpoint` is ignored (with a warning) and
1194
+ # the AppSignal agent is used instead.
1195
+ #
1196
+ # This is the *intent* check — it answers "did the user ask for
1197
+ # collector mode, and could we honor it?". It does not say whether the
1198
+ # OpenTelemetry SDK actually booted. See {#collector_mode?} for that.
1199
+ #
1200
+ # Memoised: the result is cached on first call so hot paths avoid
1201
+ # re-running the string-strip predicate, and so the unsupported-Ruby
1202
+ # warning is emitted at most once per `Config` instance.
1203
+ #
1204
+ # _@return_ — True if collector mode is configured.
1205
+ def collector_mode_configured?: () -> bool
1206
+
1207
+ # Check if AppSignal is actively running in collector mode.
1208
+ #
1209
+ # True only if collector mode is {#collector_mode_configured? configured}
1210
+ # *and* `Appsignal::OpenTelemetry.configure` has successfully booted the
1211
+ # SDK in this process. Use this for backend dispatch on hot paths
1212
+ # (metric and log emits): if the OTel boot failed, callers fall back to
1213
+ # the agent backend rather than silently dropping data into no-op
1214
+ # providers.
1215
+ #
1216
+ # _@return_ — True if collector mode is configured and started.
1217
+ def collector_mode?: () -> bool
1218
+
994
1219
  def yml_config_file?: () -> bool
995
1220
 
996
1221
  # Configuration DSL for use in configuration blocks.
@@ -1216,6 +1441,14 @@ module Appsignal
1216
1441
  # _@return_ — Ignore traces by namespaces
1217
1442
  attr_accessor ignore_namespaces: ::Array[String]
1218
1443
 
1444
+ # _@return_ — Rack environment keys to report in collector
1445
+ # mode, named the way Rack names them
1446
+ attr_accessor keep_request_environment: ::Array[String]
1447
+
1448
+ # _@return_ — HTTP request headers to report in collector
1449
+ # mode, named the way OpenTelemetry names them
1450
+ attr_accessor keep_request_headers: ::Array[String]
1451
+
1219
1452
  # _@return_ — HTTP request headers to include in error reports
1220
1453
  attr_accessor request_headers: ::Array[String]
1221
1454
 
@@ -1526,7 +1759,21 @@ module Appsignal
1526
1759
  # transaction.
1527
1760
  #
1528
1761
  # _@param_ `namespace` — Namespace of the to be created transaction.
1529
- def self.create: (String namespace) -> Transaction
1762
+ #
1763
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
1764
+ #
1765
+ # _@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`.
1766
+ #
1767
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
1768
+ #
1769
+ # _@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.
1770
+ def self.create: (
1771
+ String namespace,
1772
+ ?opentelemetry_context: untyped,
1773
+ ?opentelemetry_scope: [String, String]?,
1774
+ ?opentelemetry_kind: Symbol?,
1775
+ ?opentelemetry_relationship: Symbol?
1776
+ ) -> Transaction
1530
1777
 
1531
1778
  # Returns currently active transaction or a {NilTransaction} if none is
1532
1779
  # active.
@@ -1558,6 +1805,49 @@ module Appsignal
1558
1805
  # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
1559
1806
  def add_params: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1560
1807
 
1808
+ # Add the request payload to the transaction.
1809
+ #
1810
+ # These are the parameters of an incoming request, such as the query string
1811
+ # and the request body. In collector mode they map to the request payload
1812
+ # attribute. In agent mode they are the transaction's params.
1813
+ #
1814
+ # Behaves like {#add_params}: merges when called multiple times, and a
1815
+ # block takes precedence over the argument.
1816
+ #
1817
+ # _@param_ `given_params` — The parameters to add to the transaction.
1818
+ #
1819
+ # _@see_ `#add_function_parameters`
1820
+ def add_request_payload: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1821
+
1822
+ # Add the function parameters to the transaction.
1823
+ #
1824
+ # These are the arguments a background job or function was called with. In
1825
+ # collector mode they map to the function parameters attribute. In agent
1826
+ # mode they are the transaction's params.
1827
+ #
1828
+ # Behaves like {#add_params}: merges when called multiple times, and a
1829
+ # block takes precedence over the argument.
1830
+ #
1831
+ # _@param_ `given_params` — The parameters to add to the transaction.
1832
+ #
1833
+ # _@see_ `#add_request_payload`
1834
+ def add_function_parameters: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1835
+
1836
+ # Add the query parameters to the transaction.
1837
+ #
1838
+ # These are the parameters parsed from an incoming request's query string.
1839
+ # In collector mode they map to their own attribute, separate from the
1840
+ # request payload and the function parameters. In agent mode they are the
1841
+ # transaction's params.
1842
+ #
1843
+ # Behaves like {#add_params}: merges when called multiple times, and a
1844
+ # block takes precedence over the argument.
1845
+ #
1846
+ # _@param_ `given_params` — The parameters to add to the transaction.
1847
+ #
1848
+ # _@see_ `#add_request_payload`
1849
+ def add_query_parameters: (?(::Hash[String, Object] | ::Array[Object])? given_params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
1850
+
1561
1851
  # Add tags to the transaction.
1562
1852
  #
1563
1853
  # When this method is called multiple times, it will merge the tags.
@@ -1587,11 +1877,49 @@ module Appsignal
1587
1877
  #
1588
1878
  # _@param_ `given_headers` — A hash containing headers.
1589
1879
  #
1880
+ # _@deprecated_ — Use {#add_request_headers} for request headers and
1881
+ # {#add_request_environment} for the values a Rack environment holds that
1882
+ # are not request headers. This method takes both kinds at once, so it
1883
+ # has to work out which of them each value is.
1884
+ #
1590
1885
  # _@see_ `Helpers::Instrumentation#add_headers`
1591
1886
  #
1592
1887
  # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
1593
1888
  def add_headers: (?::Hash[String, Object]? given_headers) ?{ () -> ::Hash[String, Object] } -> void
1594
1889
 
1890
+ # Add request headers to the transaction.
1891
+ #
1892
+ # Name each header the way OpenTelemetry names it, in lowercase and with
1893
+ # dashes, such as `accept` and `content-length`. In agent mode the names
1894
+ # are converted to the Rack spellings the environment uses, such as
1895
+ # `HTTP_ACCEPT`.
1896
+ #
1897
+ # Behaves like {#add_headers}: merges when called multiple times, and a
1898
+ # block takes precedence over the argument.
1899
+ #
1900
+ # _@param_ `given_headers` — A hash containing request headers.
1901
+ #
1902
+ # _@see_ `#add_request_environment`
1903
+ #
1904
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
1905
+ def add_request_headers: (?::Hash[String, Object]? given_headers) ?{ () -> ::Hash[String, Object] } -> void
1906
+
1907
+ # Add values from the request environment to the transaction.
1908
+ #
1909
+ # These are the values a Rack environment holds that are not request
1910
+ # headers, such as `REMOTE_ADDR` and `QUERY_STRING`. Name each one the way
1911
+ # Rack names it. Use {#add_request_headers} for the request headers.
1912
+ #
1913
+ # Behaves like {#add_headers}: merges when called multiple times, and a
1914
+ # block takes precedence over the argument.
1915
+ #
1916
+ # _@param_ `given_environment` — A hash containing request environment values.
1917
+ #
1918
+ # _@see_ `#add_request_headers`
1919
+ #
1920
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
1921
+ def add_request_environment: (?::Hash[String, Object]? given_environment) ?{ () -> ::Hash[String, Object] } -> void
1922
+
1595
1923
  # Add custom data to the transaction.
1596
1924
  #
1597
1925
  # _@param_ `data` — Custom data to add to the transaction.
@@ -1658,6 +1986,35 @@ module Appsignal
1658
1986
  #
1659
1987
  # _@param_ `start` — Queue start time in milliseconds.
1660
1988
  def set_queue_start: (Integer start) -> void
1989
+
1990
+ # Add OpenTelemetry attributes to the span AppSignal is currently
1991
+ # recording.
1992
+ #
1993
+ # In collector mode, AppSignal records a transaction as an OpenTelemetry
1994
+ # span, and every instrumented event as a child span. This adds attributes
1995
+ # to whichever of those spans is open right now: the innermost event
1996
+ # started by {Appsignal::Helpers::Instrumentation#instrument}, or the
1997
+ # transaction's own span when no event is open.
1998
+ #
1999
+ # Use this to describe what is being instrumented in OpenTelemetry's own
2000
+ # terms, following the OpenTelemetry semantic conventions where they apply.
2001
+ # Attributes have no equivalent outside collector mode, so this does
2002
+ # nothing when collector mode is not active.
2003
+ #
2004
+ # _@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.
2005
+ #
2006
+ # Describing a database query
2007
+ # ```ruby
2008
+ # Appsignal.instrument("query.my_database") do
2009
+ # Appsignal::Transaction.current.add_opentelemetry_attributes(
2010
+ # "db.system.name" => "mysql"
2011
+ # )
2012
+ # run_the_query
2013
+ # end
2014
+ # ```
2015
+ #
2016
+ # _@see_ `https://opentelemetry.io/docs/specs/semconv/` — OpenTelemetry semantic conventions
2017
+ def add_opentelemetry_attributes: (?::Hash[String, Object]? attributes) -> void
1661
2018
  end
1662
2019
 
1663
2020
  # Custom markers are used on AppSignal.com to indicate events in an
@@ -1799,6 +2156,14 @@ module Appsignal
1799
2156
  #
1800
2157
  # _@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
2158
  #
2159
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2160
+ #
2161
+ # _@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`.
2162
+ #
2163
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2164
+ #
2165
+ # _@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.
2166
+ #
1802
2167
  # _@return_ — The value of the given block is returned.
1803
2168
  # Returns `nil` if there already is a transaction active and no block
1804
2169
  # was given.
@@ -1889,7 +2254,14 @@ module Appsignal
1889
2254
  # ```
1890
2255
  #
1891
2256
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/background-jobs.html` — Monitor guide
1892
- def monitor: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
2257
+ def monitor: (
2258
+ action: (String | Symbol | NilClass),
2259
+ ?namespace: (String | Symbol)?,
2260
+ ?opentelemetry_context: untyped,
2261
+ ?opentelemetry_scope: [String, String]?,
2262
+ ?opentelemetry_kind: Symbol?,
2263
+ ?opentelemetry_relationship: Symbol?
2264
+ ) ?{ () -> Object } -> Object?
1893
2265
 
1894
2266
  # Instrument a block of code and stop AppSignal.
1895
2267
  #
@@ -1903,10 +2275,25 @@ module Appsignal
1903
2275
  #
1904
2276
  # _@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
2277
  #
2278
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2279
+ #
2280
+ # _@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`.
2281
+ #
2282
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2283
+ #
2284
+ # _@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.
2285
+ #
1906
2286
  # _@return_ — The value of the given block is returned.
1907
2287
  #
1908
2288
  # _@see_ `monitor`
1909
- def monitor_and_stop: (action: (String | Symbol | NilClass), ?namespace: (String | Symbol)?) ?{ () -> Object } -> Object?
2289
+ def monitor_and_stop: (
2290
+ action: (String | Symbol | NilClass),
2291
+ ?namespace: (String | Symbol)?,
2292
+ ?opentelemetry_context: untyped,
2293
+ ?opentelemetry_scope: [String, String]?,
2294
+ ?opentelemetry_kind: Symbol?,
2295
+ ?opentelemetry_relationship: Symbol?
2296
+ ) ?{ () -> Object } -> Object?
1910
2297
 
1911
2298
  # Send an error to AppSignal regardless of the context.
1912
2299
  #
@@ -1925,6 +2312,14 @@ module Appsignal
1925
2312
  #
1926
2313
  # _@param_ `error` — The error to send to AppSignal.
1927
2314
  #
2315
+ # _@param_ `opentelemetry_kind` — In collector mode, the OpenTelemetry span kind: one of `:server`, `:consumer`, `:producer` or `:internal`. Defaults to `:server`.
2316
+ #
2317
+ # _@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`.
2318
+ #
2319
+ # _@param_ `opentelemetry_context` — In collector mode, an incoming OpenTelemetry trace context to relate this transaction's span to.
2320
+ #
2321
+ # _@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.
2322
+ #
1928
2323
  # Send an exception
1929
2324
  # ```ruby
1930
2325
  # begin
@@ -1945,7 +2340,13 @@ module Appsignal
1945
2340
  # ```
1946
2341
  #
1947
2342
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
1948
- def send_error: (Exception error) ?{ (Transaction transaction) -> void } -> void
2343
+ def send_error: (
2344
+ Exception error,
2345
+ ?opentelemetry_context: untyped,
2346
+ ?opentelemetry_scope: [String, String]?,
2347
+ ?opentelemetry_kind: Symbol?,
2348
+ ?opentelemetry_relationship: Symbol?
2349
+ ) ?{ (Transaction transaction) -> void } -> void
1949
2350
 
1950
2351
  # Set an error on the current transaction.
1951
2352
  #
@@ -2017,6 +2418,14 @@ module Appsignal
2017
2418
  #
2018
2419
  # _@param_ `exception` — The error to add to the current transaction.
2019
2420
  #
2421
+ # _@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.
2422
+ #
2423
+ # _@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.
2424
+ #
2425
+ # _@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.
2426
+ #
2427
+ # _@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.
2428
+ #
2020
2429
  # ```ruby
2021
2430
  # class SomeController < ApplicationController
2022
2431
  # def create
@@ -2038,7 +2447,13 @@ module Appsignal
2038
2447
  # ```
2039
2448
  #
2040
2449
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/exception-handling.html` — Exception handling guide
2041
- def report_error: (Exception exception) ?{ (Transaction transaction) -> void } -> void
2450
+ def report_error: (
2451
+ Exception exception,
2452
+ ?opentelemetry_context: untyped,
2453
+ ?opentelemetry_scope: [String, String]?,
2454
+ ?opentelemetry_kind: Symbol?,
2455
+ ?opentelemetry_relationship: Symbol?
2456
+ ) ?{ (Transaction transaction) -> void } -> void
2042
2457
 
2043
2458
  # Set a custom action name for the current transaction.
2044
2459
  #
@@ -2231,16 +2646,62 @@ module Appsignal
2231
2646
  # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-parameters.html` — Parameter filtering guide
2232
2647
  def add_params: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2233
2648
 
2649
+ # Add the request payload to the current transaction.
2650
+ #
2651
+ # The request payload is the parameters of an incoming request, such as
2652
+ # the query string and the request body. In collector mode it maps to its
2653
+ # own attribute, separate from the function parameters.
2654
+ #
2655
+ # Behaves like {#add_params}: merges when called multiple times, and a
2656
+ # block takes precedence over the argument.
2657
+ #
2658
+ # _@param_ `params` — The request payload to add to the transaction.
2659
+ #
2660
+ # _@see_ `#add_function_parameters`
2661
+ def add_request_payload: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2662
+
2663
+ # Add the function parameters to the current transaction.
2664
+ #
2665
+ # The function parameters are the arguments a background job or function
2666
+ # was called with. In collector mode they map to their own attribute,
2667
+ # separate from the request payload.
2668
+ #
2669
+ # Behaves like {#add_params}: merges when called multiple times, and a
2670
+ # block takes precedence over the argument.
2671
+ #
2672
+ # _@param_ `params` — The function parameters to add to the transaction.
2673
+ #
2674
+ # _@see_ `#add_request_payload`
2675
+ def add_function_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2676
+
2677
+ # Add the query parameters to the current transaction.
2678
+ #
2679
+ # The query parameters are the parameters parsed from an incoming
2680
+ # request's query string. In collector mode they map to their own
2681
+ # attribute, separate from the request payload and the function
2682
+ # parameters.
2683
+ #
2684
+ # Behaves like {#add_params}: merges when called multiple times, and a
2685
+ # block takes precedence over the argument.
2686
+ #
2687
+ # _@param_ `params` — The query parameters to add to the transaction.
2688
+ #
2689
+ # _@see_ `#add_request_payload`
2690
+ def add_query_parameters: (?(::Hash[String, Object] | ::Array[Object])? params) ?{ () -> (::Hash[String, Object] | ::Array[Object]) } -> void
2691
+
2234
2692
  # Mark the parameters sample data to be set as an empty value.
2235
2693
  #
2236
- # Use this helper to unset request parameters / background job arguments
2237
- # and not report any for this transaction.
2694
+ # Use this helper to report no parameters for this transaction, whatever
2695
+ # their source.
2238
2696
  #
2239
- # If parameters would normally be added by AppSignal instrumentations of
2240
- # libraries, these parameters will not be added to the Transaction.
2697
+ # This suppresses every params channel. In collector mode, where the
2698
+ # request payload and the function parameters (a background job's
2699
+ # arguments) are tracked as separate attributes, it suppresses both, not
2700
+ # only the request payload. Parameters that an AppSignal integration would
2701
+ # otherwise add are not added.
2241
2702
  #
2242
- # Calling {#add_params} after this helper will add new parameters to the
2243
- # transaction.
2703
+ # Calling {#add_params}, {#add_request_payload} or
2704
+ # {#add_function_parameters} after this helper adds parameters again.
2244
2705
  #
2245
2706
  # _@see_ `Transaction#set_empty_params!`
2246
2707
  #
@@ -2308,17 +2769,92 @@ module Appsignal
2308
2769
  # # { "PATH_INFO" => "/some-path", "HTTP_USER_AGENT" => "Firefox" }
2309
2770
  # ```
2310
2771
  #
2772
+ # _@deprecated_ — Use {#add_request_headers} for request headers and
2773
+ # {#add_request_environment} for the values a Rack environment holds
2774
+ # that are not request headers. This method takes both kinds at once,
2775
+ # so it has to work out which of them each value is.
2776
+ #
2777
+ # _@see_ `#add_request_headers`
2778
+ #
2779
+ # _@see_ `#add_request_environment`
2780
+ #
2311
2781
  # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
2312
2782
  #
2313
2783
  # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
2314
2784
  def add_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
2315
2785
 
2786
+ # Add request headers to the current transaction.
2787
+ #
2788
+ # Request headers are automatically added by most of our integrations. It
2789
+ # should not be necessary to call this method unless you want to also
2790
+ # report different request headers.
2791
+ #
2792
+ # Name each header the way OpenTelemetry names it, in lowercase and with
2793
+ # dashes. In agent mode the names are converted to the Rack spellings the
2794
+ # environment uses, so `accept` is reported as `HTTP_ACCEPT`.
2795
+ #
2796
+ # To filter request headers, see our request header filtering guide.
2797
+ #
2798
+ # When both the `headers` argument and a block is given to this method,
2799
+ # the block is leading and the argument will _not_ be used.
2800
+ #
2801
+ # _@param_ `headers` — The request headers to add to the transaction.
2802
+ #
2803
+ # Add request headers
2804
+ # ```ruby
2805
+ # Appsignal.add_request_headers("accept" => "text/html")
2806
+ # # The request headers will include:
2807
+ # # { "accept" => "text/html" }
2808
+ # ```
2809
+ #
2810
+ # Calling `add_request_headers` multiple times merges the values
2811
+ # ```ruby
2812
+ # Appsignal.add_request_headers("accept" => "text/html")
2813
+ # Appsignal.add_request_headers("user-agent" => "Firefox")
2814
+ # # The request headers will include:
2815
+ # # { "accept" => "text/html", "user-agent" => "Firefox" }
2816
+ # ```
2817
+ #
2818
+ # _@see_ `#add_request_environment`
2819
+ #
2820
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
2821
+ #
2822
+ # _@see_ `https://docs.appsignal.com/guides/filter-data/filter-headers.html` — Request headers filtering guide
2823
+ def add_request_headers: (?::Hash[String, Object]? headers) ?{ () -> ::Hash[String, Object] } -> void
2824
+
2825
+ # Add values from the request environment to the current transaction.
2826
+ #
2827
+ # These are the values a Rack environment holds that are not request
2828
+ # headers, such as `REMOTE_ADDR` and `QUERY_STRING`. Name each one the
2829
+ # way Rack names it. Use {#add_request_headers} for the request headers.
2830
+ #
2831
+ # The request environment is automatically added by most of our
2832
+ # integrations. It should not be necessary to call this method unless you
2833
+ # want to also report different values.
2834
+ #
2835
+ # When both the `environment` argument and a block is given to this
2836
+ # method, the block is leading and the argument will _not_ be used.
2837
+ #
2838
+ # _@param_ `environment` — The request environment values to add to the transaction.
2839
+ #
2840
+ # Add request environment values
2841
+ # ```ruby
2842
+ # Appsignal.add_request_environment("REMOTE_ADDR" => "127.0.0.1")
2843
+ # # The request environment will include:
2844
+ # # { "REMOTE_ADDR" => "127.0.0.1" }
2845
+ # ```
2846
+ #
2847
+ # _@see_ `#add_request_headers`
2848
+ #
2849
+ # _@see_ `https://docs.appsignal.com/guides/custom-data/sample-data.html` — Sample data guide
2850
+ def add_request_environment: (?::Hash[String, Object]? environment) ?{ () -> ::Hash[String, Object] } -> void
2851
+
2316
2852
  # Add breadcrumbs to the transaction.
2317
2853
  #
2318
2854
  # Breadcrumbs can be used to trace what path a user has taken
2319
2855
  # before encountering an error.
2320
2856
  #
2321
- # Only the last 20 added breadcrumbs will be saved.
2857
+ # At most 20 of the added breadcrumbs will be saved.
2322
2858
  #
2323
2859
  # _@param_ `category` — category of breadcrumb e.g. "UI", "Network", "Navigation", "Console".
2324
2860
  #
@@ -2373,6 +2909,10 @@ module Appsignal
2373
2909
  #
2374
2910
  # _@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
2911
  #
2912
+ # _@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`.
2913
+ #
2914
+ # _@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.
2915
+ #
2376
2916
  # _@return_ — Returns the block's return value.
2377
2917
  #
2378
2918
  # Simple instrumentation
@@ -2402,7 +2942,9 @@ module Appsignal
2402
2942
  String name,
2403
2943
  ?String? title,
2404
2944
  ?String? body,
2405
- ?Integer body_format
2945
+ ?Integer body_format,
2946
+ ?opentelemetry_kind: Symbol?,
2947
+ ?opentelemetry_scope: [String, String]?
2406
2948
  ) -> Object
2407
2949
 
2408
2950
  # Instrumentation helper for SQL queries.
@@ -2415,6 +2957,10 @@ module Appsignal
2415
2957
  #
2416
2958
  # _@param_ `body` — SQL query that's being executed.
2417
2959
  #
2960
+ # _@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.
2961
+ #
2962
+ # _@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.
2963
+ #
2418
2964
  # _@return_ — Returns the block's return value.
2419
2965
  #
2420
2966
  # SQL query instrumentation
@@ -2438,7 +2984,13 @@ module Appsignal
2438
2984
  # _@see_ `https://docs.appsignal.com/ruby/instrumentation/instrumentation.html` — AppSignal custom instrumentation guide
2439
2985
  #
2440
2986
  # _@see_ `https://docs.appsignal.com/api/event-names.html` — AppSignal event naming guide
2441
- def instrument_sql: (String name, ?String? title, ?String? body) -> Object
2987
+ def instrument_sql: (
2988
+ String name,
2989
+ ?String? title,
2990
+ ?String? body,
2991
+ ?opentelemetry_kind: Symbol,
2992
+ ?opentelemetry_scope: [String, String]?
2993
+ ) -> Object
2442
2994
 
2443
2995
  # Convenience method for ignoring instrumentation events in a block of
2444
2996
  # code.
@@ -2477,6 +3029,9 @@ module Appsignal
2477
3029
  class NotStartedError < Appsignal::InternalError
2478
3030
  def message: () -> String
2479
3031
  end
3032
+
3033
+ module Metrics
3034
+ end
2480
3035
  end
2481
3036
 
2482
3037
  # Extensions to Object for AppSignal method instrumentation.