Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/scripts/setup-moonbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

set -euo pipefail

readonly MOONBIT_VERSION='0.10.5+5e7afb0c0'
readonly MOONBIT_VERSION_URL='0.10.5%2B5e7afb0c0'
readonly MOONBIT_VERSION='0.10.6+80dc50f24'
readonly MOONBIT_VERSION_URL='0.10.6%2B80dc50f24'
readonly MOONBIT_BASE_URL='https://cli.moonbitlang.com'
readonly TOOLCHAIN_SHA256='07da4e4b21d3ea203b00183906e9e6a3104d77b9756a95c4d9e648471cf2e2d8'
readonly CORE_SHA256='d92991190e30d10a1ab6fcd7d0282b8ddd0004d0309bc40fbc056310cf20bfc5'
readonly TOOLCHAIN_SHA256='c67ad4e31320a5b0cce388eec51a4c9384b7f902e8d27e7479f2612491b13b6f'
readonly CORE_SHA256='a3ca729f2517b7c6170a2645aba9aae79154b3d71f13302470c9953311398174'

: "${RUNNER_TEMP:?RUNNER_TEMP must be set}"
: "${GITHUB_ENV:?GITHUB_ENV must be set}"
Expand Down
1 change: 0 additions & 1 deletion src/cmd/main/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ package "brickfrog/moontrace/cmd/main"
// Type aliases

// Traits

