Class: OpenTelemetry::Exporters::Datadog::Exporter::SpanEncoder Private
- Inherits:
-
Object
- Object
- OpenTelemetry::Exporters::Datadog::Exporter::SpanEncoder
- Defined in:
- lib/opentelemetry/exporters/datadog/exporter/span_encoder.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- ENV_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'env'- VERSION_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'version'- DD_ORIGIN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'_dd_origin'- USER_REJECT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
-1- AUTO_REJECT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
0- AUTO_KEEP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1- USER_KEEP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
2- INTERNAL_TRACE_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%r{/v\d\.\d/traces}.freeze
- SAMPLE_RATE_METRIC_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'_sample_rate'- SAMPLING_PRIORITY_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'_sampling_priority_v1'- ORIGIN_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/#{DD_ORIGIN}\=(.*?)($|,)/.freeze
- PROBABILITY_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\d[.]\d{1,6}/.freeze
- TRUNCATION_HELPER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
::Datadog::DistributedTracing::Headers::Headers.new({})
- RESOURCE_SERVICE_TAG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'service.name'- RESOURCE_VERSION_TAG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'service.version'- RESOURCE_ENVIRONMENT_TAG =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'deployment.environment'- INSTRUMENTATION_SPAN_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'OpenTelemetry::Instrumentation::Ethon' => ::Datadog::Ext::HTTP::TYPE_OUTBOUND, 'OpenTelemetry::Instrumentation::Excon' => ::Datadog::Ext::HTTP::TYPE_OUTBOUND, 'OpenTelemetry::Instrumentation::Faraday' => ::Datadog::Ext::HTTP::TYPE_OUTBOUND, 'OpenTelemetry::Instrumentation::Mysql2' => ::Datadog::Ext::SQL::TYPE, 'OpenTelemetry::Instrumentation::Net::HTTP' => ::Datadog::Ext::HTTP::TYPE_OUTBOUND, 'OpenTelemetry::Instrumentation::Rack' => ::Datadog::Ext::HTTP::TYPE_INBOUND, 'OpenTelemetry::Instrumentation::Redis' => ::Datadog::Contrib::Redis::Ext::TYPE, 'OpenTelemetry::Instrumentation::RestClient' => ::Datadog::Ext::HTTP::TYPE_OUTBOUND, 'OpenTelemetry::Instrumentation::Sidekiq' => ::Datadog::Ext::AppTypes::WORKER, 'OpenTelemetry::Instrumentation::Sinatra' => ::Datadog::Ext::HTTP::TYPE_INBOUND }.freeze
Instance Method Summary collapse
- #int64(hex_string, base) ⇒ Object private
-
#translate_to_datadog(otel_spans, service, env = nil, version = nil, tags = nil) ⇒ Object
private
rubocop:disable Metrics/AbcSize.
Instance Method Details
#int64(hex_string, base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
118 119 120 |
# File 'lib/opentelemetry/exporters/datadog/exporter/span_encoder.rb', line 118 def int64(hex_string, base) TRUNCATION_HELPER.value_to_id(hex_string, base) end |
#translate_to_datadog(otel_spans, service, env = nil, version = nil, tags = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/AbcSize
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/opentelemetry/exporters/datadog/exporter/span_encoder.rb', line 52 def translate_to_datadog(otel_spans, service, env = nil, version = nil, = nil) # rubocop:disable Metrics/AbcSize datadog_spans = [] = () || {} otel_spans.each do |span| trace_id, span_id, parent_id = get_trace_ids(span) span_type = get_span_type(span) span_name = get_span_name(span) # this excludes service.name, which we get seperately , resource_service_name, resource_environment_name, resource_version_name = (span) = .merge() datadog_span = ::Datadog::Span.new(nil, span_name, service: resource_service_name || service, trace_id: trace_id, parent_id: parent_id, resource: get_resource(span), span_type: span_type) # span_id is autogenerated so have to override datadog_span.span_id = span_id datadog_span.start_time = span. datadog_span.end_time = span. # set span.error, span tag error.msg/error.type if span.status && !span.status.ok? datadog_span.status = 1 exception_type, exception_msg, exception_stack = get_exception_info(span) if exception_type && exception_msg && exception_stack datadog_span.set_tag('error.type', exception_type) datadog_span.set_tag('error.msg', exception_msg) datadog_span.set_tag('error.stack', exception_stack) end end # set default tags &.keys&.each do |attribute| datadog_span.set_tag(attribute, [attribute]) end origin = get_origin_string(span) datadog_span.set_tag(DD_ORIGIN, origin) if origin && parent_id.zero? datadog_span.set_tag(VERSION_KEY, resource_version_name || version) if (resource_version_name || version) && parent_id.zero? datadog_span.set_tag(ENV_KEY, resource_environment_name || env) if resource_version_name || env # set tags - takes precedence over env vars span.attributes&.keys&.each do |attribute| datadog_span.set_tag(attribute, span.attributes[attribute]) end sampling_rate = get_sampling_rate(span) if filter_internal_request?(span) datadog_span.set_metric(SAMPLE_RATE_METRIC_KEY, USER_REJECT) elsif sampling_rate datadog_span.set_metric(SAMPLE_RATE_METRIC_KEY, sampling_rate) end datadog_spans << datadog_span end datadog_spans end |