From 03e36cec755df97e08139494b85473a7ad547001 Mon Sep 17 00:00:00 2001 From: Andrew Hayworth Date: Mon, 22 Aug 2022 08:54:29 -0500 Subject: [PATCH] feat: support InstrumentationScope, and update OTLP proto to 0.18.0 (#1345) * feat: support InstrumentationScope, and update OTLP proto to 0.18.0 This commit accomplishes two things simultaneously - adding support for InstrumentationScope everywhere, and also updating the OTLP proto to v0.18.0. The PR that introduced InstrumentationScope is [here](/~https://github.com/open-telemetry/opentelemetry-specification/pull/2276) My best understanding (which is implemented in this PR) is that: - Our OTLP export requests should group by InstrumentationScope instead of InstrumentationLibrary - We must be able to support accessing the InstrumentationLibrary from anywhere a ReadableSpan is available, and that it should represent the `name` and `version` fields from the InstrumentationScope. - When creating a tracer, we create and store an InstrumentationScope rather than an InstrumentationLibrary. - Non-OTLP exporters must export both `otlp.scope.{name,version}` AND `otlp.library.{name,version}` tags for backwards compatibility. Some notes that may be interesting: - I chose to keep the original definition of `InstrumentationLibrary` around for now. - I chose to have `Span#instrumentation_library` and `SpanData#instrumentation_library` create and memoize an `InstrumentationLibrary` on-demand when someone asks for it (and marked the method as deprecated in the YARD docs). - I chose *not* to reference that deprecated helper when modifying the zipkin and jaeger exporters, for performance reasons. * Update sdk/test/opentelemetry/sdk/trace/span_test.rb Co-authored-by: Francis Bogsanyi * Update sdk/lib/opentelemetry/sdk/trace/span_data.rb Co-authored-by: Francis Bogsanyi * Update sdk/lib/opentelemetry/sdk/trace/span.rb Co-authored-by: Francis Bogsanyi * fixup: use alias_method * fixup: add deprecation notice to InstrumentationLibrary * fixup: argh, use alias in class scope * Update sdk/lib/opentelemetry/sdk/trace/span.rb Co-authored-by: Francis Bogsanyi * Update sdk/lib/opentelemetry/sdk/trace/span.rb Co-authored-by: Francis Bogsanyi * Update sdk/lib/opentelemetry/sdk/trace/span_data.rb Co-authored-by: Francis Bogsanyi * fixup: update Rakefile to regenerate protos correctly It now checks out a specific tag, for starters. * bundle exec rake update_protobuf Co-authored-by: Francis Bogsanyi --- .../opentelemetry/exporter/jaeger/encoder.rb | 18 +++-- .../exporter/jaeger/encoder_test.rb | 39 ++++++---- exporter/jaeger/test/test_helper.rb | 4 +- exporter/otlp-common/Rakefile | 10 ++- .../lib/opentelemetry/exporter/otlp/common.rb | 8 +- .../collector/logs/v1/logs_service_pb.rb | 1 + .../logs/v1/logs_service_services_pb.rb | 2 +- .../metrics/v1/metrics_service_pb.rb | 1 + .../metrics/v1/metrics_service_services_pb.rb | 2 +- .../collector/trace/v1/trace_service_pb.rb | 1 + .../trace/v1/trace_service_services_pb.rb | 2 +- .../proto/common/v1/common_pb.rb | 10 +-- .../opentelemetry/proto/logs/v1/logs_pb.rb | 14 +++- .../experimental/metrics_config_service_pb.rb | 43 ----------- .../proto/metrics/v1/metrics_pb.rb | 67 ++++------------- .../proto/resource/v1/resource_pb.rb | 1 + .../opentelemetry/proto/trace/v1/trace_pb.rb | 31 +++----- .../exporter/otlp/common/common_test.rb | 14 ++-- .../exporter/otlp/http/trace_exporter_test.rb | 10 +-- exporter/otlp/Rakefile | 10 ++- .../opentelemetry/exporter/otlp/exporter.rb | 8 +- .../collector/logs/v1/logs_service_pb.rb | 1 + .../logs/v1/logs_service_services_pb.rb | 2 +- .../metrics/v1/metrics_service_pb.rb | 1 + .../metrics/v1/metrics_service_services_pb.rb | 2 +- .../collector/trace/v1/trace_service_pb.rb | 1 + .../trace/v1/trace_service_services_pb.rb | 2 +- .../proto/common/v1/common_pb.rb | 10 +-- .../opentelemetry/proto/logs/v1/logs_pb.rb | 14 +++- .../experimental/metrics_config_service_pb.rb | 43 ----------- .../proto/metrics/v1/metrics_pb.rb | 67 ++++------------- .../proto/resource/v1/resource_pb.rb | 1 + .../opentelemetry/proto/trace/v1/trace_pb.rb | 31 +++----- .../exporter/otlp/exporter_test.rb | 10 +-- .../exporter/zipkin/transformer.rb | 11 ++- .../exporters/zipkin/exporter_test.rb | 4 +- .../exporters/zipkin/transformer_test.rb | 73 +++++++++++++++---- exporter/zipkin/test/test_helper.rb | 4 +- .../instrument/synchronous_instrument.rb | 6 +- .../lib/opentelemetry/sdk/metrics/meter.rb | 14 ++-- .../sdk/metrics/state/metric_data.rb | 2 +- .../sdk/metrics/state/metric_stream.rb | 8 +- .../in_memory_metric_pull_exporter_test.rb | 2 +- sdk/lib/opentelemetry/sdk.rb | 1 + .../sdk/instrumentation_library.rb | 1 + .../sdk/instrumentation_scope.rb | 13 ++++ sdk/lib/opentelemetry/sdk/trace/span.rb | 14 +++- sdk/lib/opentelemetry/sdk/trace/span_data.rb | 8 +- sdk/lib/opentelemetry/sdk/trace/tracer.rb | 4 +- .../sdk/trace/tracer_provider.rb | 4 +- sdk/test/opentelemetry/sdk/trace/span_test.rb | 24 ++++++ .../opentelemetry/sdk/trace/tracer_test.rb | 6 +- .../lib/opentelemetry/test_helpers.rb | 4 +- 53 files changed, 325 insertions(+), 359 deletions(-) delete mode 100644 exporter/otlp-common/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb delete mode 100644 exporter/otlp/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb create mode 100644 sdk/lib/opentelemetry/sdk/instrumentation_scope.rb diff --git a/exporter/jaeger/lib/opentelemetry/exporter/jaeger/encoder.rb b/exporter/jaeger/lib/opentelemetry/exporter/jaeger/encoder.rb index 877241cd4d..452830e8a5 100644 --- a/exporter/jaeger/lib/opentelemetry/exporter/jaeger/encoder.rb +++ b/exporter/jaeger/lib/opentelemetry/exporter/jaeger/encoder.rb @@ -71,7 +71,7 @@ def encoded_span(span_data) # rubocop:disable Metrics/MethodLength tags = encoded_tags(span_data.attributes) + encoded_status(span_data.status) + encoded_kind(span_data.kind) + - encoded_instrumentation_library(span_data.instrumentation_library) + encoded_instrumentation_scope(span_data.instrumentation_scope) 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 @@ -141,12 +141,20 @@ def encoded_status(status) ) end - def encoded_instrumentation_library(instrumentation_library) - return EMPTY_ARRAY unless instrumentation_library + def encoded_instrumentation_scope(instrumentation_scope) + return EMPTY_ARRAY unless instrumentation_scope tags = [] - tags << encoded_tag('otel.library.name', instrumentation_library.name) if instrumentation_library.name - tags << encoded_tag('otel.library.version', instrumentation_library.version) if instrumentation_library.version + if instrumentation_scope.name + tags << encoded_tag('otel.scope.name', instrumentation_scope.name) + tags << encoded_tag('otel.library.name', instrumentation_scope.name) + end + + if instrumentation_scope.version + tags << encoded_tag('otel.scope.version', instrumentation_scope.version) + tags << encoded_tag('otel.library.version', instrumentation_scope.version) + end + tags end diff --git a/exporter/jaeger/test/opentelemetry/exporter/jaeger/encoder_test.rb b/exporter/jaeger/test/opentelemetry/exporter/jaeger/encoder_test.rb index 5df8e3f730..37b8c04650 100644 --- a/exporter/jaeger/test/opentelemetry/exporter/jaeger/encoder_test.rb +++ b/exporter/jaeger/test/opentelemetry/exporter/jaeger/encoder_test.rb @@ -119,38 +119,47 @@ ) end - describe 'instrumentation library' do - it 'encodes library and version when set' do - lib = OpenTelemetry::SDK::InstrumentationLibrary.new('mylib', '0.1.0') - span_data = create_span_data(instrumentation_library: lib) + describe 'instrumentation scope' do + it 'encodes name and version when set, with backwards-compat tags' do + lib = OpenTelemetry::SDK::InstrumentationScope.new('mylib', '0.1.0') + span_data = create_span_data(instrumentation_scope: lib) encoded_span = Encoder.encoded_span(span_data) - _(encoded_span.tags.size).must_equal(2) + _(encoded_span.tags.size).must_equal(4) - name_tag, version_tag = encoded_span.tags + name_tag, old_name_tag, version_tag, old_version_tag = encoded_span.tags - _(name_tag.key).must_equal('otel.library.name') + _(name_tag.key).must_equal('otel.scope.name') _(name_tag.vStr).must_equal('mylib') - _(version_tag.key).must_equal('otel.library.version') + _(old_name_tag.key).must_equal('otel.library.name') + _(old_name_tag.vStr).must_equal('mylib') + + _(version_tag.key).must_equal('otel.scope.version') _(version_tag.vStr).must_equal('0.1.0') + + _(old_version_tag.key).must_equal('otel.library.version') + _(old_version_tag.vStr).must_equal('0.1.0') end it 'skips nil values' do - lib = OpenTelemetry::SDK::InstrumentationLibrary.new('mylib') - span_data = create_span_data(instrumentation_library: lib) + lib = OpenTelemetry::SDK::InstrumentationScope.new('mylib') + span_data = create_span_data(instrumentation_scope: lib) encoded_span = Encoder.encoded_span(span_data) - _(encoded_span.tags.size).must_equal(1) + _(encoded_span.tags.size).must_equal(2) - name_tag, = encoded_span.tags + name_tag, old_name_tag = encoded_span.tags - _(name_tag.key).must_equal('otel.library.name') + _(name_tag.key).must_equal('otel.scope.name') _(name_tag.vStr).must_equal('mylib') + + _(old_name_tag.key).must_equal('otel.library.name') + _(old_name_tag.vStr).must_equal('mylib') end end - def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_attributes: 0, events: nil, total_recorded_events: 0, links: nil, total_recorded_links: 0, instrumentation_library: nil, trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) + def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_attributes: 0, events: nil, total_recorded_events: 0, links: nil, total_recorded_links: 0, instrumentation_scope: nil, trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) OpenTelemetry::SDK::Trace::SpanData.new( '', kind, @@ -165,7 +174,7 @@ def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_att links, events, nil, - instrumentation_library, + instrumentation_scope, OpenTelemetry::Trace.generate_span_id, trace_id, trace_flags, diff --git a/exporter/jaeger/test/test_helper.rb b/exporter/jaeger/test/test_helper.rb index 7268b95315..43f863fed2 100644 --- a/exporter/jaeger/test/test_helper.rb +++ b/exporter/jaeger/test/test_helper.rb @@ -15,10 +15,10 @@ def create_span_data(name: '', kind: nil, status: nil, parent_span_id: OpenTelemetry::Trace::INVALID_SPAN_ID, total_recorded_attributes: 0, total_recorded_events: 0, total_recorded_links: 0, start_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, - end_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, attributes: nil, links: nil, events: nil, resource: nil, instrumentation_library: nil, + end_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, attributes: nil, links: nil, events: nil, resource: nil, instrumentation_scope: nil, span_id: OpenTelemetry::Trace.generate_span_id, trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) OpenTelemetry::SDK::Trace::SpanData.new(name, kind, status, parent_span_id, total_recorded_attributes, total_recorded_events, total_recorded_links, start_timestamp, end_timestamp, - attributes, links, events, resource, instrumentation_library, span_id, trace_id, trace_flags, tracestate) + attributes, links, events, resource, instrumentation_scope, span_id, trace_id, trace_flags, tracestate) end diff --git a/exporter/otlp-common/Rakefile b/exporter/otlp-common/Rakefile index 511f7665d9..637f7132f8 100644 --- a/exporter/otlp-common/Rakefile +++ b/exporter/otlp-common/Rakefile @@ -29,15 +29,21 @@ else task default: %i[test rubocop yard] end +PROTO_VERSION = 'v0.18.0' PROTOBUF_FILES = [ + 'collector/logs/v1/logs_service.proto', + 'collector/metrics/v1/metrics_service.proto', + 'collector/trace/v1/trace_service.proto', 'common/v1/common.proto', + 'logs/v1/logs.proto', + 'metrics/v1/metrics.proto', 'resource/v1/resource.proto', 'trace/v1/trace.proto', - 'collector/trace/v1/trace_service.proto' + 'trace/v1/trace_config.proto' ].freeze task :update_protobuf do - system('git clone /~https://github.com/open-telemetry/opentelemetry-proto') + system("git clone -b #{PROTO_VERSION} /~https://github.com/open-telemetry/opentelemetry-proto") PROTOBUF_FILES.each do |file| system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto opentelemetry/proto/#{file}") end diff --git a/exporter/otlp-common/lib/opentelemetry/exporter/otlp/common.rb b/exporter/otlp-common/lib/opentelemetry/exporter/otlp/common.rb index 9a5ad0166b..4d17958183 100644 --- a/exporter/otlp-common/lib/opentelemetry/exporter/otlp/common.rb +++ b/exporter/otlp-common/lib/opentelemetry/exporter/otlp/common.rb @@ -52,11 +52,11 @@ def as_etsr(span_data) # rubocop:disable Metrics/MethodLength resource: Opentelemetry::Proto::Resource::V1::Resource.new( attributes: resource.attribute_enumerator.map { |key, value| as_otlp_key_value(key, value) } ), - instrumentation_library_spans: span_datas - .group_by(&:instrumentation_library) + scope_spans: span_datas + .group_by(&:instrumentation_scope) .map do |il, sds| - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: il.name, version: il.version ), diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb index f92a39cb89..645dfd21f8 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/logs/v1/logs_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/logs/v1/logs_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest" do diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb index 2850cb6094..98712758d0 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb @@ -30,7 +30,7 @@ module LogsService # case logs are sent/received to/from multiple Applications). class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb index 5a4fd99a59..56e3bbea69 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/metrics/v1/metrics_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/metrics/v1/metrics_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest" do diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb index 589c821a04..13be8cb414 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb @@ -30,7 +30,7 @@ module MetricsService # central collector. class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb index 8cfd05470b..a71fbf168a 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/trace/v1/trace_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/trace/v1/trace_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest" do diff --git a/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb index c9e92e7ea3..aa9a167155 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb @@ -30,7 +30,7 @@ module TraceService # case spans are sent/received to/from multiple Applications). class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp-common/lib/opentelemetry/proto/common/v1/common_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/common/v1/common_pb.rb index 4f735a1f64..006d3047d0 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/common/v1/common_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/common/v1/common_pb.rb @@ -26,14 +26,14 @@ optional :key, :string, 1 optional :value, :message, 2, "opentelemetry.proto.common.v1.AnyValue" end - add_message "opentelemetry.proto.common.v1.StringKeyValue" do - optional :key, :string, 1 - optional :value, :string, 2 - end add_message "opentelemetry.proto.common.v1.InstrumentationLibrary" do optional :name, :string, 1 optional :version, :string, 2 end + add_message "opentelemetry.proto.common.v1.InstrumentationScope" do + optional :name, :string, 1 + optional :version, :string, 2 + end end end @@ -45,8 +45,8 @@ module V1 ArrayValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.ArrayValue").msgclass KeyValueList = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.KeyValueList").msgclass KeyValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.KeyValue").msgclass - StringKeyValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.StringKeyValue").msgclass InstrumentationLibrary = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.InstrumentationLibrary").msgclass + InstrumentationScope = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.InstrumentationScope").msgclass end end end diff --git a/exporter/otlp-common/lib/opentelemetry/proto/logs/v1/logs_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/logs/v1/logs_pb.rb index 38010a5ffd..d6ea3cd664 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/logs/v1/logs_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/logs/v1/logs_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/logs/v1/logs.proto", :syntax => :proto3) do add_message "opentelemetry.proto.logs.v1.LogsData" do @@ -12,19 +13,25 @@ end add_message "opentelemetry.proto.logs.v1.ResourceLogs" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_logs, :message, 2, "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" + repeated :scope_logs, :message, 2, "opentelemetry.proto.logs.v1.ScopeLogs" + repeated :instrumentation_library_logs, :message, 1000, "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.logs.v1.ScopeLogs" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :log_records, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" do optional :instrumentation_library, :message, 1, "opentelemetry.proto.common.v1.InstrumentationLibrary" - repeated :logs, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" + repeated :log_records, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.logs.v1.LogRecord" do optional :time_unix_nano, :fixed64, 1 + optional :observed_time_unix_nano, :fixed64, 11 optional :severity_number, :enum, 2, "opentelemetry.proto.logs.v1.SeverityNumber" optional :severity_text, :string, 3 - optional :name, :string, 4 optional :body, :message, 5, "opentelemetry.proto.common.v1.AnyValue" repeated :attributes, :message, 6, "opentelemetry.proto.common.v1.KeyValue" optional :dropped_attributes_count, :uint32, 7 @@ -72,6 +79,7 @@ module Logs module V1 LogsData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.LogsData").msgclass ResourceLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.ResourceLogs").msgclass + ScopeLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.ScopeLogs").msgclass InstrumentationLibraryLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.InstrumentationLibraryLogs").msgclass LogRecord = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.LogRecord").msgclass SeverityNumber = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.SeverityNumber").enummodule diff --git a/exporter/otlp-common/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb deleted file mode 100644 index 0045124c05..0000000000 --- a/exporter/otlp-common/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: opentelemetry/proto/metrics/experimental/metrics_config_service.proto - -require 'google/protobuf' - -require 'opentelemetry/proto/resource/v1/resource_pb' -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("opentelemetry/proto/metrics/experimental/metrics_config_service.proto", :syntax => :proto3) do - add_message "opentelemetry.proto.metrics.experimental.MetricConfigRequest" do - optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - optional :last_known_fingerprint, :bytes, 2 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse" do - optional :fingerprint, :bytes, 1 - repeated :schedules, :message, 2, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule" - optional :suggested_wait_time_sec, :int32, 3 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule" do - repeated :exclusion_patterns, :message, 1, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" - repeated :inclusion_patterns, :message, 2, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" - optional :period_sec, :int32, 3 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" do - oneof :match do - optional :equals, :string, 1 - optional :starts_with, :string, 2 - end - end - end -end - -module Opentelemetry - module Proto - module Metrics - module Experimental - MetricConfigRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigRequest").msgclass - MetricConfigResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse").msgclass - MetricConfigResponse::Schedule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule").msgclass - MetricConfigResponse::Schedule::Pattern = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern").msgclass - end - end - end -end diff --git a/exporter/otlp-common/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb index 6d805afc8b..f85db6b9c1 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/metrics/v1/metrics.proto", :syntax => :proto3) do add_message "opentelemetry.proto.metrics.v1.MetricsData" do @@ -12,7 +13,13 @@ end add_message "opentelemetry.proto.metrics.v1.ResourceMetrics" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_metrics, :message, 2, "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" + repeated :scope_metrics, :message, 2, "opentelemetry.proto.metrics.v1.ScopeMetrics" + repeated :instrumentation_library_metrics, :message, 1000, "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.metrics.v1.ScopeMetrics" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :metrics, :message, 2, "opentelemetry.proto.metrics.v1.Metric" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" do @@ -25,11 +32,8 @@ optional :description, :string, 2 optional :unit, :string, 3 oneof :data do - optional :int_gauge, :message, 4, "opentelemetry.proto.metrics.v1.IntGauge" optional :gauge, :message, 5, "opentelemetry.proto.metrics.v1.Gauge" - optional :int_sum, :message, 6, "opentelemetry.proto.metrics.v1.IntSum" optional :sum, :message, 7, "opentelemetry.proto.metrics.v1.Sum" - optional :int_histogram, :message, 8, "opentelemetry.proto.metrics.v1.IntHistogram" optional :histogram, :message, 9, "opentelemetry.proto.metrics.v1.Histogram" optional :exponential_histogram, :message, 10, "opentelemetry.proto.metrics.v1.ExponentialHistogram" optional :summary, :message, 11, "opentelemetry.proto.metrics.v1.Summary" @@ -56,7 +60,6 @@ end add_message "opentelemetry.proto.metrics.v1.NumberDataPoint" do repeated :attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 repeated :exemplars, :message, 5, "opentelemetry.proto.metrics.v1.Exemplar" @@ -68,28 +71,31 @@ end add_message "opentelemetry.proto.metrics.v1.HistogramDataPoint" do repeated :attributes, :message, 9, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 - optional :sum, :double, 5 + proto3_optional :sum, :double, 5 repeated :bucket_counts, :fixed64, 6 repeated :explicit_bounds, :double, 7 repeated :exemplars, :message, 8, "opentelemetry.proto.metrics.v1.Exemplar" optional :flags, :uint32, 10 + proto3_optional :min, :double, 11 + proto3_optional :max, :double, 12 end add_message "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint" do repeated :attributes, :message, 1, "opentelemetry.proto.common.v1.KeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 - optional :sum, :double, 5 + proto3_optional :sum, :double, 5 optional :scale, :sint32, 6 optional :zero_count, :fixed64, 7 optional :positive, :message, 8, "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" optional :negative, :message, 9, "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" optional :flags, :uint32, 10 repeated :exemplars, :message, 11, "opentelemetry.proto.metrics.v1.Exemplar" + proto3_optional :min, :double, 12 + proto3_optional :max, :double, 13 end add_message "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" do optional :offset, :sint32, 1 @@ -97,7 +103,6 @@ end add_message "opentelemetry.proto.metrics.v1.SummaryDataPoint" do repeated :attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 @@ -111,7 +116,6 @@ end add_message "opentelemetry.proto.metrics.v1.Exemplar" do repeated :filtered_attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :filtered_labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :time_unix_nano, :fixed64, 2 optional :span_id, :bytes, 4 optional :trace_id, :bytes, 5 @@ -120,42 +124,6 @@ optional :as_int, :sfixed64, 6 end end - add_message "opentelemetry.proto.metrics.v1.IntDataPoint" do - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :start_time_unix_nano, :fixed64, 2 - optional :time_unix_nano, :fixed64, 3 - optional :value, :sfixed64, 4 - repeated :exemplars, :message, 5, "opentelemetry.proto.metrics.v1.IntExemplar" - end - add_message "opentelemetry.proto.metrics.v1.IntGauge" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntDataPoint" - end - add_message "opentelemetry.proto.metrics.v1.IntSum" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntDataPoint" - optional :aggregation_temporality, :enum, 2, "opentelemetry.proto.metrics.v1.AggregationTemporality" - optional :is_monotonic, :bool, 3 - end - add_message "opentelemetry.proto.metrics.v1.IntHistogramDataPoint" do - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :start_time_unix_nano, :fixed64, 2 - optional :time_unix_nano, :fixed64, 3 - optional :count, :fixed64, 4 - optional :sum, :sfixed64, 5 - repeated :bucket_counts, :fixed64, 6 - repeated :explicit_bounds, :double, 7 - repeated :exemplars, :message, 8, "opentelemetry.proto.metrics.v1.IntExemplar" - end - add_message "opentelemetry.proto.metrics.v1.IntHistogram" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntHistogramDataPoint" - optional :aggregation_temporality, :enum, 2, "opentelemetry.proto.metrics.v1.AggregationTemporality" - end - add_message "opentelemetry.proto.metrics.v1.IntExemplar" do - repeated :filtered_labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :time_unix_nano, :fixed64, 2 - optional :value, :sfixed64, 3 - optional :span_id, :bytes, 4 - optional :trace_id, :bytes, 5 - end add_enum "opentelemetry.proto.metrics.v1.AggregationTemporality" do value :AGGREGATION_TEMPORALITY_UNSPECIFIED, 0 value :AGGREGATION_TEMPORALITY_DELTA, 1 @@ -174,6 +142,7 @@ module Metrics module V1 MetricsData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.MetricsData").msgclass ResourceMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.ResourceMetrics").msgclass + ScopeMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.ScopeMetrics").msgclass InstrumentationLibraryMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics").msgclass Metric = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Metric").msgclass Gauge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Gauge").msgclass @@ -188,12 +157,6 @@ module V1 SummaryDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.SummaryDataPoint").msgclass SummaryDataPoint::ValueAtQuantile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.SummaryDataPoint.ValueAtQuantile").msgclass Exemplar = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Exemplar").msgclass - IntDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntDataPoint").msgclass - IntGauge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntGauge").msgclass - IntSum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntSum").msgclass - IntHistogramDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntHistogramDataPoint").msgclass - IntHistogram = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntHistogram").msgclass - IntExemplar = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntExemplar").msgclass AggregationTemporality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.AggregationTemporality").enummodule DataPointFlags = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.DataPointFlags").enummodule end diff --git a/exporter/otlp-common/lib/opentelemetry/proto/resource/v1/resource_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/resource/v1/resource_pb.rb index 7c0d53e6ee..a10d5ad1f5 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/resource/v1/resource_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/resource/v1/resource_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/common/v1/common_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/resource/v1/resource.proto", :syntax => :proto3) do add_message "opentelemetry.proto.resource.v1.Resource" do diff --git a/exporter/otlp-common/lib/opentelemetry/proto/trace/v1/trace_pb.rb b/exporter/otlp-common/lib/opentelemetry/proto/trace/v1/trace_pb.rb index 72a63a813c..e06a34c0bf 100644 --- a/exporter/otlp-common/lib/opentelemetry/proto/trace/v1/trace_pb.rb +++ b/exporter/otlp-common/lib/opentelemetry/proto/trace/v1/trace_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/trace/v1/trace.proto", :syntax => :proto3) do add_message "opentelemetry.proto.trace.v1.TracesData" do @@ -12,7 +13,13 @@ end add_message "opentelemetry.proto.trace.v1.ResourceSpans" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_spans, :message, 2, "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" + repeated :scope_spans, :message, 2, "opentelemetry.proto.trace.v1.ScopeSpans" + repeated :instrumentation_library_spans, :message, 1000, "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.trace.v1.ScopeSpans" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :spans, :message, 2, "opentelemetry.proto.trace.v1.Span" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" do @@ -59,29 +66,9 @@ value :SPAN_KIND_CONSUMER, 5 end add_message "opentelemetry.proto.trace.v1.Status" do - optional :deprecated_code, :enum, 1, "opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode" optional :message, :string, 2 optional :code, :enum, 3, "opentelemetry.proto.trace.v1.Status.StatusCode" end - add_enum "opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode" do - value :DEPRECATED_STATUS_CODE_OK, 0 - value :DEPRECATED_STATUS_CODE_CANCELLED, 1 - value :DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, 2 - value :DEPRECATED_STATUS_CODE_INVALID_ARGUMENT, 3 - value :DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED, 4 - value :DEPRECATED_STATUS_CODE_NOT_FOUND, 5 - value :DEPRECATED_STATUS_CODE_ALREADY_EXISTS, 6 - value :DEPRECATED_STATUS_CODE_PERMISSION_DENIED, 7 - value :DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED, 8 - value :DEPRECATED_STATUS_CODE_FAILED_PRECONDITION, 9 - value :DEPRECATED_STATUS_CODE_ABORTED, 10 - value :DEPRECATED_STATUS_CODE_OUT_OF_RANGE, 11 - value :DEPRECATED_STATUS_CODE_UNIMPLEMENTED, 12 - value :DEPRECATED_STATUS_CODE_INTERNAL_ERROR, 13 - value :DEPRECATED_STATUS_CODE_UNAVAILABLE, 14 - value :DEPRECATED_STATUS_CODE_DATA_LOSS, 15 - value :DEPRECATED_STATUS_CODE_UNAUTHENTICATED, 16 - end add_enum "opentelemetry.proto.trace.v1.Status.StatusCode" do value :STATUS_CODE_UNSET, 0 value :STATUS_CODE_OK, 1 @@ -96,13 +83,13 @@ module Trace module V1 TracesData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.TracesData").msgclass ResourceSpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ResourceSpans").msgclass + ScopeSpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ScopeSpans").msgclass InstrumentationLibrarySpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.InstrumentationLibrarySpans").msgclass Span = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span").msgclass Span::Event = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.Event").msgclass Span::Link = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.Link").msgclass Span::SpanKind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.SpanKind").enummodule Status = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status").msgclass - Status::DeprecatedStatusCode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode").enummodule Status::StatusCode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status.StatusCode").enummodule end end diff --git a/exporter/otlp-common/test/opentelemetry/exporter/otlp/common/common_test.rb b/exporter/otlp-common/test/opentelemetry/exporter/otlp/common/common_test.rb index f3d7ab56f8..ea0635ff12 100644 --- a/exporter/otlp-common/test/opentelemetry/exporter/otlp/common/common_test.rb +++ b/exporter/otlp-common/test/opentelemetry/exporter/otlp/common/common_test.rb @@ -36,8 +36,8 @@ etsr = OpenTelemetry::Exporter::OTLP::Common.as_etsr([span_data1, span_data2, span_data3]) _(etsr.resource_spans.length).must_equal(2) - _(etsr.resource_spans[0].instrumentation_library_spans[0].spans.length).must_equal(1) - _(etsr.resource_spans[1].instrumentation_library_spans[0].spans.length).must_equal(2) + _(etsr.resource_spans[0].scope_spans[0].spans.length).must_equal(1) + _(etsr.resource_spans[1].scope_spans[0].spans.length).must_equal(2) end it 'translates all the things' do @@ -98,9 +98,9 @@ Opentelemetry::Proto::Common::V1::KeyValue.new(key: 'telemetry.sdk.version', value: Opentelemetry::Proto::Common::V1::AnyValue.new(string_value: OpenTelemetry::SDK::VERSION)) ] ), - instrumentation_library_spans: [ - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + scope_spans: [ + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'tracer', version: 'v0.0.1' ), @@ -190,8 +190,8 @@ ) ] ), - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'other_tracer' ), spans: [ diff --git a/exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb b/exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb index 2aa3686be2..5c04745ea2 100644 --- a/exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb +++ b/exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb @@ -514,9 +514,9 @@ Opentelemetry::Proto::Common::V1::KeyValue.new(key: 'telemetry.sdk.version', value: Opentelemetry::Proto::Common::V1::AnyValue.new(string_value: OpenTelemetry::SDK::VERSION)) ] ), - instrumentation_library_spans: [ - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + scope_spans: [ + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'tracer', version: 'v0.0.1' ), @@ -606,8 +606,8 @@ ) ] ), - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'other_tracer' ), spans: [ diff --git a/exporter/otlp/Rakefile b/exporter/otlp/Rakefile index 511f7665d9..637f7132f8 100644 --- a/exporter/otlp/Rakefile +++ b/exporter/otlp/Rakefile @@ -29,15 +29,21 @@ else task default: %i[test rubocop yard] end +PROTO_VERSION = 'v0.18.0' PROTOBUF_FILES = [ + 'collector/logs/v1/logs_service.proto', + 'collector/metrics/v1/metrics_service.proto', + 'collector/trace/v1/trace_service.proto', 'common/v1/common.proto', + 'logs/v1/logs.proto', + 'metrics/v1/metrics.proto', 'resource/v1/resource.proto', 'trace/v1/trace.proto', - 'collector/trace/v1/trace_service.proto' + 'trace/v1/trace_config.proto' ].freeze task :update_protobuf do - system('git clone /~https://github.com/open-telemetry/opentelemetry-proto') + system("git clone -b #{PROTO_VERSION} /~https://github.com/open-telemetry/opentelemetry-proto") PROTOBUF_FILES.each do |file| system("protoc --ruby_out=lib/ --proto_path=opentelemetry-proto opentelemetry/proto/#{file}") end diff --git a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb index 9cb3142f39..987319d5f0 100644 --- a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb +++ b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb @@ -284,11 +284,11 @@ def encode(span_data) # rubocop:disable Metrics/MethodLength resource: Opentelemetry::Proto::Resource::V1::Resource.new( attributes: resource.attribute_enumerator.map { |key, value| as_otlp_key_value(key, value) } ), - instrumentation_library_spans: span_datas - .group_by(&:instrumentation_library) + scope_spans: span_datas + .group_by(&:instrumentation_scope) .map do |il, sds| - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: il.name, version: il.version ), diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb index f92a39cb89..645dfd21f8 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/logs/v1/logs_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/logs/v1/logs_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest" do diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb index 2850cb6094..98712758d0 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/logs/v1/logs_service_services_pb.rb @@ -30,7 +30,7 @@ module LogsService # case logs are sent/received to/from multiple Applications). class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb index 5a4fd99a59..56e3bbea69 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/metrics/v1/metrics_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/metrics/v1/metrics_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest" do diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb index 589c821a04..13be8cb414 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/metrics/v1/metrics_service_services_pb.rb @@ -30,7 +30,7 @@ module MetricsService # central collector. class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb index 8cfd05470b..a71fbf168a 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/trace/v1/trace_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/collector/trace/v1/trace_service.proto", :syntax => :proto3) do add_message "opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest" do diff --git a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb b/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb index c9e92e7ea3..aa9a167155 100644 --- a/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/collector/trace/v1/trace_service_services_pb.rb @@ -30,7 +30,7 @@ module TraceService # case spans are sent/received to/from multiple Applications). class Service - include GRPC::GenericService + include ::GRPC::GenericService self.marshal_class_method = :encode self.unmarshal_class_method = :decode diff --git a/exporter/otlp/lib/opentelemetry/proto/common/v1/common_pb.rb b/exporter/otlp/lib/opentelemetry/proto/common/v1/common_pb.rb index 4f735a1f64..006d3047d0 100644 --- a/exporter/otlp/lib/opentelemetry/proto/common/v1/common_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/common/v1/common_pb.rb @@ -26,14 +26,14 @@ optional :key, :string, 1 optional :value, :message, 2, "opentelemetry.proto.common.v1.AnyValue" end - add_message "opentelemetry.proto.common.v1.StringKeyValue" do - optional :key, :string, 1 - optional :value, :string, 2 - end add_message "opentelemetry.proto.common.v1.InstrumentationLibrary" do optional :name, :string, 1 optional :version, :string, 2 end + add_message "opentelemetry.proto.common.v1.InstrumentationScope" do + optional :name, :string, 1 + optional :version, :string, 2 + end end end @@ -45,8 +45,8 @@ module V1 ArrayValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.ArrayValue").msgclass KeyValueList = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.KeyValueList").msgclass KeyValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.KeyValue").msgclass - StringKeyValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.StringKeyValue").msgclass InstrumentationLibrary = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.InstrumentationLibrary").msgclass + InstrumentationScope = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.common.v1.InstrumentationScope").msgclass end end end diff --git a/exporter/otlp/lib/opentelemetry/proto/logs/v1/logs_pb.rb b/exporter/otlp/lib/opentelemetry/proto/logs/v1/logs_pb.rb index 38010a5ffd..d6ea3cd664 100644 --- a/exporter/otlp/lib/opentelemetry/proto/logs/v1/logs_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/logs/v1/logs_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/logs/v1/logs.proto", :syntax => :proto3) do add_message "opentelemetry.proto.logs.v1.LogsData" do @@ -12,19 +13,25 @@ end add_message "opentelemetry.proto.logs.v1.ResourceLogs" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_logs, :message, 2, "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" + repeated :scope_logs, :message, 2, "opentelemetry.proto.logs.v1.ScopeLogs" + repeated :instrumentation_library_logs, :message, 1000, "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.logs.v1.ScopeLogs" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :log_records, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.logs.v1.InstrumentationLibraryLogs" do optional :instrumentation_library, :message, 1, "opentelemetry.proto.common.v1.InstrumentationLibrary" - repeated :logs, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" + repeated :log_records, :message, 2, "opentelemetry.proto.logs.v1.LogRecord" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.logs.v1.LogRecord" do optional :time_unix_nano, :fixed64, 1 + optional :observed_time_unix_nano, :fixed64, 11 optional :severity_number, :enum, 2, "opentelemetry.proto.logs.v1.SeverityNumber" optional :severity_text, :string, 3 - optional :name, :string, 4 optional :body, :message, 5, "opentelemetry.proto.common.v1.AnyValue" repeated :attributes, :message, 6, "opentelemetry.proto.common.v1.KeyValue" optional :dropped_attributes_count, :uint32, 7 @@ -72,6 +79,7 @@ module Logs module V1 LogsData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.LogsData").msgclass ResourceLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.ResourceLogs").msgclass + ScopeLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.ScopeLogs").msgclass InstrumentationLibraryLogs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.InstrumentationLibraryLogs").msgclass LogRecord = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.LogRecord").msgclass SeverityNumber = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.logs.v1.SeverityNumber").enummodule diff --git a/exporter/otlp/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb b/exporter/otlp/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb deleted file mode 100644 index 0045124c05..0000000000 --- a/exporter/otlp/lib/opentelemetry/proto/metrics/experimental/metrics_config_service_pb.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: opentelemetry/proto/metrics/experimental/metrics_config_service.proto - -require 'google/protobuf' - -require 'opentelemetry/proto/resource/v1/resource_pb' -Google::Protobuf::DescriptorPool.generated_pool.build do - add_file("opentelemetry/proto/metrics/experimental/metrics_config_service.proto", :syntax => :proto3) do - add_message "opentelemetry.proto.metrics.experimental.MetricConfigRequest" do - optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - optional :last_known_fingerprint, :bytes, 2 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse" do - optional :fingerprint, :bytes, 1 - repeated :schedules, :message, 2, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule" - optional :suggested_wait_time_sec, :int32, 3 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule" do - repeated :exclusion_patterns, :message, 1, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" - repeated :inclusion_patterns, :message, 2, "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" - optional :period_sec, :int32, 3 - end - add_message "opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern" do - oneof :match do - optional :equals, :string, 1 - optional :starts_with, :string, 2 - end - end - end -end - -module Opentelemetry - module Proto - module Metrics - module Experimental - MetricConfigRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigRequest").msgclass - MetricConfigResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse").msgclass - MetricConfigResponse::Schedule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule").msgclass - MetricConfigResponse::Schedule::Pattern = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.experimental.MetricConfigResponse.Schedule.Pattern").msgclass - end - end - end -end diff --git a/exporter/otlp/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb b/exporter/otlp/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb index 6d805afc8b..f85db6b9c1 100644 --- a/exporter/otlp/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/metrics/v1/metrics_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/metrics/v1/metrics.proto", :syntax => :proto3) do add_message "opentelemetry.proto.metrics.v1.MetricsData" do @@ -12,7 +13,13 @@ end add_message "opentelemetry.proto.metrics.v1.ResourceMetrics" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_metrics, :message, 2, "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" + repeated :scope_metrics, :message, 2, "opentelemetry.proto.metrics.v1.ScopeMetrics" + repeated :instrumentation_library_metrics, :message, 1000, "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.metrics.v1.ScopeMetrics" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :metrics, :message, 2, "opentelemetry.proto.metrics.v1.Metric" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics" do @@ -25,11 +32,8 @@ optional :description, :string, 2 optional :unit, :string, 3 oneof :data do - optional :int_gauge, :message, 4, "opentelemetry.proto.metrics.v1.IntGauge" optional :gauge, :message, 5, "opentelemetry.proto.metrics.v1.Gauge" - optional :int_sum, :message, 6, "opentelemetry.proto.metrics.v1.IntSum" optional :sum, :message, 7, "opentelemetry.proto.metrics.v1.Sum" - optional :int_histogram, :message, 8, "opentelemetry.proto.metrics.v1.IntHistogram" optional :histogram, :message, 9, "opentelemetry.proto.metrics.v1.Histogram" optional :exponential_histogram, :message, 10, "opentelemetry.proto.metrics.v1.ExponentialHistogram" optional :summary, :message, 11, "opentelemetry.proto.metrics.v1.Summary" @@ -56,7 +60,6 @@ end add_message "opentelemetry.proto.metrics.v1.NumberDataPoint" do repeated :attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 repeated :exemplars, :message, 5, "opentelemetry.proto.metrics.v1.Exemplar" @@ -68,28 +71,31 @@ end add_message "opentelemetry.proto.metrics.v1.HistogramDataPoint" do repeated :attributes, :message, 9, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 - optional :sum, :double, 5 + proto3_optional :sum, :double, 5 repeated :bucket_counts, :fixed64, 6 repeated :explicit_bounds, :double, 7 repeated :exemplars, :message, 8, "opentelemetry.proto.metrics.v1.Exemplar" optional :flags, :uint32, 10 + proto3_optional :min, :double, 11 + proto3_optional :max, :double, 12 end add_message "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint" do repeated :attributes, :message, 1, "opentelemetry.proto.common.v1.KeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 - optional :sum, :double, 5 + proto3_optional :sum, :double, 5 optional :scale, :sint32, 6 optional :zero_count, :fixed64, 7 optional :positive, :message, 8, "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" optional :negative, :message, 9, "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" optional :flags, :uint32, 10 repeated :exemplars, :message, 11, "opentelemetry.proto.metrics.v1.Exemplar" + proto3_optional :min, :double, 12 + proto3_optional :max, :double, 13 end add_message "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets" do optional :offset, :sint32, 1 @@ -97,7 +103,6 @@ end add_message "opentelemetry.proto.metrics.v1.SummaryDataPoint" do repeated :attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :start_time_unix_nano, :fixed64, 2 optional :time_unix_nano, :fixed64, 3 optional :count, :fixed64, 4 @@ -111,7 +116,6 @@ end add_message "opentelemetry.proto.metrics.v1.Exemplar" do repeated :filtered_attributes, :message, 7, "opentelemetry.proto.common.v1.KeyValue" - repeated :filtered_labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" optional :time_unix_nano, :fixed64, 2 optional :span_id, :bytes, 4 optional :trace_id, :bytes, 5 @@ -120,42 +124,6 @@ optional :as_int, :sfixed64, 6 end end - add_message "opentelemetry.proto.metrics.v1.IntDataPoint" do - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :start_time_unix_nano, :fixed64, 2 - optional :time_unix_nano, :fixed64, 3 - optional :value, :sfixed64, 4 - repeated :exemplars, :message, 5, "opentelemetry.proto.metrics.v1.IntExemplar" - end - add_message "opentelemetry.proto.metrics.v1.IntGauge" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntDataPoint" - end - add_message "opentelemetry.proto.metrics.v1.IntSum" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntDataPoint" - optional :aggregation_temporality, :enum, 2, "opentelemetry.proto.metrics.v1.AggregationTemporality" - optional :is_monotonic, :bool, 3 - end - add_message "opentelemetry.proto.metrics.v1.IntHistogramDataPoint" do - repeated :labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :start_time_unix_nano, :fixed64, 2 - optional :time_unix_nano, :fixed64, 3 - optional :count, :fixed64, 4 - optional :sum, :sfixed64, 5 - repeated :bucket_counts, :fixed64, 6 - repeated :explicit_bounds, :double, 7 - repeated :exemplars, :message, 8, "opentelemetry.proto.metrics.v1.IntExemplar" - end - add_message "opentelemetry.proto.metrics.v1.IntHistogram" do - repeated :data_points, :message, 1, "opentelemetry.proto.metrics.v1.IntHistogramDataPoint" - optional :aggregation_temporality, :enum, 2, "opentelemetry.proto.metrics.v1.AggregationTemporality" - end - add_message "opentelemetry.proto.metrics.v1.IntExemplar" do - repeated :filtered_labels, :message, 1, "opentelemetry.proto.common.v1.StringKeyValue" - optional :time_unix_nano, :fixed64, 2 - optional :value, :sfixed64, 3 - optional :span_id, :bytes, 4 - optional :trace_id, :bytes, 5 - end add_enum "opentelemetry.proto.metrics.v1.AggregationTemporality" do value :AGGREGATION_TEMPORALITY_UNSPECIFIED, 0 value :AGGREGATION_TEMPORALITY_DELTA, 1 @@ -174,6 +142,7 @@ module Metrics module V1 MetricsData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.MetricsData").msgclass ResourceMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.ResourceMetrics").msgclass + ScopeMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.ScopeMetrics").msgclass InstrumentationLibraryMetrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.InstrumentationLibraryMetrics").msgclass Metric = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Metric").msgclass Gauge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Gauge").msgclass @@ -188,12 +157,6 @@ module V1 SummaryDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.SummaryDataPoint").msgclass SummaryDataPoint::ValueAtQuantile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.SummaryDataPoint.ValueAtQuantile").msgclass Exemplar = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.Exemplar").msgclass - IntDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntDataPoint").msgclass - IntGauge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntGauge").msgclass - IntSum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntSum").msgclass - IntHistogramDataPoint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntHistogramDataPoint").msgclass - IntHistogram = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntHistogram").msgclass - IntExemplar = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.IntExemplar").msgclass AggregationTemporality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.AggregationTemporality").enummodule DataPointFlags = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.metrics.v1.DataPointFlags").enummodule end diff --git a/exporter/otlp/lib/opentelemetry/proto/resource/v1/resource_pb.rb b/exporter/otlp/lib/opentelemetry/proto/resource/v1/resource_pb.rb index 7c0d53e6ee..a10d5ad1f5 100644 --- a/exporter/otlp/lib/opentelemetry/proto/resource/v1/resource_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/resource/v1/resource_pb.rb @@ -4,6 +4,7 @@ require 'google/protobuf' require 'opentelemetry/proto/common/v1/common_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/resource/v1/resource.proto", :syntax => :proto3) do add_message "opentelemetry.proto.resource.v1.Resource" do diff --git a/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_pb.rb b/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_pb.rb index 72a63a813c..e06a34c0bf 100644 --- a/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_pb.rb +++ b/exporter/otlp/lib/opentelemetry/proto/trace/v1/trace_pb.rb @@ -5,6 +5,7 @@ require 'opentelemetry/proto/common/v1/common_pb' require 'opentelemetry/proto/resource/v1/resource_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("opentelemetry/proto/trace/v1/trace.proto", :syntax => :proto3) do add_message "opentelemetry.proto.trace.v1.TracesData" do @@ -12,7 +13,13 @@ end add_message "opentelemetry.proto.trace.v1.ResourceSpans" do optional :resource, :message, 1, "opentelemetry.proto.resource.v1.Resource" - repeated :instrumentation_library_spans, :message, 2, "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" + repeated :scope_spans, :message, 2, "opentelemetry.proto.trace.v1.ScopeSpans" + repeated :instrumentation_library_spans, :message, 1000, "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" + optional :schema_url, :string, 3 + end + add_message "opentelemetry.proto.trace.v1.ScopeSpans" do + optional :scope, :message, 1, "opentelemetry.proto.common.v1.InstrumentationScope" + repeated :spans, :message, 2, "opentelemetry.proto.trace.v1.Span" optional :schema_url, :string, 3 end add_message "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans" do @@ -59,29 +66,9 @@ value :SPAN_KIND_CONSUMER, 5 end add_message "opentelemetry.proto.trace.v1.Status" do - optional :deprecated_code, :enum, 1, "opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode" optional :message, :string, 2 optional :code, :enum, 3, "opentelemetry.proto.trace.v1.Status.StatusCode" end - add_enum "opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode" do - value :DEPRECATED_STATUS_CODE_OK, 0 - value :DEPRECATED_STATUS_CODE_CANCELLED, 1 - value :DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, 2 - value :DEPRECATED_STATUS_CODE_INVALID_ARGUMENT, 3 - value :DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED, 4 - value :DEPRECATED_STATUS_CODE_NOT_FOUND, 5 - value :DEPRECATED_STATUS_CODE_ALREADY_EXISTS, 6 - value :DEPRECATED_STATUS_CODE_PERMISSION_DENIED, 7 - value :DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED, 8 - value :DEPRECATED_STATUS_CODE_FAILED_PRECONDITION, 9 - value :DEPRECATED_STATUS_CODE_ABORTED, 10 - value :DEPRECATED_STATUS_CODE_OUT_OF_RANGE, 11 - value :DEPRECATED_STATUS_CODE_UNIMPLEMENTED, 12 - value :DEPRECATED_STATUS_CODE_INTERNAL_ERROR, 13 - value :DEPRECATED_STATUS_CODE_UNAVAILABLE, 14 - value :DEPRECATED_STATUS_CODE_DATA_LOSS, 15 - value :DEPRECATED_STATUS_CODE_UNAUTHENTICATED, 16 - end add_enum "opentelemetry.proto.trace.v1.Status.StatusCode" do value :STATUS_CODE_UNSET, 0 value :STATUS_CODE_OK, 1 @@ -96,13 +83,13 @@ module Trace module V1 TracesData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.TracesData").msgclass ResourceSpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ResourceSpans").msgclass + ScopeSpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.ScopeSpans").msgclass InstrumentationLibrarySpans = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.InstrumentationLibrarySpans").msgclass Span = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span").msgclass Span::Event = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.Event").msgclass Span::Link = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.Link").msgclass Span::SpanKind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Span.SpanKind").enummodule Status = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status").msgclass - Status::DeprecatedStatusCode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status.DeprecatedStatusCode").enummodule Status::StatusCode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("opentelemetry.proto.trace.v1.Status.StatusCode").enummodule end end diff --git a/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb b/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb index 0cac50f983..042c364595 100644 --- a/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb +++ b/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb @@ -551,9 +551,9 @@ Opentelemetry::Proto::Common::V1::KeyValue.new(key: 'telemetry.sdk.version', value: Opentelemetry::Proto::Common::V1::AnyValue.new(string_value: OpenTelemetry::SDK::VERSION)) ] ), - instrumentation_library_spans: [ - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + scope_spans: [ + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'tracer', version: 'v0.0.1' ), @@ -643,8 +643,8 @@ ) ] ), - Opentelemetry::Proto::Trace::V1::InstrumentationLibrarySpans.new( - instrumentation_library: Opentelemetry::Proto::Common::V1::InstrumentationLibrary.new( + Opentelemetry::Proto::Trace::V1::ScopeSpans.new( + scope: Opentelemetry::Proto::Common::V1::InstrumentationScope.new( name: 'other_tracer' ), spans: [ diff --git a/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb b/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb index 11552ce109..25a5fdd6bd 100644 --- a/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb +++ b/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb @@ -46,7 +46,7 @@ def to_zipkin_span(span_d, resource) 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) @@ -70,9 +70,12 @@ def to_zipkin_span(span_d, resource) 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) diff --git a/exporter/zipkin/test/opentelemetry/exporters/zipkin/exporter_test.rb b/exporter/zipkin/test/opentelemetry/exporters/zipkin/exporter_test.rb index 680feca319..f324309452 100644 --- a/exporter/zipkin/test/opentelemetry/exporters/zipkin/exporter_test.rb +++ b/exporter/zipkin/test/opentelemetry/exporters/zipkin/exporter_test.rb @@ -148,11 +148,11 @@ def create_resource_span_data(name: '', kind: nil, status: nil, parent_span_id: OpenTelemetry::Trace::INVALID_SPAN_ID, total_recorded_attributes: 0, total_recorded_events: 0, total_recorded_links: 0, start_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, end_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, attributes: nil, links: nil, events: nil, resource: nil, - instrumentation_library: OpenTelemetry::SDK::InstrumentationLibrary.new('', 'v0.0.1'), + instrumentation_scope: OpenTelemetry::SDK::InstrumentationScope.new('', 'v0.0.1'), span_id: OpenTelemetry::Trace.generate_span_id, trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) resource ||= OpenTelemetry::SDK::Resources::Resource.telemetry_sdk OpenTelemetry::SDK::Trace::SpanData.new(name, kind, status, parent_span_id, total_recorded_attributes, total_recorded_events, total_recorded_links, start_timestamp, end_timestamp, - attributes, links, events, resource, instrumentation_library, span_id, trace_id, trace_flags, tracestate) + attributes, links, events, resource, instrumentation_scope, span_id, trace_id, trace_flags, tracestate) end diff --git a/exporter/zipkin/test/opentelemetry/exporters/zipkin/transformer_test.rb b/exporter/zipkin/test/opentelemetry/exporters/zipkin/transformer_test.rb index 6ac937e8eb..d598775eaf 100644 --- a/exporter/zipkin/test/opentelemetry/exporters/zipkin/transformer_test.rb +++ b/exporter/zipkin/test/opentelemetry/exporters/zipkin/transformer_test.rb @@ -13,7 +13,13 @@ encoded_span = Transformer.to_zipkin_span(create_span_data(attributes: { 'bar' => 'baz' }), resource) _(encoded_span[:name]).must_equal('') _(encoded_span['localEndpoint']['serviceName']).must_equal('foo') - _(encoded_span['tags']).must_equal('bar' => 'baz', 'otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(encoded_span['tags']).must_equal( + 'bar' => 'baz', + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end it 'encodes span.status and span.kind' do @@ -22,7 +28,7 @@ encoded_span = Transformer.to_zipkin_span(span_data, resource) - _(encoded_span['tags'].size).must_equal(5) + _(encoded_span['tags'].size).must_equal(7) kind_tag = encoded_span['kind'] error_tag = encoded_span['tags']['error'] @@ -56,7 +62,14 @@ _(annotation_two[:value]).must_equal('event_no_attrib') tags = encoded_span['tags'] - _(tags).must_equal('akey' => 'avalue', 'bar' => 'baz', 'otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(tags).must_equal( + 'akey' => 'avalue', + 'bar' => 'baz', + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end it 'records dropped attribute, event, and links counts when things were dropped' do @@ -66,7 +79,9 @@ tags = encoded_span['tags'] _(tags).must_equal( 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib', 'otel.dropped_attributes_count' => '1', 'otel.dropped_events_count' => '1', 'otel.dropped_links_count' => '1' @@ -78,7 +93,12 @@ span_data = create_span_data encoded_span = Transformer.to_zipkin_span(span_data, resource) tags = encoded_span['tags'] - _(tags).must_equal('otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(tags).must_equal( + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end it 'encodes array attribute values in events and the span as JSON strings' do @@ -99,7 +119,14 @@ _(annotation_one[:value]).must_equal({ 'event_with_attribs' => { 'ekey' => '["evalue"]' } }.to_json) tags = encoded_span['tags'] - _(tags).must_equal('akey' => ['avalue'].to_s, 'bar' => 'baz', 'otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(tags).must_equal( + 'akey' => ['avalue'].to_s, + 'bar' => 'baz', + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end describe 'status' do @@ -111,7 +138,14 @@ encoded_span = Transformer.to_zipkin_span(span_data, resource) tags = encoded_span['tags'] - _(tags).must_equal('otel.status_code' => 'OK', 'bar' => 'baz', 'otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(tags).must_equal( + 'otel.status_code' => 'OK', + 'bar' => 'baz', + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end it 'encodes error status code as strings on error tag and status description field' do @@ -122,29 +156,40 @@ encoded_span = Transformer.to_zipkin_span(span_data, resource) tags = encoded_span['tags'] - _(tags).must_equal('error' => error_description, 'otel.status_code' => 'ERROR', 'bar' => 'baz', 'otel.library.version' => '0.0.0', 'otel.library.name' => 'vendorlib') + _(tags).must_equal( + 'error' => error_description, + 'otel.status_code' => 'ERROR', + 'bar' => 'baz', + 'otel.library.version' => '0.0.0', + 'otel.scope.version' => '0.0.0', + 'otel.library.name' => 'vendorlib', + 'otel.scope.name' => 'vendorlib' + ) end end - describe 'instrumentation library' do + describe 'instrumentation scope' do it 'encodes library and version when set' do - lib = OpenTelemetry::SDK::InstrumentationLibrary.new('mylib', '0.1.0') + lib = OpenTelemetry::SDK::InstrumentationScope.new('mylib', '0.1.0') resource = OpenTelemetry::SDK::Resources::Resource.create('service.name' => 'foo') - span_data = create_span_data(attributes: { 'bar' => 'baz' }, instrumentation_library: lib) + span_data = create_span_data(attributes: { 'bar' => 'baz' }, instrumentation_scope: lib) encoded_span = Transformer.to_zipkin_span(span_data, resource) - _(encoded_span['tags'].size).must_equal(3) + _(encoded_span['tags'].size).must_equal(5) + _(encoded_span['tags']['otel.scope.name']).must_equal('mylib') _(encoded_span['tags']['otel.library.name']).must_equal('mylib') + _(encoded_span['tags']['otel.scope.version']).must_equal('0.1.0') _(encoded_span['tags']['otel.library.version']).must_equal('0.1.0') end it 'skips nil values' do - lib = OpenTelemetry::SDK::InstrumentationLibrary.new('mylib') + lib = OpenTelemetry::SDK::InstrumentationScope.new('mylib') resource = OpenTelemetry::SDK::Resources::Resource.create('service.name' => 'foo') - span_data = create_span_data(attributes: { 'bar' => 'baz' }, instrumentation_library: lib) + span_data = create_span_data(attributes: { 'bar' => 'baz' }, instrumentation_scope: lib) encoded_span = Transformer.to_zipkin_span(span_data, resource) - _(encoded_span['tags'].size).must_equal(3) + _(encoded_span['tags'].size).must_equal(5) + _(encoded_span['tags']['otel.scope.name']).must_equal('mylib') _(encoded_span['tags']['otel.library.name']).must_equal('mylib') end end diff --git a/exporter/zipkin/test/test_helper.rb b/exporter/zipkin/test/test_helper.rb index 73122c2346..b49479e116 100644 --- a/exporter/zipkin/test/test_helper.rb +++ b/exporter/zipkin/test/test_helper.rb @@ -12,7 +12,7 @@ require 'minitest/autorun' require 'webmock/minitest' -def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_attributes: 0, events: nil, total_recorded_events: 0, links: nil, total_recorded_links: 0, instrumentation_library: OpenTelemetry::SDK::InstrumentationLibrary.new('vendorlib', '0.0.0'), trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) +def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_attributes: 0, events: nil, total_recorded_events: 0, links: nil, total_recorded_links: 0, instrumentation_scope: OpenTelemetry::SDK::InstrumentationScope.new('vendorlib', '0.0.0'), trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) OpenTelemetry::SDK::Trace::SpanData.new( '', kind, @@ -27,7 +27,7 @@ def create_span_data(status: nil, kind: nil, attributes: nil, total_recorded_att links, events, nil, - instrumentation_library, + instrumentation_scope, OpenTelemetry::Trace.generate_span_id, trace_id, trace_flags, diff --git a/metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb b/metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb index 0080186fd9..7f7912c059 100644 --- a/metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb +++ b/metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb @@ -11,11 +11,11 @@ module Instrument # {SynchronousInstrument} contains the common functionality shared across # the synchronous instruments SDK instruments. class SynchronousInstrument - def initialize(name, unit, description, instrumentation_library, meter_provider) + def initialize(name, unit, description, instrumentation_scope, meter_provider) @name = name @unit = unit @description = description - @instrumentation_library = instrumentation_library + @instrumentation_scope = instrumentation_scope @meter_provider = meter_provider @metric_streams = [] @@ -32,7 +32,7 @@ def register_with_new_metric_store(metric_store) @unit, instrument_kind, @meter_provider, - @instrumentation_library + @instrumentation_scope ) @metric_streams << ms metric_store.add_metric_stream(ms) diff --git a/metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb b/metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb index f4355f1168..faf8e9adb1 100644 --- a/metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb +++ b/metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb @@ -22,7 +22,7 @@ class Meter < OpenTelemetry::Metrics::Meter def initialize(name, version, meter_provider) @mutex = Mutex.new @instrument_registry = {} - @instrumentation_library = InstrumentationLibrary.new(name, version) + @instrumentation_scope = InstrumentationScope.new(name, version) @meter_provider = meter_provider end @@ -36,12 +36,12 @@ def add_metric_reader(metric_reader) def create_instrument(kind, name, unit, description, callback) super do case kind - when :counter then OpenTelemetry::SDK::Metrics::Instrument::Counter.new(name, unit, description, @instrumentation_library, @meter_provider) - when :observable_counter then OpenTelemetry::SDK::Metrics::Instrument::ObservableCounter.new(name, unit, description, callback, @instrumentation_library, @meter_provider) - when :histogram then OpenTelemetry::SDK::Metrics::Instrument::Histogram.new(name, unit, description, @instrumentation_library, @meter_provider) - when :observable_gauge then OpenTelemetry::SDK::Metrics::Instrument::ObservableGauge.new(name, unit, description, callback, @instrumentation_library, @meter_provider) - when :up_down_counter then OpenTelemetry::SDK::Metrics::Instrument::UpDownCounter.new(name, unit, description, @instrumentation_library, @meter_provider) - when :observable_up_down_counter then OpenTelemetry::SDK::Metrics::Instrument::ObservableUpDownCounter.new(name, unit, description, callback, @instrumentation_library, @meter_provider) + when :counter then OpenTelemetry::SDK::Metrics::Instrument::Counter.new(name, unit, description, @instrumentation_scope, @meter_provider) + when :observable_counter then OpenTelemetry::SDK::Metrics::Instrument::ObservableCounter.new(name, unit, description, callback, @instrumentation_scope, @meter_provider) + when :histogram then OpenTelemetry::SDK::Metrics::Instrument::Histogram.new(name, unit, description, @instrumentation_scope, @meter_provider) + when :observable_gauge then OpenTelemetry::SDK::Metrics::Instrument::ObservableGauge.new(name, unit, description, callback, @instrumentation_scope, @meter_provider) + when :up_down_counter then OpenTelemetry::SDK::Metrics::Instrument::UpDownCounter.new(name, unit, description, @instrumentation_scope, @meter_provider) + when :observable_up_down_counter then OpenTelemetry::SDK::Metrics::Instrument::ObservableUpDownCounter.new(name, unit, description, callback, @instrumentation_scope, @meter_provider) end end end diff --git a/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_data.rb b/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_data.rb index bf982c5cd8..9885deba71 100644 --- a/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_data.rb +++ b/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_data.rb @@ -14,7 +14,7 @@ module State :unit, # String :instrument_kind, # Symbol :resource, # OpenTelemetry::SDK::Resources::Resource - :instrumentation_library, # OpenTelemetry::SDK::InstrumentationLibrary + :instrumentation_scope, # OpenTelemetry::SDK::InstrumentationScope :data_points, # Hash{Hash{String => String, Numeric, Boolean, Array} => Numeric} :start_time_unix_nano, # Integer nanoseconds since Epoch :time_unix_nano) # Integer nanoseconds since Epoch diff --git a/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_stream.rb b/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_stream.rb index 60ed86e75b..2154a3a844 100644 --- a/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_stream.rb +++ b/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_stream.rb @@ -13,7 +13,7 @@ module State # The MetricStream class provides SDK internal functionality that is not a part of the # public API. class MetricStream - attr_reader :name, :description, :unit, :instrument_kind, :instrumentation_library, :data_points + attr_reader :name, :description, :unit, :instrument_kind, :instrumentation_scope, :data_points def initialize( name, @@ -21,14 +21,14 @@ def initialize( unit, instrument_kind, meter_provider, - instrumentation_library + instrumentation_scope ) @name = name @description = description @unit = unit @instrument_kind = instrument_kind @meter_provider = meter_provider - @instrumentation_library = instrumentation_library + @instrumentation_scope = instrumentation_scope @data_points = {} @mutex = Mutex.new @@ -42,7 +42,7 @@ def collect(start_time, end_time) @unit, @instrument_kind, @meter_provider.resource, - @instrumentation_library, + @instrumentation_scope, @data_points.dup, start_time, end_time diff --git a/metrics_sdk/test/integration/in_memory_metric_pull_exporter_test.rb b/metrics_sdk/test/integration/in_memory_metric_pull_exporter_test.rb index a62443da11..ac4e8566ed 100644 --- a/metrics_sdk/test/integration/in_memory_metric_pull_exporter_test.rb +++ b/metrics_sdk/test/integration/in_memory_metric_pull_exporter_test.rb @@ -32,7 +32,7 @@ _(last_snapshot[0].name).must_equal('b_counter') _(last_snapshot[0].unit).must_equal('smidgen') _(last_snapshot[0].description).must_equal('a small amount of something') - _(last_snapshot[0].instrumentation_library.name).must_equal('test') + _(last_snapshot[0].instrumentation_scope.name).must_equal('test') _(last_snapshot[0].data_points).must_equal( {} => 1, { 'a' => 'b' } => 4, diff --git a/sdk/lib/opentelemetry/sdk.rb b/sdk/lib/opentelemetry/sdk.rb index 11a2397923..8bfde7198e 100644 --- a/sdk/lib/opentelemetry/sdk.rb +++ b/sdk/lib/opentelemetry/sdk.rb @@ -78,6 +78,7 @@ def configure require 'opentelemetry/sdk/forwarding_logger' require 'opentelemetry/sdk/internal' require 'opentelemetry/sdk/instrumentation_library' +require 'opentelemetry/sdk/instrumentation_scope' require 'opentelemetry/sdk/resources' require 'opentelemetry/sdk/trace' require 'opentelemetry/sdk/version' diff --git a/sdk/lib/opentelemetry/sdk/instrumentation_library.rb b/sdk/lib/opentelemetry/sdk/instrumentation_library.rb index af867ccebb..8375bb8349 100644 --- a/sdk/lib/opentelemetry/sdk/instrumentation_library.rb +++ b/sdk/lib/opentelemetry/sdk/instrumentation_library.rb @@ -7,6 +7,7 @@ module OpenTelemetry module SDK # InstrumentationLibrary is a struct containing library information for export. + # @deprecated Use InstrumentationScope instead. InstrumentationLibrary = Struct.new(:name, :version) end diff --git a/sdk/lib/opentelemetry/sdk/instrumentation_scope.rb b/sdk/lib/opentelemetry/sdk/instrumentation_scope.rb new file mode 100644 index 0000000000..606738ebbc --- /dev/null +++ b/sdk/lib/opentelemetry/sdk/instrumentation_scope.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module SDK + # InstrumentationScope is a struct containing scope information for export. + InstrumentationScope = Struct.new(:name, + :version) + end +end diff --git a/sdk/lib/opentelemetry/sdk/trace/span.rb b/sdk/lib/opentelemetry/sdk/trace/span.rb index 0137c934c7..1a91bb32d4 100644 --- a/sdk/lib/opentelemetry/sdk/trace/span.rb +++ b/sdk/lib/opentelemetry/sdk/trace/span.rb @@ -23,7 +23,13 @@ class Span < OpenTelemetry::Trace::Span # The following readers are intended for the use of SpanProcessors and # should not be considered part of the public interface for instrumentation. - attr_reader :name, :status, :kind, :parent_span_id, :start_timestamp, :end_timestamp, :links, :resource, :instrumentation_library + attr_reader :name, :status, :kind, :parent_span_id, :start_timestamp, :end_timestamp, :links, :resource, :instrumentation_scope + + # Returns an InstrumentationScope struct, which is backwards compatible with InstrumentationLibrary. + # @deprecated Please use instrumentation_scope instead. + # + # @return InstrumentationScope + alias instrumentation_library instrumentation_scope # Return a frozen copy of the current attributes. This is intended for # use of SpanProcessors and should not be considered part of the public @@ -267,7 +273,7 @@ def to_span_data @links, @events, @resource, - @instrumentation_library, + @instrumentation_scope, context.span_id, context.trace_id, context.trace_flags, @@ -276,7 +282,7 @@ def to_span_data end # @api private - def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity + def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_scope) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity super(span_context: context) @mutex = Mutex.new @name = name @@ -285,7 +291,7 @@ def initialize(context, parent_context, parent_span, name, kind, parent_span_id, @span_limits = span_limits @span_processors = span_processors @resource = resource - @instrumentation_library = instrumentation_library + @instrumentation_scope = instrumentation_scope @ended = false @status = DEFAULT_STATUS @total_recorded_events = 0 diff --git a/sdk/lib/opentelemetry/sdk/trace/span_data.rb b/sdk/lib/opentelemetry/sdk/trace/span_data.rb index 115ae7ca9e..9a122fbaa9 100644 --- a/sdk/lib/opentelemetry/sdk/trace/span_data.rb +++ b/sdk/lib/opentelemetry/sdk/trace/span_data.rb @@ -23,7 +23,7 @@ module Trace :links, # optional Array[OpenTelemetry::Trace::Link] :events, # optional Array[Event] :resource, # OpenTelemetry::SDK::Resources::Resource - :instrumentation_library, # OpenTelemetry::SDK::InstrumentationLibrary + :instrumentation_scope, # OpenTelemetry::SDK::InstrumentationScope :span_id, # String (8 byte binary) :trace_id, # String (16-byte binary) :trace_flags, # Integer (8-bit byte of bit flags) @@ -48,6 +48,12 @@ def hex_trace_id def hex_parent_span_id parent_span_id.unpack1('H*') end + + # Returns an InstrumentationScope struct, which is backwards compatible with InstrumentationLibrary. + # @deprecated Please use instrumentation_scope instead. + # + # @return InstrumentationScope + alias_method :instrumentation_library, :instrumentation_scope end end end diff --git a/sdk/lib/opentelemetry/sdk/trace/tracer.rb b/sdk/lib/opentelemetry/sdk/trace/tracer.rb index 4ff497dac8..f38c4a1c49 100644 --- a/sdk/lib/opentelemetry/sdk/trace/tracer.rb +++ b/sdk/lib/opentelemetry/sdk/trace/tracer.rb @@ -19,7 +19,7 @@ class Tracer < OpenTelemetry::Trace::Tracer # # @return [Tracer] def initialize(name, version, tracer_provider) - @instrumentation_library = InstrumentationLibrary.new(name, version) + @instrumentation_scope = InstrumentationScope.new(name, version) @tracer_provider = tracer_provider end @@ -32,7 +32,7 @@ def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timest kind ||= :internal with_parent ||= Context.current - @tracer_provider.internal_create_span(name, kind, attributes, links, start_timestamp, with_parent, @instrumentation_library) + @tracer_provider.internal_create_span(name, kind, attributes, links, start_timestamp, with_parent, @instrumentation_scope) end end end diff --git a/sdk/lib/opentelemetry/sdk/trace/tracer_provider.rb b/sdk/lib/opentelemetry/sdk/trace/tracer_provider.rb index d1d7942837..b277a3c45f 100644 --- a/sdk/lib/opentelemetry/sdk/trace/tracer_provider.rb +++ b/sdk/lib/opentelemetry/sdk/trace/tracer_provider.rb @@ -126,7 +126,7 @@ def add_span_processor(span_processor) end # @api private - def internal_create_span(name, kind, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength + def internal_create_span(name, kind, attributes, links, start_timestamp, parent_context, instrumentation_scope) # rubocop:disable Metrics/MethodLength parent_span = OpenTelemetry::Trace.current_span(parent_context) parent_span_context = parent_span.context @@ -155,7 +155,7 @@ def internal_create_span(name, kind, attributes, links, start_timestamp, parent_ links, start_timestamp, @resource, - instrumentation_library + instrumentation_scope ) else OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, tracestate: result.tracestate)) diff --git a/sdk/test/opentelemetry/sdk/trace/span_test.rb b/sdk/test/opentelemetry/sdk/trace/span_test.rb index dfe9cb3f41..fe73f35376 100644 --- a/sdk/test/opentelemetry/sdk/trace/span_test.rb +++ b/sdk/test/opentelemetry/sdk/trace/span_test.rb @@ -463,6 +463,30 @@ end end + describe '#instrumentation_library' do + it 'is identical to the instrumentation_scope' do + mock_span_processor.expect(:on_start, nil) { |s| yielded_span = s } # rubocop:disable Lint/UselessAssignment + span = Span.new( + context, + Context.empty, + OpenTelemetry::Trace::Span::INVALID, + 'name', + SpanKind::INTERNAL, + nil, + span_limits, + [mock_span_processor], + nil, + nil, + Time.now, + nil, + OpenTelemetry::SDK::InstrumentationScope.new('foo', '1.0') + ) + + _(span.instrumentation_library.name).must_equal(span.instrumentation_scope.name) + _(span.instrumentation_library.version).must_equal(span.instrumentation_scope.version) + end + end + describe '#initialize' do it 'calls the span processor #on_start callback' do yielded_span = nil diff --git a/sdk/test/opentelemetry/sdk/trace/tracer_test.rb b/sdk/test/opentelemetry/sdk/trace/tracer_test.rb index e5825cb60e..fe00dc5007 100644 --- a/sdk/test/opentelemetry/sdk/trace/tracer_test.rb +++ b/sdk/test/opentelemetry/sdk/trace/tracer_test.rb @@ -237,10 +237,10 @@ _(span.context.span_id).must_equal span_id end - it 'creates a span with the provided instrumentation library' do + it 'creates a span with the provided instrumentation scope' do span = tracer.start_span('span', with_parent: context) - _(span.instrumentation_library.name).must_equal('component-tracer') - _(span.instrumentation_library.version).must_equal('1.0.0') + _(span.instrumentation_scope.name).must_equal('component-tracer') + _(span.instrumentation_scope.version).must_equal('1.0.0') end it 'creates a span with all supplied parameters' do diff --git a/test_helpers/lib/opentelemetry/test_helpers.rb b/test_helpers/lib/opentelemetry/test_helpers.rb index b43095c998..fd3c472cb8 100644 --- a/test_helpers/lib/opentelemetry/test_helpers.rb +++ b/test_helpers/lib/opentelemetry/test_helpers.rb @@ -66,13 +66,13 @@ def with_ids(trace_id, span_id) def create_span_data(name: '', kind: nil, status: nil, parent_span_id: OpenTelemetry::Trace::INVALID_SPAN_ID, total_recorded_attributes: 0, total_recorded_events: 0, total_recorded_links: 0, start_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, end_timestamp: OpenTelemetry::TestHelpers.exportable_timestamp, attributes: nil, links: nil, events: nil, resource: nil, - instrumentation_library: OpenTelemetry::SDK::InstrumentationLibrary.new('', 'v0.0.1'), + instrumentation_scope: OpenTelemetry::SDK::InstrumentationScope.new('', 'v0.0.1'), span_id: OpenTelemetry::Trace.generate_span_id, trace_id: OpenTelemetry::Trace.generate_trace_id, trace_flags: OpenTelemetry::Trace::TraceFlags::DEFAULT, tracestate: nil) resource ||= OpenTelemetry::SDK::Resources::Resource.telemetry_sdk OpenTelemetry::SDK::Trace::SpanData.new(name, kind, status, parent_span_id, total_recorded_attributes, total_recorded_events, total_recorded_links, start_timestamp, end_timestamp, - attributes, links, events, resource, instrumentation_library, span_id, trace_id, trace_flags, tracestate) + attributes, links, events, resource, instrumentation_scope, span_id, trace_id, trace_flags, tracestate) end end end