atatus 1.3.0 → 1.4.0

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 (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile +72 -22
  4. data/LICENSE +1 -1
  5. data/atatus.gemspec +2 -2
  6. data/lib/atatus.rb +76 -16
  7. data/lib/atatus/agent.rb +78 -29
  8. data/lib/atatus/central_config.rb +72 -27
  9. data/lib/atatus/central_config/cache_control.rb +18 -1
  10. data/lib/atatus/child_durations.rb +64 -0
  11. data/lib/atatus/collector/base.rb +61 -29
  12. data/lib/atatus/collector/builder.rb +46 -2
  13. data/lib/atatus/collector/hist.rb +54 -0
  14. data/lib/atatus/collector/transport.rb +41 -11
  15. data/lib/atatus/config.rb +129 -28
  16. data/lib/atatus/config/bytes.rb +17 -0
  17. data/lib/atatus/config/duration.rb +17 -0
  18. data/lib/atatus/config/options.rb +29 -9
  19. data/lib/atatus/config/regexp_list.rb +17 -0
  20. data/lib/atatus/config/wildcard_pattern_list.rb +64 -0
  21. data/lib/atatus/context.rb +32 -1
  22. data/lib/atatus/context/request.rb +17 -0
  23. data/lib/atatus/context/request/socket.rb +18 -1
  24. data/lib/atatus/context/request/url.rb +17 -0
  25. data/lib/atatus/context/response.rb +27 -2
  26. data/lib/atatus/context/user.rb +17 -0
  27. data/lib/atatus/context_builder.rb +19 -4
  28. data/lib/atatus/deprecations.rb +17 -0
  29. data/lib/atatus/error.rb +27 -0
  30. data/lib/atatus/error/exception.rb +24 -0
  31. data/lib/atatus/error/log.rb +17 -0
  32. data/lib/atatus/error_builder.rb +17 -2
  33. data/lib/atatus/grape.rb +62 -0
  34. data/lib/atatus/graphql.rb +91 -0
  35. data/lib/atatus/grpc.rb +99 -0
  36. data/lib/atatus/instrumenter.rb +135 -30
  37. data/lib/atatus/internal_error.rb +17 -0
  38. data/lib/atatus/logging.rb +17 -2
  39. data/lib/atatus/metadata.rb +17 -0
  40. data/lib/atatus/metadata/process_info.rb +17 -0
  41. data/lib/atatus/metadata/service_info.rb +21 -6
  42. data/lib/atatus/metadata/system_info.rb +22 -3
  43. data/lib/atatus/metadata/system_info/container_info.rb +49 -10
  44. data/lib/atatus/metadata/system_info/hw_info.rb +1 -1
  45. data/lib/atatus/metrics.rb +69 -27
  46. data/lib/atatus/metrics/breakdown_set.rb +31 -0
  47. data/lib/atatus/metrics/{cpu_mem.rb → cpu_mem_set.rb} +110 -63
  48. data/lib/atatus/metrics/metric.rb +140 -0
  49. data/lib/atatus/metrics/set.rb +123 -0
  50. data/lib/atatus/metrics/span_scoped_set.rb +56 -0
  51. data/lib/atatus/metrics/transaction_set.rb +26 -0
  52. data/lib/atatus/metrics/vm_set.rb +58 -0
  53. data/lib/atatus/metricset.rb +48 -4
  54. data/lib/atatus/middleware.rb +28 -8
  55. data/lib/atatus/naively_hashable.rb +17 -0
  56. data/lib/atatus/normalizers.rb +23 -9
  57. data/lib/atatus/normalizers/grape.rb +22 -0
  58. data/lib/atatus/normalizers/grape/endpoint_run.rb +65 -0
  59. data/lib/atatus/normalizers/rails.rb +27 -0
  60. data/lib/atatus/normalizers/rails/action_controller.rb +44 -0
  61. data/lib/atatus/normalizers/rails/action_mailer.rb +43 -0
  62. data/lib/atatus/normalizers/{action_view.rb → rails/action_view.rb} +17 -0
  63. data/lib/atatus/normalizers/rails/active_record.rb +80 -0
  64. data/lib/atatus/opentracing.rb +75 -42
  65. data/lib/atatus/rails.rb +29 -13
  66. data/lib/atatus/railtie.rb +19 -6
  67. data/lib/atatus/resque.rb +29 -0
  68. data/lib/atatus/sinatra.rb +53 -0
  69. data/lib/atatus/span.rb +44 -15
  70. data/lib/atatus/span/context.rb +43 -28
  71. data/lib/atatus/span/context/db.rb +43 -0
  72. data/lib/atatus/span/context/destination.rb +77 -0
  73. data/lib/atatus/span/context/http.rb +43 -0
  74. data/lib/atatus/span_helpers.rb +18 -1
  75. data/lib/atatus/spies.rb +33 -15
  76. data/lib/atatus/spies/action_dispatch.rb +27 -6
  77. data/lib/atatus/spies/delayed_job.rb +26 -5
  78. data/lib/atatus/spies/dynamo_db.rb +62 -0
  79. data/lib/atatus/spies/elasticsearch.rb +53 -7
  80. data/lib/atatus/spies/faraday.rb +54 -20
  81. data/lib/atatus/spies/http.rb +36 -6
  82. data/lib/atatus/spies/json.rb +18 -0
  83. data/lib/atatus/spies/mongo.rb +41 -10
  84. data/lib/atatus/spies/net_http.rb +52 -11
  85. data/lib/atatus/spies/rake.rb +42 -23
  86. data/lib/atatus/spies/redis.rb +17 -0
  87. data/lib/atatus/spies/resque.rb +57 -0
  88. data/lib/atatus/spies/sequel.rb +54 -17
  89. data/lib/atatus/spies/shoryuken.rb +69 -0
  90. data/lib/atatus/spies/sidekiq.rb +46 -25
  91. data/lib/atatus/spies/sinatra.rb +20 -4
  92. data/lib/atatus/spies/sneakers.rb +74 -0
  93. data/lib/atatus/spies/sucker_punch.rb +58 -0
  94. data/lib/atatus/spies/tilt.rb +20 -1
  95. data/lib/atatus/sql.rb +36 -0
  96. data/lib/atatus/sql/signature.rb +169 -0
  97. data/lib/atatus/sql/tokenizer.rb +264 -0
  98. data/lib/atatus/sql/tokens.rb +63 -0
  99. data/lib/atatus/sql_summarizer.rb +24 -6
  100. data/lib/atatus/stacktrace.rb +17 -0
  101. data/lib/atatus/stacktrace/frame.rb +17 -3
  102. data/lib/atatus/stacktrace_builder.rb +23 -3
  103. data/lib/atatus/subscriber.rb +23 -4
  104. data/lib/atatus/trace_context.rb +84 -51
  105. data/lib/atatus/trace_context/traceparent.rb +111 -0
  106. data/lib/atatus/trace_context/tracestate.rb +148 -0
  107. data/lib/atatus/transaction.rb +74 -18
  108. data/lib/atatus/transport/base.rb +44 -27
  109. data/lib/atatus/transport/connection.rb +28 -72
  110. data/lib/atatus/transport/connection/http.rb +58 -35
  111. data/lib/atatus/transport/connection/proxy_pipe.rb +24 -5
  112. data/lib/atatus/transport/filters.rb +18 -1
  113. data/lib/atatus/transport/filters/hash_sanitizer.rb +77 -0
  114. data/lib/atatus/transport/filters/secrets_filter.rb +30 -55
  115. data/lib/atatus/transport/headers.rb +83 -0
  116. data/lib/atatus/transport/serializers.rb +17 -5
  117. data/lib/atatus/transport/serializers/context_serializer.rb +30 -3
  118. data/lib/atatus/transport/serializers/error_serializer.rb +17 -2
  119. data/lib/atatus/transport/serializers/metadata_serializer.rb +44 -22
  120. data/lib/atatus/transport/serializers/metricset_serializer.rb +34 -6
  121. data/lib/atatus/transport/serializers/span_serializer.rb +47 -12
  122. data/lib/atatus/transport/serializers/transaction_serializer.rb +18 -2
  123. data/lib/atatus/transport/user_agent.rb +48 -0
  124. data/lib/atatus/transport/worker.rb +31 -7
  125. data/lib/atatus/util.rb +18 -1
  126. data/lib/atatus/util/inflector.rb +17 -0
  127. data/lib/atatus/util/lru_cache.rb +17 -0
  128. data/lib/atatus/util/throttle.rb +17 -0
  129. data/lib/atatus/version.rb +19 -1
  130. metadata +46 -26
  131. data/Rakefile +0 -19
  132. data/bench/.gitignore +0 -2
  133. data/bench/app.rb +0 -53
  134. data/bench/benchmark.rb +0 -36
  135. data/bench/report.rb +0 -55
  136. data/bench/rubyprof.rb +0 -39
  137. data/bench/stackprof.rb +0 -23
  138. data/bin/build_docs +0 -5
  139. data/bin/console +0 -15
  140. data/bin/setup +0 -8
  141. data/bin/with_framework +0 -7
  142. data/lib/atatus/metrics/vm.rb +0 -60
  143. data/lib/atatus/normalizers/action_controller.rb +0 -27
  144. data/lib/atatus/normalizers/action_mailer.rb +0 -26
  145. data/lib/atatus/normalizers/active_record.rb +0 -45
  146. data/lib/atatus/util/prefixed_logger.rb +0 -18
  147. data/vendor/.gitkeep +0 -0
@@ -0,0 +1,83 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ # frozen_string_literal: true
19
+
20
+ module Atatus
21
+ module Transport
22
+ # @api private
23
+ class Headers
24
+ HEADERS = {
25
+ 'Content-Type' => 'application/x-ndjson',
26
+ 'Transfer-Encoding' => 'chunked'
27
+ }.freeze
28
+ GZIP_HEADERS = HEADERS.merge(
29
+ 'Content-Encoding' => 'gzip'
30
+ ).freeze
31
+
32
+ def initialize(config, initial: {})
33
+ @config = config
34
+ @hash = build!(initial)
35
+ end
36
+
37
+ attr_accessor :hash
38
+
39
+ def [](key)
40
+ @hash[key]
41
+ end
42
+
43
+ def []=(key, value)
44
+ @hash[key] = value
45
+ end
46
+
47
+ def merge(other)
48
+ self.class.new(@config, initial: @hash.merge(other))
49
+ end
50
+
51
+ def merge!(other)
52
+ @hash.merge!(other)
53
+ self
54
+ end
55
+
56
+ def to_h
57
+ @hash
58
+ end
59
+
60
+ def chunked
61
+ merge(
62
+ @config.http_compression? ? GZIP_HEADERS : HEADERS
63
+ )
64
+ end
65
+
66
+ private
67
+
68
+ def build!(headers)
69
+ headers[:'User-Agent'] = UserAgent.new(@config).to_s
70
+
71
+ if (token = @config.secret_token)
72
+ headers[:Authorization] = "Bearer #{token}"
73
+ end
74
+
75
+ if (api_key = @config.api_key)
76
+ headers[:Authorization] = "ApiKey #{api_key}"
77
+ end
78
+
79
+ headers
80
+ end
81
+ end
82
+ end
83
+ end
@@ -1,6 +1,21 @@
1
- # frozen_string_literal: true
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
2
17
 
3
- require 'json'
18
+ # frozen_string_literal: true
4
19
 
5
20
  module Atatus
6
21
  module Transport
@@ -57,8 +72,6 @@ module Atatus
57
72
  end
58
73
 
59
74
  attr_reader :transaction, :span, :error, :metadata, :metricset
60
-
61
- # rubocop:disable Metrics/MethodLength
62
75
  def serialize(resource)
63
76
  case resource
64
77
  when Transaction
@@ -75,7 +88,6 @@ module Atatus
75
88
  raise UnrecognizedResource, resource.inspect
76
89
  end
77
90
  end
78
- # rubocop:enable Metrics/MethodLength
79
91
  end
80
92
 
81
93
  def self.new(config)
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module Atatus
@@ -13,13 +30,13 @@ module Atatus
13
30
  tags: mixed_object(context.labels),
14
31
  request: build_request(context.request),
15
32
  response: build_response(context.response),
16
- user: build_user(context.user)
33
+ user: build_user(context.user),
34
+ service: build_service(context.service)
17
35
  }
