Class: NewRelic::Agent::OpenTelemetry::RpcTranslator
Constant Summary
AttributeMappings::DATASTORE_MAPPINGS, AttributeMappings::DEFAULT_DESTINATIONS, AttributeMappings::HTTP_CLIENT_MAPPINGS, AttributeMappings::HTTP_SERVER_MAPPINGS, AttributeMappings::MESSAGING_CONSUMER_MAPPINGS, AttributeMappings::MESSAGING_PRODUCER_MAPPINGS, AttributeMappings::REDIS_MAPPINGS, AttributeMappings::RPC_CLIENT_MAPPINGS, AttributeMappings::RPC_SERVER_MAPPINGS
Class Method Summary
collapse
translate
Class Method Details
.add_specialized_attributes(result: {}, name: nil, attributes: nil, instrumentation_scope: nil, kind: nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/new_relic/agent/opentelemetry/translators/rpc_translator.rb', line 16
def add_specialized_attributes(result: {}, name: nil, attributes: nil, instrumentation_scope: nil, kind: nil)
case kind
when :client
uri = build_uri(attributes)
result[:for_segment_api][:uri] = uri if uri
when :server
server_name = create_server_transaction_name(name: name, attributes: attributes, instrumentation_scope: instrumentation_scope) if name
result[:for_segment_api][:name] = server_name if server_name
uri = build_uri(attributes)
if uri
result[:agent]['request.uri'] = {value: uri, destinations: AttributeMappings::DEFAULT_DESTINATIONS}
end
end
result
end
|
.build_uri(attributes) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/new_relic/agent/opentelemetry/translators/rpc_translator.rb', line 39
def build_uri(attributes)
host = attributes['server.address'] || attributes['net.peer.name'] || attributes['net.sock.peer.addr']
service = attributes['rpc.service']
method = attributes['rpc.method']
return unless host || service || method
host = host&.sub(%r{\A\w+:///}, '')
if host && service && method
"grpc://#{host}/#{service}/#{method}"
elsif host && method
"grpc://#{host}/#{method}"
elsif service && method
"grpc://#{service}/#{method}"
end
end
|
.create_server_transaction_name(name: nil, attributes: nil, instrumentation_scope: nil) ⇒ Object
.mappings_hash(kind) ⇒ Object