Skip to content

Commit f1ac22e

Browse files
committed
update generated code again, repeated fields are optional again
1 parent 7e86fd4 commit f1ac22e

19 files changed

+201
-268
lines changed

src/core/opentelemetry.ml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,7 @@ module Globals = struct
692692
let service_version = ref None
693693

694694
let instrumentation_library : instrumentation_scope =
695-
make_instrumentation_scope ~version:"%%VERSION_NUM%%" ~name:"ocaml-otel"
696-
~attributes:[] ()
695+
make_instrumentation_scope ~version:"%%VERSION_NUM%%" ~name:"ocaml-otel" ()
697696

698697
(** Global attributes, initially set via OTEL_RESOURCE_ATTRIBUTES and
699698
modifiable by the user code. They will be attached to each outgoing
@@ -1219,9 +1218,7 @@ module Trace = struct
12191218
make_scope_spans ~scope:Globals.instrumentation_library ~spans ()
12201219
in
12211220
let attributes = Globals.mk_attributes ?service_name ?attrs () in
1222-
let resource =
1223-
Proto.Resource.make_resource ~entity_refs:[] ~attributes ()
1224-
in
1221+
let resource = Proto.Resource.make_resource ~attributes () in
12251222
make_resource_spans ~resource ~scope_spans:[ ils ] ()
12261223

12271224
(** Sync emitter.
@@ -1371,7 +1368,7 @@ module Metrics = struct
13711368
number_data_point =
13721369
let attributes = attrs |> List.map _conv_key_value in
13731370
make_number_data_point ~start_time_unix_nano ~time_unix_nano:now ~attributes
1374-
~value:(As_double d) ~exemplars:[] ()
1371+
~value:(As_double d) ()
13751372

13761373
(** Number data point, as an int *)
13771374
let int ?(start_time_unix_nano = _program_start)
@@ -1380,12 +1377,12 @@ module Metrics = struct
13801377
let attributes = attrs |> List.map _conv_key_value in
13811378
make_number_data_point ~start_time_unix_nano ~time_unix_nano:now ~attributes
13821379
~value:(As_int (Int64.of_int i))
1383-
~exemplars:[] ()
1380+
()
13841381

13851382
(** Aggregation of a scalar metric, always with the current value *)
13861383
let gauge ~name ?description ?unit_ (l : number_data_point list) : t =
13871384
let data = Gauge (make_gauge ~data_points:l ()) in
1388-
make_metric ~metadata:[] ~name ?description ?unit_ ~data ()
1385+
make_metric ~name ?description ?unit_ ~data ()
13891386

13901387
type aggregation_temporality = Metrics.aggregation_temporality =
13911388
| Aggregation_temporality_unspecified
@@ -1399,7 +1396,7 @@ module Metrics = struct
13991396
let data =
14001397
Sum (make_sum ~data_points:l ?is_monotonic ~aggregation_temporality ())
14011398
in
1402-
make_metric ~metadata:[] ~name ?description ?unit_ ~data ()
1399+
make_metric ~name ?description ?unit_ ~data ()
14031400

14041401
(** Histogram data
14051402
@param count number of values in population (non negative)
@@ -1422,7 +1419,7 @@ module Metrics = struct
14221419
let data =
14231420
Histogram (make_histogram ~data_points:l ?aggregation_temporality ())
14241421
in
1425-
make_metric ~metadata:[] ~name ?description ?unit_ ~data ()
1422+
make_metric ~name ?description ?unit_ ~data ()
14261423

14271424
(* TODO: exponential history *)
14281425
(* TODO: summary *)
@@ -1435,9 +1432,7 @@ module Metrics = struct
14351432
make_scope_metrics ~scope:Globals.instrumentation_library ~metrics:l ()
14361433
in
14371434
let attributes = Globals.mk_attributes ?service_name ?attrs () in
1438-
let resource =
1439-
Proto.Resource.make_resource ~entity_refs:[] ~attributes ()
1440-
in
1435+
let resource = Proto.Resource.make_resource ~attributes () in
14411436
make_resource_metrics ~scope_metrics:[ lm ] ~resource ()
14421437

14431438
(** Emit some metrics to the collector (sync). This blocks until the backend
@@ -1542,7 +1537,7 @@ module Logs = struct
15421537
let trace_id = Option.map Trace_id.to_bytes trace_id in
15431538
let span_id = Option.map Span_id.to_bytes span_id in
15441539
let body = _conv_value body in
1545-
make_log_record ~time_unix_nano ~observed_time_unix_nano ~attributes:[]
1540+
make_log_record ~time_unix_nano ~observed_time_unix_nano
15461541
?severity_number:severity ?severity_text:log_level ?flags ?trace_id
15471542
?span_id ?body ()
15481543

@@ -1568,9 +1563,7 @@ module Logs = struct
15681563
cause deadlocks. *)
15691564
let emit ?service_name ?attrs (l : t list) : unit =
15701565
let attributes = Globals.mk_attributes ?service_name ?attrs () in
1571-
let resource =
1572-
Proto.Resource.make_resource ~entity_refs:[] ~attributes ()
1573-
in
1566+
let resource = Proto.Resource.make_resource ~attributes () in
15741567
let ll =
15751568
make_scope_logs ~scope:Globals.instrumentation_library ~log_records:l ()
15761569
in

src/proto/common.ml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,21 @@ and key_value_list = {
1818
}
1919

2020
and key_value = {
21-
mutable _presence: Pbrt.Bitfield.t;
22-
(** tracking presence for 1 fields *)
21+
mutable _presence: Pbrt.Bitfield.t; (** presence for 1 fields *)
2322
mutable key : string;
2423
mutable value : any_value option;
2524
}
2625

2726
type instrumentation_scope = {
28-
mutable _presence: Pbrt.Bitfield.t;
29-
(** tracking presence for 3 fields *)
27+
mutable _presence: Pbrt.Bitfield.t; (** presence for 3 fields *)
3028
mutable name : string;
3129
mutable version : string;
3230
mutable attributes : key_value list;
3331
mutable dropped_attributes_count : int32;
3432
}
3533

3634
type entity_ref = {
37-
mutable _presence: Pbrt.Bitfield.t;
38-
(** tracking presence for 2 fields *)
35+
mutable _presence: Pbrt.Bitfield.t; (** presence for 2 fields *)
3936
mutable schema_url : string;
4037
mutable type_ : string;
4138
mutable id_keys : string list;
@@ -44,24 +41,24 @@ type entity_ref = {
4441

4542
let default_any_value (): any_value = String_value ("")
4643

47-
let default_array_value (): array_value =
44+
let default_array_value (): array_value =
4845
{
4946
values=[];
5047
}
5148

52-
let default_key_value_list (): key_value_list =
49+
let default_key_value_list (): key_value_list =
5350
{
5451
values=[];
5552
}
5653

57-
let default_key_value (): key_value =
54+
let default_key_value (): key_value =
5855
{
5956
_presence=Pbrt.Bitfield.empty;
6057
key="";
6158
value=None;
6259
}
6360

64-
let default_instrumentation_scope (): instrumentation_scope =
61+
let default_instrumentation_scope (): instrumentation_scope =
6562
{
6663
_presence=Pbrt.Bitfield.empty;
6764
name="";
@@ -70,7 +67,7 @@ let default_instrumentation_scope (): instrumentation_scope =
7067
dropped_attributes_count=0l;
7168
}
7269

73-
let default_entity_ref (): entity_ref =
70+
let default_entity_ref (): entity_ref =
7471
{
7572
_presence=Pbrt.Bitfield.empty;
7673
schema_url="";
@@ -91,7 +88,7 @@ let copy_array_value (self:array_value) : array_value =
9188
{ self with values = self.values }
9289

9390
let make_array_value
94-
~(values:any_value list)
91+
?(values=[])
9592
() : array_value =
9693
let _res = default_array_value () in
9794
set_array_value_values _res values;
@@ -105,7 +102,7 @@ let copy_key_value_list (self:key_value_list) : key_value_list =
105102
{ self with values = self.values }
106103

107104
let make_key_value_list
108-
~(values:key_value list)
105+
?(values=[])
109106
() : key_value_list =
110107
let _res = default_key_value_list () in
111108
set_key_value_list_values _res values;
@@ -153,7 +150,7 @@ let copy_instrumentation_scope (self:instrumentation_scope) : instrumentation_sc
153150
let make_instrumentation_scope
154151
?(name:string option)
155152
?(version:string option)
156-
~(attributes:key_value list)
153+
?(attributes=[])
157154
?(dropped_attributes_count:int32 option)
158155
() : instrumentation_scope =
159156
let _res = default_instrumentation_scope () in
@@ -187,8 +184,8 @@ let copy_entity_ref (self:entity_ref) : entity_ref =
187184
let make_entity_ref
188185
?(schema_url:string option)
189186
?(type_:string option)
190-
~(id_keys:string list)
191-
~(description_keys:string list)
187+
?(id_keys=[])
188+
?(description_keys=[])
192189
() : entity_ref =
193190
let _res = default_entity_ref () in
194191
(match schema_url with

src/proto/common.mli

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,21 @@ and key_value_list = private {
2525
}
2626

2727
and key_value = private {
28-
mutable _presence: Pbrt.Bitfield.t;
29-
(** tracking presence for 1 fields *)
28+
mutable _presence: Pbrt.Bitfield.t; (** presence for 1 fields *)
3029
mutable key : string;
3130
mutable value : any_value option;
3231
}
3332

3433
type instrumentation_scope = private {
35-
mutable _presence: Pbrt.Bitfield.t;
36-
(** tracking presence for 3 fields *)
34+
mutable _presence: Pbrt.Bitfield.t; (** presence for 3 fields *)
3735
mutable name : string;
3836
mutable version : string;
3937
mutable attributes : key_value list;
4038
mutable dropped_attributes_count : int32;
4139
}
4240

4341
type entity_ref = private {
44-
mutable _presence: Pbrt.Bitfield.t;
45-
(** tracking presence for 2 fields *)
42+
mutable _presence: Pbrt.Bitfield.t; (** presence for 2 fields *)
4643
mutable schema_url : string;
4744
mutable type_ : string;
4845
mutable id_keys : string list;
@@ -75,7 +72,7 @@ val default_entity_ref : unit -> entity_ref
7572

7673

7774
val make_array_value :
78-
values:any_value list ->
75+
?values:any_value list ->
7976
unit ->
8077
array_value
8178
(** [make_array_value … ()] is a builder for type [array_value] *)
@@ -86,7 +83,7 @@ val set_array_value_values : array_value -> any_value list -> unit
8683
(** set field values in array_value *)
8784

8885
val make_key_value_list :
89-
values:key_value list ->
86+
?values:key_value list ->
9087
unit ->
9188
key_value_list
9289
(** [make_key_value_list … ()] is a builder for type [key_value_list] *)
@@ -117,7 +114,7 @@ val set_key_value_value : key_value -> any_value -> unit
117114
val make_instrumentation_scope :
118115
?name:string ->
119116
?version:string ->
120-
attributes:key_value list ->
117+
?attributes:key_value list ->
121118
?dropped_attributes_count:int32 ->
122119
unit ->
123120
instrumentation_scope
@@ -149,8 +146,8 @@ val set_instrumentation_scope_dropped_attributes_count : instrumentation_scope -
149146
val make_entity_ref :
150147
?schema_url:string ->
151148
?type_:string ->
152-
id_keys:string list ->
153-
description_keys:string list ->
149+
?id_keys:string list ->
150+
?description_keys:string list ->
154151
unit ->
155152
entity_ref
156153
(** [make_entity_ref … ()] is a builder for type [entity_ref] *)

src/proto/logs.ml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ type severity_number =
2828
| Severity_number_fatal4
2929

3030
type log_record = {
31-
mutable _presence: Pbrt.Bitfield.t;
32-
(** tracking presence for 9 fields *)
31+
mutable _presence: Pbrt.Bitfield.t; (** presence for 9 fields *)
3332
mutable time_unix_nano : int64;
3433
mutable observed_time_unix_nano : int64;
3534
mutable severity_number : severity_number;
@@ -44,16 +43,14 @@ type log_record = {
4443
}
4544

4645
type scope_logs = {
47-
mutable _presence: Pbrt.Bitfield.t;
48-
(** tracking presence for 1 fields *)
46+
mutable _presence: Pbrt.Bitfield.t; (** presence for 1 fields *)
4947
mutable scope : Common.instrumentation_scope option;
5048
mutable log_records : log_record list;
5149
mutable schema_url : string;
5250
}
5351

5452
type resource_logs = {
55-
mutable _presence: Pbrt.Bitfield.t;
56-
(** tracking presence for 1 fields *)
53+
mutable _presence: Pbrt.Bitfield.t; (** presence for 1 fields *)
5754
mutable resource : Resource.resource option;
5855
mutable scope_logs : scope_logs list;
5956
mutable schema_url : string;
@@ -69,7 +66,7 @@ type log_record_flags =
6966

7067
let default_severity_number () = (Severity_number_unspecified:severity_number)
7168

72-
let default_log_record (): log_record =
69+
let default_log_record (): log_record =
7370
{
7471
_presence=Pbrt.Bitfield.empty;
7572
time_unix_nano=0L;
@@ -85,23 +82,23 @@ let default_log_record (): log_record =
8582
event_name="";
8683
}
8784

88-
let default_scope_logs (): scope_logs =
85+
let default_scope_logs (): scope_logs =
8986
{
9087
_presence=Pbrt.Bitfield.empty;
9188
scope=None;
9289
log_records=[];
9390
schema_url="";
9491
}
9592

96-
let default_resource_logs (): resource_logs =
93+
let default_resource_logs (): resource_logs =
9794
{
9895
_presence=Pbrt.Bitfield.empty;
9996
resource=None;
10097
scope_logs=[];
10198
schema_url="";
10299
}
103100

104-
let default_logs_data (): logs_data =
101+
let default_logs_data (): logs_data =
105102
{
106103
resource_logs=[];
107104
}
@@ -154,7 +151,7 @@ let make_log_record
154151
?(severity_number:severity_number option)
155152
?(severity_text:string option)
156153
?(body:Common.any_value option)
157-
~(attributes:Common.key_value list)
154+
?(attributes=[])
158155
?(dropped_attributes_count:int32 option)
159156
?(flags:int32 option)
160157
?(trace_id:bytes option)
@@ -209,7 +206,7 @@ let copy_scope_logs (self:scope_logs) : scope_logs =
209206

210207
let make_scope_logs
211208
?(scope:Common.instrumentation_scope option)
212-
~(log_records:log_record list)
209+
?(log_records=[])
213210
?(schema_url:string option)
214211
() : scope_logs =
215212
let _res = default_scope_logs () in
@@ -236,7 +233,7 @@ let copy_resource_logs (self:resource_logs) : resource_logs =
236233

237234
let make_resource_logs
238235
?(resource:Resource.resource option)
239-
~(scope_logs:scope_logs list)
236+
?(scope_logs=[])
240237
?(schema_url:string option)
241238
() : resource_logs =
242239
let _res = default_resource_logs () in
@@ -257,7 +254,7 @@ let copy_logs_data (self:logs_data) : logs_data =
257254
{ self with resource_logs = self.resource_logs }
258255

259256
let make_logs_data
260-
~(resource_logs:resource_logs list)
257+
?(resource_logs=[])
261258
() : logs_data =
262259
let _res = default_logs_data () in
263260
set_logs_data_resource_logs _res resource_logs;

0 commit comments

Comments
 (0)