fix some tests

This commit is contained in:
Simon Cruanes 2025-12-17 14:00:39 -05:00
parent dc99897e87
commit 1853fa7585
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
4 changed files with 142 additions and 338 deletions

View file

@ -1,4 +1,4 @@
(tests
(names test_urls)
(package opentelemetry-client-cohttp-lwt)
(libraries opentelemetry opentelemetry-client-cohttp-lwt))
(libraries opentelemetry opentelemetry-client-cohttp-lwt unix))

View file

@ -1,4 +1,4 @@
(tests
(names test_implicit_scope_sync)
(package opentelemetry-client-cohttp-lwt)
(libraries threads alcotest opentelemetry opentelemetry-client-cohttp-lwt))
(libraries threads alcotest opentelemetry unix opentelemetry-client-cohttp-lwt))

View file

@ -5,8 +5,12 @@
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name"; value = Some(String_value("emit_logs")); };
{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
{ key = "process.runtime.version";
value = Some(String_value("5.3.0"));
};
{ key = "process.runtime.name";
value = Some(String_value("ocaml"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
@ -25,7 +29,134 @@
severity_number = Severity_number_debug;
severity_text = "debug";
body = Some(String_value("emit_logs: starting"));
attributes = [];
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 1;
observed_time_unix_nano = 1;
severity_number = Severity_number_info2;
severity_text = "info";
body = Some(String_value("emit_logs: info log"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 2;
observed_time_unix_nano = 2;
severity_number = Severity_number_warn;
severity_text = "warning";
body = Some(String_value("emit_logs: warn log"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 3;
observed_time_unix_nano = 3;
severity_number = Severity_number_error;
severity_text = "error";
body = Some(String_value("emit_logs: error log"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 4;
observed_time_unix_nano = 4;
severity_number = Severity_number_info;
severity_text = "app";
body = Some(String_value("emit_logs: app log"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 5;
observed_time_unix_nano = 5;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log is emitted with varied tags from a span"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "string_list_attr"; value = Some(String_value("")); };
{ key = "bool_attr"; value = Some(String_value("")); };
{ key = "float_attr"; value = Some(String_value("")); };
{ key = "int_attr"; value = Some(String_value("")); };
{ key = "string_attr"; value = Some(String_value("")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=16>;
span_id = <bytes len=8>;
event_name = "" (* absent *);
};
{ time_unix_nano = 6;
observed_time_unix_nano = 6;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log will be emitted with varied tags"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "string_list_attr"; value = Some(String_value("")); };
{ key = "bool_attr"; value = Some(String_value("")); };
{ key = "float_attr"; value = Some(String_value("")); };
{ key = "int_attr"; value = Some(String_value("")); };
{ key = "string_attr"; value = Some(String_value("")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
};
{ time_unix_nano = 7;
observed_time_unix_nano = 7;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log will be emitted from otel and fmt reporter"));
attributes =
[{ key = "src"; value = Some(String_value("application")); };
{ key = "my_fmt_attr"; value = Some(String_value("bar")); }
];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
@ -38,334 +169,3 @@
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name"; value = Some(String_value("emit_logs")); };
{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_info2;
severity_text = "info";
body = Some(String_value("emit_logs: info log"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs"));
};
{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr"; value = Some(String_value("foo")); }
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_warn;
severity_text = "warning";
body = Some(String_value("emit_logs: warn log"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs"));
};
{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr";
value = Some(String_value("foo"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_error;
severity_text = "error";
body = Some(String_value("emit_logs: error log"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs"));
};
{ key = "src"; value = Some(String_value("application")); };
{ key = "my_reporter_attr";
value = Some(String_value("foo"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_info;
severity_text = "app";
body = Some(String_value("emit_logs: app log"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs"));
};
{ key = "src";
value = Some(String_value("application"));
};
{ key = "string_list_attr";
value = Some(String_value(""));
};
{ key = "bool_attr"; value = Some(String_value("")); };
{ key = "float_attr"; value = Some(String_value("")); };
{ key = "int_attr"; value = Some(String_value("")); };
{ key = "string_attr"; value = Some(String_value("")); };
{ key = "my_reporter_attr";
value = Some(String_value("foo"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log is emitted with varied tags from a span"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=16>;
span_id = <bytes len=8>;
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs"));
};
{ key = "src";
value = Some(String_value("application"));
};
{ key = "string_list_attr";
value = Some(String_value(""));
};
{ key = "bool_attr"; value = Some(String_value("")); };
{ key = "float_attr"; value = Some(String_value("")); };
{ key = "int_attr"; value = Some(String_value("")); };
{ key = "string_attr"; value = Some(String_value("")); };
{ key = "my_reporter_attr";
value = Some(String_value("foo"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log will be emitted with varied tags"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
{ resource =
Some(
{ attributes =
[{ key = "service.namespace";
value = Some(String_value("ocaml-otel.test"));
};
{ key = "service.name";
value = Some(String_value("emit_logs_fmt"));
};
{ key = "src";
value = Some(String_value("application"));
};
{ key = "my_fmt_attr";
value = Some(String_value("bar"));
}
];
dropped_attributes_count = 0 (* absent *);
entity_refs = [];
});
scope_logs =
[{ scope =
Some(
{ name = "ocaml-otel";
version = "%%VERSION_NUM%%";
attributes = [];
dropped_attributes_count = 0 (* absent *);
});
log_records =
[{ time_unix_nano = 0;
observed_time_unix_nano = 0;
severity_number = Severity_number_info2;
severity_text = "info";
body =
Some(
String_value(
"emit_logs: this log will be emitted from otel and fmt reporter"));
attributes = [];
dropped_attributes_count = 0 (* absent *);
flags = 0 (* absent *);
trace_id = <bytes len=0> (* absent *);
span_id = <bytes len=0> (* absent *);
event_name = "" (* absent *);
}
];
schema_url = "" (* absent *);
}
];
schema_url = "" (* absent *);
}

View file

@ -11,6 +11,7 @@ let cmd = [ "emit_logs_cohttp"; "--url"; url ]
let tests (signal_batches : Client.Signal.t list) =
ignore signal_batches;
let cur_time = ref 0 in
List.iter
(fun (signal_batch : Client.Signal.t) ->
match signal_batch with
@ -24,8 +25,11 @@ let tests (signal_batches : Client.Signal.t list) =
List.map
(fun (lr : L.log_record) ->
let lr = L.copy_log_record lr in
L.log_record_set_time_unix_nano lr 0L;
L.log_record_set_observed_time_unix_nano lr 0L;
let pseudo_time = Int64.of_int !cur_time in
incr cur_time;
L.log_record_set_time_unix_nano lr pseudo_time;
L.log_record_set_observed_time_unix_nano lr
pseudo_time;
lr)
sl.log_records
in