lib/opentelemetry/exporter/zipkin/transformer.rb in opentelemetry-exporter-zipkin-0.20.0 vs lib/opentelemetry/exporter/zipkin/transformer.rb in opentelemetry-exporter-zipkin-0.21.0
- old
+ new
@@ -44,11 +44,11 @@
service_name = DEFAULT_SERVICE_NAME
resource.attribute_enumerator.select do |key, value|
service_name = value if key == SERVICE_NAME_ATTRIBUTE_KEY
end
- add_il_tags(span_d, tags)
+ add_scope_tags(span_d, tags)
add_status_tags(span_d, tags)
tags = aggregate_span_tags(span_d, tags)
# TOOO: set debug flag? (is that represented in tracestate?)
# https://github.com/openzipkin/b3-propagation#why-is-debug-encoded-as-x-b3-flags-1
@@ -68,13 +68,16 @@
add_annotations(zipkin_span, span_d)
zipkin_span
end
- def add_il_tags(span_data, tags)
- tags['otel.library.name'] = span_data.instrumentation_library.name
- tags['otel.library.version'] = span_data.instrumentation_library.version
+ def add_scope_tags(span_data, tags)
+ tags['otel.scope.name'] = span_data.instrumentation_scope.name
+ tags['otel.library.name'] = span_data.instrumentation_scope.name
+
+ tags['otel.scope.version'] = span_data.instrumentation_scope.version
+ tags['otel.library.version'] = span_data.instrumentation_scope.version
end
def add_status_tags(span_data, tags)
if span_data.status&.code == OpenTelemetry::Trace::Status::ERROR
# mark errors if we can, setting error key to description but falling back to an empty string
@@ -86,10 +89,17 @@
elsif span_data.status&.code == OpenTelemetry::Trace::Status::OK
tags[STATUS_CODE_NAME] = STATUS_OK
end
end
- def add_conditional_tags(zipkin_span, span_data, tags, service_name)
+ def add_conditional_tags(zipkin_span, span_data, tags, service_name) # rubocop:disable Metrics/CyclomaticComplexity
+ dropped_attributes_count = span_data.total_recorded_attributes - span_data.attributes&.size.to_i
+ dropped_events_count = span_data.total_recorded_events - span_data.events&.size.to_i
+ dropped_links_count = span_data.total_recorded_links - span_data.links&.size.to_i
+ tags['otel.dropped_attributes_count'] = dropped_attributes_count.to_s if dropped_attributes_count.positive?
+ tags['otel.dropped_events_count'] = dropped_events_count.to_s if dropped_events_count.positive?
+ tags['otel.dropped_links_count'] = dropped_links_count.to_s if dropped_links_count.positive?
+
zipkin_span['tags'] = tags unless tags.empty?
zipkin_span['kind'] = KIND_MAP[span_data.kind] unless span_data.kind.nil?
zipkin_span['parentId'] = span_data.hex_parent_span_id unless span_data.parent_span_id == OpenTelemetry::Trace::INVALID_SPAN_ID
zipkin_span['localEndpoint'] = endpoint_from_tags(tags, (span_data.attributes && span_data.attributes[SERVICE_NAME_ATTRIBUTE_KEY]) || service_name)
# remote endpoint logic https://github.com/open-telemetry/opentelemetry-collector/blob/347cfa9ab21d47240128c58c9bafcc0014bc729d/translator/trace/zipkin/traces_to_zipkinv2.go#L284