1 change: 0 additions & 1 deletion src/console/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ pub fn subscriber(min_level? : @moontrace.Level, output? : (String) -> Unit, col
// Type aliases

// Traits

2 changes: 1 addition & 1 deletion src/env_filter.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn parse_env_filter(
directive : String,
) -> Result[ParsedFilter, EnvFilterError] {
let mut default_level = Info
let filters : Map[String, Level] = {}
let filters : Map[String, Level] = Map([])
for raw_part in directive.split(",") {
let part = trim_env_filter_part(raw_part)
if !part.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions src/event.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn merge_fields(fields : Array[Field]) -> Array[Field] {
if global_context.val.is_empty() {
fields
} else {
let explicit_keys : Map[String, Bool] = {}
let explicit_keys : Map[String, Bool] = Map([])
fields.each(fn(f) { explicit_keys.set(f.key, true) })
let merged : Array[Field] = []
global_context.val.each(fn(k, v) {
Expand Down Expand Up @@ -325,7 +325,7 @@ pub fn trace(

///|
pub fn Event::to_json(self : Event) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("level", self.level.to_json())
m.set("message", self.message.to_json())
m.set("timestamp", self.timestamp.to_json())
Expand Down
2 changes: 1 addition & 1 deletion src/field.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(all) struct Field {

///|
pub fn fields_to_json(fields : Array[Field]) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
fields.each(fn(f) { m.set(f.key, f.value) })
m.to_json()
}
Expand Down
2 changes: 1 addition & 1 deletion src/field_show.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub impl Show for Field with fn output(self, logger) {

///|
pub fn Field::to_json(self : Field) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set(self.key, self.value)
m.to_json()
}
1 change: 0 additions & 1 deletion src/file/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ pub fn FileSubscriberConfig::new(String, max_size_bytes? : Int, max_files? : Int
// Type aliases

// Traits

8 changes: 4 additions & 4 deletions src/flame/flame.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ pub fn FlameExporter::reset(self : FlameExporter) -> Unit {

///|
pub fn fold_spans(spans : Array[@moontrace.Span]) -> String {
let spans_by_id : Map[String, @moontrace.Span] = {}
let spans_by_id : Map[String, @moontrace.Span] = Map([])
spans.each(fn(span) {
spans_by_id.set(span_key(span.trace_id, span.span_id), span)
})
let direct_child_duration_by_parent : Map[String, UInt64] = {}
let direct_child_duration_by_parent : Map[String, UInt64] = Map([])
spans.each(fn(span) {
let parent = span_key(span.trace_id, span.parent_span_id)
if valid_parent_edge(span, spans_by_id, spans.length()) {
add_weight(direct_child_duration_by_parent, parent, span.duration())
}
})
let folded_weights : Map[String, UInt64] = {}
let folded_weights : Map[String, UInt64] = Map([])
spans.each(fn(span) {
let child_duration = direct_child_duration_by_parent.get_or_default(
span_key(span.trace_id, span.span_id),
Expand Down Expand Up @@ -129,7 +129,7 @@ fn valid_parent_edge(
Some(parent_span) => Some(parent_span)
None => return false
}
let visited : Map[String, Bool] = {}
let visited : Map[String, Bool] = Map([])
let mut remaining = span_count
while remaining > 0 {
match current {
Expand Down
1 change: 0 additions & 1 deletion src/flame/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ pub fn FlameExporter::span_observer(Self) -> @moontrace.SpanLifecycleObserver
// Type aliases

// Traits

4 changes: 2 additions & 2 deletions src/id_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test "ids are non-zero" {

///|
test "bulk trace ids are unique" {
let seen : Map[String, Bool] = {}
let seen : Map[String, Bool] = Map([])
for _ in 0..<1000 {
let id = @moontrace.next_trace_id()
assert_true(!seen.contains(id))
Expand All @@ -49,7 +49,7 @@ test "bulk trace ids are unique" {

///|
test "bulk span ids are unique" {
let seen : Map[String, Bool] = {}
let seen : Map[String, Bool] = Map([])
for _ in 0..<1000 {
let id = @moontrace.next_span_id()
assert_true(!seen.contains(id))
Expand Down
1 change: 0 additions & 1 deletion src/json/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ pub fn subscriber(min_level? : @moontrace.Level, output? : (String) -> Unit) ->
// Type aliases

// Traits

12 changes: 6 additions & 6 deletions src/otlp/convert.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ pub fn wrap_log_records(
resource? : Resource = resource(),
scope? : InstrumentationScope = instrumentation_scope(),
) -> Json {
let scope_logs : Map[String, Json] = {}
let scope_logs : Map[String, Json] = Map([])
scope_logs.set("scope", scope.to_json())
scope_logs.set("logRecords", records.map(fn(r) { r.to_json() }).to_json())

let resource_logs : Map[String, Json] = {}
let resource_logs : Map[String, Json] = Map([])
resource_logs.set("resource", resource.to_json())
resource_logs.set("scopeLogs", [scope_logs.to_json()].to_json())

let root : Map[String, Json] = {}
let root : Map[String, Json] = Map([])
root.set("resourceLogs", [resource_logs.to_json()].to_json())
root.to_json()
}
Expand All @@ -76,15 +76,15 @@ pub fn wrap_spans(
resource? : Resource = resource(),
scope? : InstrumentationScope = instrumentation_scope(),
) -> Json {
let scope_spans : Map[String, Json] = {}
let scope_spans : Map[String, Json] = Map([])
scope_spans.set("scope", scope.to_json())
scope_spans.set("spans", spans.map(fn(s) { s.to_json() }).to_json())

let resource_spans : Map[String, Json] = {}
let resource_spans : Map[String, Json] = Map([])
resource_spans.set("resource", resource.to_json())
resource_spans.set("scopeSpans", [scope_spans.to_json()].to_json())

let root : Map[String, Json] = {}
let root : Map[String, Json] = Map([])
root.set("resourceSpans", [resource_spans.to_json()].to_json())
root.to_json()
}
1 change: 0 additions & 1 deletion src/otlp/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ pub fn Resource::to_json(Self) -> Json
// Type aliases

// Traits

1 change: 0 additions & 1 deletion src/otlp/transport/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ pub impl Show for TransportError
pub(open) trait OtlpHttpClient {
async fn post(Self, String, String, Map[String, String]) -> Result[HttpResponse, TransportError]
}

24 changes: 12 additions & 12 deletions src/otlp/types.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ pub fn instrumentation_scope(
pub fn OtlpValue::to_json(self : OtlpValue) -> Json {
match self {
StringVal(s) => {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("stringValue", s.to_json())
m.to_json()
}
IntVal(i) => {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("intValue", i.to_string().to_json())
m.to_json()
}
BoolVal(b) => {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("boolValue", b.to_json())
m.to_json()
}
DoubleVal(d) => {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("doubleValue", d.to_json())
m.to_json()
}
Expand All @@ -129,15 +129,15 @@ pub fn OtlpValue::to_json(self : OtlpValue) -> Json {

///|
pub fn OtlpAttribute::to_json(self : OtlpAttribute) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("key", self.key.to_json())
m.set("value", self.value.to_json())
m.to_json()
}

///|
pub fn OtlpLink::to_json(self : OtlpLink) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("traceId", self.trace_id.to_json())
m.set("spanId", self.span_id.to_json())
if !self.trace_state.is_empty() {
Expand All @@ -149,7 +149,7 @@ pub fn OtlpLink::to_json(self : OtlpLink) -> Json {

///|
pub fn OtlpSpan::to_json(self : OtlpSpan) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("traceId", self.trace_id.to_json())
m.set("spanId", self.span_id.to_json())
if !self.parent_span_id.is_empty() {
Expand All @@ -162,7 +162,7 @@ pub fn OtlpSpan::to_json(self : OtlpSpan) -> Json {
m.set("endTimeUnixNano", self.end_time_unix_nano.to_string().to_json())
m.set("attributes", self.attributes.map(fn(a) { a.to_json() }).to_json())
m.set("links", self.links.map(fn(link) { link.to_json() }).to_json())
let status : Map[String, Json] = {}
let status : Map[String, Json] = Map([])
status.set("code", self.status_code.to_json())
if !self.status_message.is_empty() {
status.set("message", self.status_message.to_json())
Expand All @@ -173,11 +173,11 @@ pub fn OtlpSpan::to_json(self : OtlpSpan) -> Json {

///|
pub fn OtlpLogRecord::to_json(self : OtlpLogRecord) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("timeUnixNano", self.time_unix_nano.to_string().to_json())
m.set("severityNumber", self.severity_number.to_json())
m.set("severityText", self.severity_text.to_json())
let body : Map[String, Json] = {}
let body : Map[String, Json] = Map([])
body.set("stringValue", self.body.to_json())
m.set("body", body.to_json())
m.set("attributes", self.attributes.map(fn(a) { a.to_json() }).to_json())
Expand All @@ -186,14 +186,14 @@ pub fn OtlpLogRecord::to_json(self : OtlpLogRecord) -> Json {

///|
pub fn Resource::to_json(self : Resource) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("attributes", self.attributes.map(fn(a) { a.to_json() }).to_json())
m.to_json()
}

///|
pub fn InstrumentationScope::to_json(self : InstrumentationScope) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("name", self.name.to_json())
if !self.version.is_empty() {
m.set("version", self.version.to_json())
Expand Down
1 change: 0 additions & 1 deletion src/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,3 @@ pub struct TraceStateEntry {
// Type aliases

// Traits

7 changes: 5 additions & 2 deletions src/scoped_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,11 @@ test "with_trace_state restores all globals after raised failure" {
})
}

let result : Result[Unit, ScopedFailure] = try? fail_in_scope()
guard result is Err(_) else { abort("expected scoped failure") }
try fail_in_scope() catch {
_ => ()
} noraise {
_ => abort("expected scoped failure")
}

@moontrace.info("blocked after failure")
@moontrace.warn("blocked by restored module filter after failure")
Expand Down
1 change: 0 additions & 1 deletion src/span_async/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ pub async fn[T] with_span_async(String, fields? : Array[@moontrace.Field], async
// Type aliases

// Traits

2 changes: 1 addition & 1 deletion src/span_json.mbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///|
pub fn Span::to_json(self : Span) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("name", self.name.to_json())
m.set("trace_id", self.trace_id.to_json())
m.set("span_id", self.span_id.to_json())
Expand Down
2 changes: 1 addition & 1 deletion src/span_observer.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub fn SpanLinkKind::to_json(self : SpanLinkKind) -> Json {

///|
pub fn SpanLink::to_json(self : SpanLink) -> Json {
let m : Map[String, Json] = {}
let m : Map[String, Json] = Map([])
m.set("trace_id", self.trace_id.to_json())
m.set("span_id", self.span_id.to_json())
m.set("kind", self.kind.to_json())
Expand Down
1 change: 0 additions & 1 deletion src/test/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,3 @@ pub fn[T] TestSubscriber::with_install(Self, () -> T raise?) -> T raise?
// Type aliases

// Traits

7 changes: 5 additions & 2 deletions src/test/test_subscriber_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,11 @@ test "scoped install restores global subscriber and observer on raise" {
})
}

let result : Result[Unit, ExampleFailure] = try? fail_in_scope()
guard result is Err(_) else { abort("expected ExampleFailure") }
try fail_in_scope() catch {
_ => ()
} noraise {
_ => abort("expected ExampleFailure")
}

@moontrace.info("after failure")
let after_span = @moontrace.span("after failure span")
Expand Down