18
36
  end
19
37
 
20
38
  private
21
39
 
22
- # rubocop:disable Metrics/MethodLength
23
40
  def build_request(request)
24
41
  return unless request
25
42
 
@@ -34,7 +51,6 @@ module Atatus
34
51
  url: build_url(request.url)
35
52
  }
36
53
  end
37
- # rubocop:enable Metrics/MethodLength
38
54
 
39
55
  def build_response(response)
40
56
  return unless response
@@ -79,6 +95,17 @@ module Atatus
79
95
  hash: keyword_field(url.hash)
80
96
  }
81
97
  end
98
+
99
+ def build_service(service)
100
+ return unless service
101
+
102
+ {
103
+ framework: {
104
+ name: keyword_field(service.framework.name),
105
+ version: keyword_field(service.framework.version)
106
+ }
107
+ }
108
+ end
82
109
  end
83
110
  end
84
111
  end
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module Atatus
@@ -9,7 +26,6 @@ module Atatus
9
26
  @context_serializer ||= ContextSerializer.new(config)
10
27
  end
11
28
 
12
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
29
  def build(error)
14
30
  base = {
15
31
  id: error.id,
@@ -36,7 +52,6 @@ module Atatus
36
52
 
37
53
  { error: base }
38
54
  end
39
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
40
55
 
41
56
  private
42
57
 
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module Atatus
@@ -18,31 +35,36 @@ module Atatus
18
35
 
19
36
  private
20
37
 
21
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
22
38
  def build_service(service)
23
- {
24
- name: keyword_field(service.name),
25
- environment: keyword_field(service.environment),
26
- version: keyword_field(service.version),
27
- agent: {
28
- name: keyword_field(service.agent.name),
29
- version: keyword_field(service.agent.version)
30
- },
31
- framework: {
32
- name: keyword_field(service.framework.name),
33
- version: keyword_field(service.framework.version)
34
- },
35
- language: {
36
- name: keyword_field(service.language.name),
37
- version: keyword_field(service.language.version)
38
- },
39
- runtime: {
40
- name: keyword_field(service.runtime.name),
41
- version: keyword_field(service.runtime.version)
39
+ base =
40
+ {
41
+ name: keyword_field(service.name),
42
+ environment: keyword_field(service.environment),
43
+ version: keyword_field(service.version),
44
+ agent: {
45
+ name: keyword_field(service.agent.name),
46
+ version: keyword_field(service.agent.version)
47
+ },
48
+ framework: {
49
+ name: keyword_field(service.framework.name),
50
+ version: keyword_field(service.framework.version)
51
+ },
52
+ language: {
53
+ name: keyword_field(service.language.name),
54
+ version: keyword_field(service.language.version)
55
+ },
56
+ runtime: {
57
+ name: keyword_field(service.runtime.name),
58
+ version: keyword_field(service.runtime.version)
59
+ }
42
60
  }
43
- }
61
+
62
+ if node_name = service.node_name
63
+ base[:node] = { name: keyword_field(node_name) }
64
+ end
65
+
66
+ base
44
67
  end
45
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
46
68
 
47
69
  def build_process(process)
48
70
  {
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module Atatus
@@ -6,13 +23,24 @@ module Atatus
6
23
  # @api private
7
24
  class MetricsetSerializer < Serializer
8
25
  def build(metricset)
9
- {
10
- metricset: {
11
- timestamp: metricset.timestamp.to_i,
12
- tags: keyword_object(metricset.labels),
13
- samples: build_samples(metricset.samples)
14
- }
26
+ payload = {
27
+ timestamp: metricset.timestamp.to_i,
28
+ samples: build_samples(metricset.samples)
15
29
  }
30
+
31
+ if metricset.tags?
32
+ payload[:tags] = mixed_object(metricset.tags)
33
+ end
34
+
35
+ if metricset.transaction
36
+ payload[:transaction] = metricset.transaction
37
+ end
38
+
39
+ if metricset.span
40
+ payload[:span] = metricset.span
41
+ end
42
+
43
+ { metricset: payload }
16
44
  end
17
45
 
18
46
  private
@@ -1,3 +1,20 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
1
18
  # frozen_string_literal: true
2
19
 
3
20
  module Atatus
@@ -13,12 +30,11 @@ module Atatus
13
30
 
14
31
  attr_reader :context_serializer
15
32
 
16
- # rubocop:disable Metrics/MethodLength
17
33
  def build(span)
18
34
  {
19
35
  span: {
20
36
  id: span.id,
21
- transaction_id: span.transaction_id,
37
+ transaction_id: span.transaction.id,
22
38
  parent_id: span.parent_id,
23
39
  name: keyword_field(span.name),
24
40
  type: join_type(span),
@@ -26,45 +42,64 @@ module Atatus
26
42
  context: context_serializer.build(span.context),
27
43
  stacktrace: span.stacktrace.to_a,
28
44
  timestamp: span.timestamp,
29
- trace_id: span.trace_id
45
+ trace_id: span.trace_id,
46
+ sample_rate: span.sample_rate
30
47
  }
31
48
  }
32
49
  end
33
- # rubocop:enable Metrics/MethodLength
34
50
 
35
51
  # @api private
36
52
  class ContextSerializer < Serializer
53
+ # rubocop:disable Metrics/CyclomaticComplexity
37
54
  def build(context)
38
55
  return unless context
39
56
 
40
- { sync: context.sync }.tap do |base|
41
- base[:db] = build_db(context.db) if context.db
42
- base[:http] = build_http(context.http) if context.http
57
+ base = {}
58
+
59
+ base[:tags] = mixed_object(context.labels) if context.labels.any?
60
+ base[:sync] = context.sync unless context.sync.nil?
61
+ base[:db] = build_db(context.db) if context.db
62
+ base[:http] = build_http(context.http) if context.http
63
+
64
+ if context.destination
65
+ base[:destination] = build_destination(context.destination)
43
66
  end
67
+
68
+ base
44
69
  end
70
+ # rubocop:enable Metrics/CyclomaticComplexity
45
71
 
46
72
  private
47
73
 
48
74
  def build_db(db)
49
- return unless db
50
-
51
75
  {
52
76
  instance: db.instance,
53
77
  statement: Util.truncate(db.statement, max_length: 10_000),
54
78
  type: db.type,
55
- user: db.user
79
+ user: db.user,
80
+ rows_affected: db.rows_affected
56
81
  }
57
82
  end
58
83
 
59
84
  def build_http(http)
60
- return unless http
61
-
62
85
  {
63
86
  url: http.url,
64
87
  status_code: http.status_code.to_i,
65
88
  method: keyword_field(http.method)
66
89
  }
67
90
  end
91
+
92
+ def build_destination(destination)
93
+ {
94
+ service: {
95
+ name: keyword_field(destination.name),
96
+ resource: keyword_field(destination.resource),
97
+ type: keyword_field(destination.type)
98
+ },
99
+ address: keyword_field(destination.address),
100
+ port: destination.port
101
+ }
102
+ end
68
103
  end
69
104
 
70
105
  private