syntax = "proto3";

package golem.worker;

import "google/protobuf/timestamp.proto";
import "golem/worker/worker_id.proto";

message InvocationContext {
  golem.worker.WorkerId parent = 1;
  repeated string args = 3;
  map<string, string> env = 4;
  optional TracingInvocationContext tracing = 5;
}

message TracingInvocationContext {
  string trace_id = 1;               // hexadecimal representation of a 128-bit trace ID
  repeated InvocationSpan spans = 2; // stack of spans, first item is the current, last one is the root
  repeated string trace_state = 3;
}

message InvocationSpan {
  oneof span {
    LocalInvocationSpan local = 1;
    ExternalParentSpan external_parent = 2;
  }
}

message LocalInvocationSpan {
  uint64 span_id = 1;
  google.protobuf.Timestamp start = 2;
  map<string, AttributeValue> attributes = 3;
  bool inherited = 4;
  repeated InvocationSpan linked_context = 5;
}

message ExternalParentSpan {
  uint64 span_id = 1;
}

message AttributeValue {
  oneof value {
    string string_value = 1;
  }
}
