// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you 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 banyandb.common.v1;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1";
option java_package = "org.apache.skywalking.banyandb.common.v1";

// Trace is the top level message of a trace.
message Trace {
  // trace_id is the unique identifier of the trace.
  string trace_id = 1;
  // spans is a list of spans in the trace.
  repeated Span spans = 2;
  // error indicates whether the trace is an error trace.
  bool error = 3;
}

// Span is the basic unit of a trace.
message Span {
  // start_time is the start time of the span.
  google.protobuf.Timestamp start_time = 1;
  // end_time is the end time of the span.
  google.protobuf.Timestamp end_time = 2;
  // error indicates whether the span is an error span.
  bool error = 3;
  // tags is a list of tags of the span.
  repeated Tag tags = 4;
  // message is the message generated by the span.
  string message = 5;
  // children is a list of child spans of the span.
  repeated Span children = 6;
  // duration is the duration of the span.
  int64 duration = 7;
}

// Tag is the key-value pair of a span.
message Tag {
  // key is the key of the tag.
  string key = 1;
  // value is the value of the tag.
  string value = 2;
}
