Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 90 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"asap-common/dependencies/rs/promql_utilities",
"asap-common/dependencies/rs/sql_utilities",
"asap-common/dependencies/rs/elastic_dsl_utilities",
"asap-common/dependencies/rs/asap_otel_proto",
"asap-common/dependencies/rs/asap_types",
"asap-common/dependencies/rs/datafusion_summary_library",
"asap-common/tests/compare_matched_tokens/rust_tests",
Expand Down
29 changes: 29 additions & 0 deletions asap-common/dependencies/rs/asap_otel_proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "asap_otel_proto"
version.workspace = true
edition.workspace = true

# Vendored Rust bindings for DataCollector's modified opentelemetry-proto.
# See ../../../../docs/pipeline-query-catalog.md §5.4 for the reasoning.
#
# The .proto files in proto/opentelemetry/proto/ are copied verbatim from
# DataCollector's opentelemetry-proto submodule and add first-class sketch
# variants (DDSketch, KLLSketch, CountSketch, CountMinSketch, HLLSketch) to
# the standard OTLP Metric.data oneof. To re-vendor when DataCollector
# updates its proto schema, copy the four files referenced in build.rs
# from the corresponding paths in the DataCollector worktree.

[lib]
path = "src/lib.rs"

[dependencies]
prost = "0.13"
tonic = { version = "0.12", features = ["transport", "codegen", "prost"] }

[build-dependencies]
prost-build = "0.13"
tonic-build = { version = "0.12", features = ["prost"] }
# Ship a modern protoc so the build does not depend on the host's system
# protoc version. The system protoc on many distros is < 3.15 which
# rejects proto3 `optional` keyword used in opentelemetry-proto.
protoc-bin-vendored = "3"
24 changes: 24 additions & 0 deletions asap-common/dependencies/rs/asap_otel_proto/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
let proto_root = "proto";
let proto_files = [
"proto/opentelemetry/proto/common/v1/common.proto",
"proto/opentelemetry/proto/resource/v1/resource.proto",
"proto/opentelemetry/proto/metrics/v1/metrics.proto",
"proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto",
];
for f in &proto_files {
println!("cargo:rerun-if-changed={f}");
}
println!("cargo:rerun-if-changed=build.rs");

// Use the vendored protoc binary so the build is independent of the
// host's system protoc version. Many distros still ship protoc < 3.15
// which rejects proto3 `optional` keyword used in opentelemetry-proto.
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path()?);

tonic_build::configure()
.build_server(true)
.build_client(false)
.compile_protos(&proto_files, &[proto_root])?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright 2019, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package opentelemetry.proto.collector.metrics.v1;

import "opentelemetry/proto/metrics/v1/metrics.proto";

option csharp_namespace = "OpenTelemetry.Proto.Collector.Metrics.V1";
option java_multiple_files = true;
option java_package = "io.opentelemetry.proto.collector.metrics.v1";
option java_outer_classname = "MetricsServiceProto";
option go_package = "go.opentelemetry.io/proto/otlp/collector/metrics/v1";

// Service that can be used to push metrics between one Application
// instrumented with OpenTelemetry and a collector, or between a collector and a
// central collector.
service MetricsService {
rpc Export(ExportMetricsServiceRequest) returns (ExportMetricsServiceResponse) {}
}

message ExportMetricsServiceRequest {
// An array of ResourceMetrics.
// For data coming from a single resource this array will typically contain one
// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
// data from multiple origins typically batch the data before forwarding further and
// in that case this array will contain multiple elements.
repeated opentelemetry.proto.metrics.v1.ResourceMetrics resource_metrics = 1;
}

message ExportMetricsServiceResponse {
// The details of a partially successful export request.
//
// If the request is only partially accepted
// (i.e. when the server accepts only parts of the data and rejects the rest)
// the server MUST initialize the `partial_success` field and MUST
// set the `rejected_<signal>` with the number of items it rejected.
//
// Servers MAY also make use of the `partial_success` field to convey
// warnings/suggestions to senders even when the request was fully accepted.
// In such cases, the `rejected_<signal>` MUST have a value of `0` and
// the `error_message` MUST be non-empty.
//
// A `partial_success` message with an empty value (rejected_<signal> = 0 and
// `error_message` = "") is equivalent to it not being set/present. Senders
// SHOULD interpret it the same way as in the full success case.
ExportMetricsPartialSuccess partial_success = 1;

// List of compact descriptors for series IDs that were minted by the
// collector while processing this request. Exporters SHOULD cache these
// assignments and omit the associated attributes on subsequent exports once
// a series_id is known.
repeated SeriesAssignment series_assignments = 2;
}

message ExportMetricsPartialSuccess {
// The number of rejected data points.
//
// A `rejected_<signal>` field holding a `0` value indicates that the
// request was fully accepted.
int64 rejected_data_points = 1;

// A developer-facing human-readable message in English. It should be used
// either to explain why the server rejected parts of the data during a partial
// success or to convey warnings/suggestions during a full success. The message
// should offer guidance on how users can address such issues.
//
// error_message is an optional field. An error_message with an empty value
// is equivalent to it not being set.
string error_message = 2;
}

// SeriesAssignment communicates collector-assigned series identifiers back to
// exporters. Identifiers are expressed using the same deterministic key format
// as the collector's attribute de-duplication logic: resource_key and scope_key
// are built by concatenating the schema URL with sorted attribute pairs,
// metric_name is the OTLP Metric name, metric_type is the string form of
// opentelemetry.proto.metrics.v1.Metric.MetricType, and attributes_fingerprint
// is an opaque fingerprint of the sorted point-level attributes.
message SeriesAssignment {
// Deterministic encoding of the Resource associated with the series. The
// collector MUST build this using schema_url + sorted attributes separated
// by '|' to match the lookup key it uses internally.
string resource_key = 1;

// Deterministic encoding of the instrumentation scope. Built from
// scope.name + scope.version + scope.schema_url + sorted attributes separated
// by '|'.
string scope_key = 2;

// Fully-qualified metric identity.
string metric_name = 3;

// String representation of the metric type (e.g. "Gauge", "Histogram").
string metric_type = 4;

// Opaque fingerprint of the data point's attribute set. The exporter MUST
// use the same fingerprinting algorithm when looking up cached series_ids.
bytes attributes_fingerprint = 5;

// The collector-assigned series identifier.
uint64 series_id = 6;
}
Loading
Loading