lib/opentelemetry/exporter/jaeger/encoder.rb in opentelemetry-exporter-jaeger-0.12.0 vs lib/opentelemetry/exporter/jaeger/encoder.rb in opentelemetry-exporter-jaeger-0.13.0
- old
+ new
@@ -28,14 +28,15 @@
OpenTelemetry::Trace::SpanKind::SERVER => 'server',
OpenTelemetry::Trace::SpanKind::CLIENT => 'client',
OpenTelemetry::Trace::SpanKind::PRODUCER => 'producer',
OpenTelemetry::Trace::SpanKind::CONSUMER => 'consumer'
}.freeze
- private_constant(:EMPTY_ARRAY, :LONG, :DOUBLE, :STRING, :BOOL, :KEY, :TYPE, :TYPE_MAP, :KIND_MAP)
+ DEFAULT_SERVICE_NAME = OpenTelemetry::SDK::Resources::Resource.default.attribute_enumerator.find { |k, _| k == 'service.name' }&.last || 'unknown_service'
+ private_constant(:EMPTY_ARRAY, :LONG, :DOUBLE, :STRING, :BOOL, :KEY, :TYPE, :TYPE_MAP, :KIND_MAP, :DEFAULT_SERVICE_NAME)
def encoded_process(resource)
- service_name = 'unknown'
+ service_name = DEFAULT_SERVICE_NAME
tags = resource&.attribute_enumerator&.select do |key, value|
service_name = value if key == 'service.name'
key != 'service.name'
end
tags = encoded_tags(tags)
@@ -108,10 +109,10 @@
end
def encoded_references(links)
links&.map do |link|
Thrift::SpanRef.new(
- 'refType' => Thrift::SpanRefType::CHILD_OF,
+ 'refType' => Thrift::SpanRefType::FOLLOWS_FROM,
'traceIdLow' => int64(link.span_context.trace_id[16, 16]),
'traceIdHigh' => int64(link.span_context.trace_id[0, 16]),
'spanId' => int64(link.span_context.span_id)
)
end