Class: NewRelic::Agent::OpenTelemetry::HttpServerTranslator

Inherits:
BaseTranslator
  • Object
show all
Defined in:
lib/new_relic/agent/opentelemetry/translators/http_server_translator.rb

Constant Summary

Constants included from AttributeMappings

AttributeMappings::DATASTORE_MAPPINGS, AttributeMappings::DEFAULT_DESTINATIONS, AttributeMappings::HTTP_CLIENT_MAPPINGS, AttributeMappings::HTTP_SERVER_MAPPINGS

Class Method Summary collapse

Methods inherited from BaseTranslator

translate

Class Method Details

.add_specialized_attributes(result: {}, name: nil, attributes: nil, instrumentation_scope: nil) ⇒ Object



16
17
18
19
20
# File 'lib/new_relic/agent/opentelemetry/translators/http_server_translator.rb', line 16

def add_specialized_attributes(result: {}, name: nil, attributes: nil, instrumentation_scope: nil)
  result[:for_segment_api][:name] = create_server_transaction_name(name, instrumentation_scope, attributes)

  result
end

.create_server_transaction_name(original_name, instrumentation_scope, attributes) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/new_relic/agent/opentelemetry/translators/http_server_translator.rb', line 22

def create_server_transaction_name(original_name, instrumentation_scope, attributes)
  attributes ||= NewRelic::EMPTY_HASH
  method = attributes['http.request.method'] || attributes['http.method']
  path = attributes['url.path'] || attributes['http.target']

  if method && path
    # TransactionNamer.name_for is used in ControllerInstrumentation
    # This will produce a name that looks something like:
    # "Controller/OpenTelemetry::Instrumentation::Rack/GET /path"
    # "method /path" is roughly what the semantic conventions have for
    # a server span name in the stable conventions, but the old
    # conventions prefix with HTTP; so we create the string
    # ourselves until only the stable conventions are used
    Instrumentation::ControllerInstrumentation::TransactionNamer.name_for(nil, nil, :web, {class_name: instrumentation_scope, name: "#{method} #{path}"})
  else
    original_name
  end
end

.mappings_hashObject



12
13
14
# File 'lib/new_relic/agent/opentelemetry/translators/http_server_translator.rb', line 12

def mappings_hash
  AttributeMappings::HTTP_SERVER_MAPPINGS
end