// 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.logs.v1;

option java_multiple_files = true;
option java_package = "io.opentelemetry.proto.logs.v1";
option java_outer_classname = "LogsProto";

import "opentelemetry/proto/common/v1/common.proto";
import "opentelemetry/proto/resource/v1/resource.proto";

// Service request for ExportLogsServiceRequest.
message ExportLogsServiceRequest {
  // An array of ResourceLogs.
  repeated ResourceLogs resource_logs = 1;
}

// Service response for ExportLogsServiceResponse.
message ExportLogsServiceResponse {
  // The details of a partially successful export request.
  ExportLogsPartialSuccess partial_success = 1;
}

// ExportLogsPartialSuccess is used when some logs were rejected.
message ExportLogsPartialSuccess {
  // The number of rejected log records.
  int64 rejected_log_records = 1;

  // A developer-facing human-readable message in English.
  string error_message = 2;
}

// A collection of ScopeLogs from a Resource.
message ResourceLogs {
  // The resource for the logs in this message.
  opentelemetry.proto.resource.v1.Resource resource = 1;

  // A list of ScopeLogs that originate from a resource.
  repeated ScopeLogs scope_logs = 2;

  // The Schema URL, if known.
  string schema_url = 3;
}

// A collection of Logs produced by a Scope.
message ScopeLogs {
  // The instrumentation scope information for the logs in this message.
  opentelemetry.proto.common.v1.InstrumentationScope scope = 1;

  // A list of log records.
  repeated LogRecord log_records = 2;

  // The Schema URL, if known.
  string schema_url = 3;
}

// Possible values for LogRecord.SeverityNumber.
enum SeverityNumber {
  // UNSPECIFIED is the default SeverityNumber, it MUST NOT be used.
  SEVERITY_NUMBER_UNSPECIFIED = 0;
  SEVERITY_NUMBER_TRACE = 1;
  SEVERITY_NUMBER_TRACE2 = 2;
  SEVERITY_NUMBER_TRACE3 = 3;
  SEVERITY_NUMBER_TRACE4 = 4;
  SEVERITY_NUMBER_DEBUG = 5;
  SEVERITY_NUMBER_DEBUG2 = 6;
  SEVERITY_NUMBER_DEBUG3 = 7;
  SEVERITY_NUMBER_DEBUG4 = 8;
  SEVERITY_NUMBER_INFO = 9;
  SEVERITY_NUMBER_INFO2 = 10;
  SEVERITY_NUMBER_INFO3 = 11;
  SEVERITY_NUMBER_INFO4 = 12;
  SEVERITY_NUMBER_WARN = 13;
  SEVERITY_NUMBER_WARN2 = 14;
  SEVERITY_NUMBER_WARN3 = 15;
  SEVERITY_NUMBER_WARN4 = 16;
  SEVERITY_NUMBER_ERROR = 17;
  SEVERITY_NUMBER_ERROR2 = 18;
  SEVERITY_NUMBER_ERROR3 = 19;
  SEVERITY_NUMBER_ERROR4 = 20;
  SEVERITY_NUMBER_FATAL = 21;
  SEVERITY_NUMBER_FATAL2 = 22;
  SEVERITY_NUMBER_FATAL3 = 23;
  SEVERITY_NUMBER_FATAL4 = 24;
}

// A log record according to OpenTelemetry Log Data Model.
message LogRecord {
  // time_unix_nano is the time when the event occurred.
  fixed64 time_unix_nano = 1;

  // time when the event was observed by the collection system.
  fixed64 observed_time_unix_nano = 11;

  // Numerical value of the severity.
  SeverityNumber severity_number = 2;

  // The severity text (also known as log level).
  string severity_text = 3;

  // A value containing the body of the log record.
  opentelemetry.proto.common.v1.AnyValue body = 5;

  // Additional attributes that describe the specific event occurrence.
  repeated opentelemetry.proto.common.v1.KeyValue attributes = 6;
  uint32 dropped_attributes_count = 7;

  // Flags, a bit field.
  fixed32 flags = 8;

  // A unique identifier for a trace.
  bytes trace_id = 9;

  // A unique identifier for a span within a trace.
  bytes span_id = 10;
}
