Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

- Rename `resolved_schema_uri` to `resolved_registry_uri` in publication manifest and in `package` command. ([#1425](https://github.com/open-telemetry/weaver/pull/1425))
- Fix V2 resolver overwriting `SpanName.note` with the span type id during resolution. ([#1401](https://github.com/open-telemetry/weaver/pull/1401))
- Add `semconv_grouped_events` JQ helper with v1/v2 options parity and coverage. ([#1439](https://github.com/open-telemetry/weaver/pull/1439))
- New feature ([#1344](https://github.com/open-telemetry/weaver/issues/1344)) - Support authenticated HTTP downloads of remote registries, including GitHub private release assets. Auth is configured per-URL via `[[auth]]` entries in `.weaver.toml` (longest `url_prefix` wins), with tokens sourced from a literal `token`, a `token_env` variable, or a `token_command` helper (e.g. `["gh", "auth", "token"]`). ([#1356](https://github.com/open-telemetry/weaver/pull/1356) by @jerbly)
- New feature - `.weaver.toml` project configuration now covers all subcommands allowing for simplified configuration management. See the [README.md](https://github.com/open-telemetry/weaver/blob/main/crates/weaver_config/README.md) ([#1410](https://github.com/open-telemetry/weaver/pull/1410) by @jerbly)
- Live-check OTLP log findings are now dog-fooded: the event schema, attributes, and enumerations are defined in a semconv model and code-generated using Weaver's own templates. See [`finding.md`](crates/weaver_live_check/docs/finding.md) for the generated reference documentation and [`dog-fooding.md`](crates/weaver_live_check/docs/dog-fooding.md) for the full dog-fooding guide.
Expand Down
389 changes: 200 additions & 189 deletions crates/weaver_forge/expected_output/semconv_jq_fn/semconv_events.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"events": [
{
"attributes": null,
"brief": "",
"name": "db.query",
"root_namespace": "db",
"stability": "alpha"
}
],
"root_namespace": "db"
}
]
58 changes: 57 additions & 1 deletion crates/weaver_forge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ mod tests {
use crate::extensions::case::case_converter;
use crate::file_loader::FileSystemFileLoader;
use crate::registry::ResolvedRegistry;
use crate::v2::event::Event;
use crate::v2::registry::{ForgeResolvedRegistry, Refinements, Registry as V2Registry};
use crate::v2::span::Span;
use crate::{run_filter_raw, OutputDirective, TemplateEngine};
Expand Down Expand Up @@ -962,7 +963,13 @@ mod tests {
common: CommonFields::default(),
provenance: Default::default(),
}],
events: vec![],
events: vec![Event {
name: SignalId::from("db.query".to_owned()),
attributes: vec![],
entity_associations: vec![],
common: CommonFields::default(),
provenance: Default::default(),
}],
entities: vec![],
},
refinements: Refinements {
Expand Down Expand Up @@ -1352,6 +1359,55 @@ mod tests {
assert_eq!(result, expected);
}

#[test]
fn test_run_filter_raw_semconv_grouped_events_v2() {
let input = serde_json::json!({
"registry": {
"events": [
{
"name": "http.request",
"brief": "stable event",
"stability": "stable"
},
{
"name": "db.query",
"brief": "deprecated event",
"stability": "stable",
"deprecated": { "note": "deprecated" }
},
{
"name": "other.event",
"brief": "excluded namespace",
"stability": "stable"
}
]
}
});

let result = run_filter_raw(
&input,
"semconv_grouped_events({\"v2\": true, \"exclude_deprecated\": true, \"exclude_root_namespace\": [\"other\"]})",
)
.expect("failed to run semconv_grouped_events for v2");

let expected = serde_json::json!([
{
"root_namespace": "http",
"events": [
{
"name": "http.request",
"brief": "stable event",
"stability": "stable",
"root_namespace": "http",
"attributes": null
}
]
}
]);

assert_eq!(result, expected);
}

#[test]
fn test_auto_escape_modes() {
use minijinja::{AutoEscape, Environment};
Expand Down
9 changes: 3 additions & 6 deletions crates/weaver_forge/templates/semconv_jq_fn/weaver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ templates:
application_mode: single
- template: semconv_events.json
filter: >
.groups
| map(select(.type == "event"))
| map(. + {
event_namespace: (if .id | index(".") then (.id | split(".") | .[0:-1] | join(".")) else "other" end)
})
| sort_by(.event_namespace, .id)
semconv_grouped_events({
Comment thread
lmolkova marked this conversation as resolved.
"stable_only": false
})
application_mode: single
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ ctx | tojson(indent=true) }}
5 changes: 5 additions & 0 deletions crates/weaver_forge/templates/semconv_jq_fn_v2/weaver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ templates:
semconv_grouped_spans({"v2": true})
application_mode: single
file_name: semconv_spans.json
- template: semconv_events.j2
filter: >
semconv_grouped_events({"v2": true})
application_mode: single
file_name: semconv_events.json
70 changes: 63 additions & 7 deletions defaults/jq/semconv.jq
Comment thread
lmolkova marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ def stability_filter($options):
map(
select(.stability == "stable")
)
| map(.type.members? |= map(select(.stability == "stable")))
| map(
if .type? == null then
.
else
.type.members? |= map(select(.stability == "stable"))
end
)
else
.
end
| if $options | has("exclude_stability") then
map(select(.stability as $st | expand_stability($options.exclude_stability) | index($st) | not))
| map(.type.members? |= map(select(.stability as $st | expand_stability($options.exclude_stability) | index($st) | not)))
| map(
if .type? == null then
.
else
.type.members? |= map(select(.stability as $st | expand_stability($options.exclude_stability) | index($st) | not))
end
)
else
.
end;
Expand Down Expand Up @@ -90,10 +102,16 @@ def code_generation_exclude_filter($options):
or .annotations.code_generation.exclude == null
or .annotations.code_generation.exclude == false
))
| map(.type.members? |= map(select(.annotations == null
or .annotations.code_generation == null
or .annotations.code_generation.exclude == null
or .annotations.code_generation.exclude == false)))
| map(
if .type? == null then
.
else
.type.members? |= map(select(.annotations == null
or .annotations.code_generation == null
or .annotations.code_generation.exclude == null
or .annotations.code_generation.exclude == false))
end
)
end;

# Filters the input list of attributes and enum members based on deprecation status.
Expand All @@ -102,7 +120,13 @@ def code_generation_exclude_filter($options):
def deprecated_filter($options):
if ($options | has("exclude_deprecated") and $options.exclude_deprecated == true) then
map(select(has("deprecated") | not))
| map(.type.members? |= map(select(has("deprecated") | not)))
| map(
if .type? == null then
.
Comment thread
lmolkova marked this conversation as resolved.
else
.type.members? |= map(select(has("deprecated") | not))
end
)
else
.
end;
Expand Down Expand Up @@ -261,3 +285,35 @@ def semconv_grouped_spans($options): semconv_spans($options) | semconv_group_spa

# Convenience function to group all spans by their root namespace without any filtering options.
def semconv_grouped_spans: semconv_grouped_spans({});

# Event Functions
# Groups the events by their root namespace and sorts events by name.
def semconv_group_events_by_root_namespace:
group_by(.root_namespace)
| map({ root_namespace: .[0].root_namespace, events: . | sort_by(.name) });

# Extracts and processes semantic convention events based on provided options.
# $options is an object that can contain:
# - stable_only: a boolean to exclude all non-stable events and non-stable attributes on stable events.
# - exclude_deprecated: a boolean to exclude deprecated events and deprecated attributes.
# - exclude_root_namespace: a list of root namespaces to exclude - applies to top-level events and does not apply to nested attributes.
# - exclude_stability: a list of stability statuses to exclude. Use `stable_only` to exclude all non-stable events instead. Applies to nested attributes as well.
# - ignore_code_generation_annotations: a boolean to ignore code generation annotations. Applies to signals and nested attributes.
# - v2: a boolean to use v2 schema.
def semconv_events($options): semconv_signal("event"; $options) | sort_by(.name);

# Convenience function to extract all events without any filtering options.
def semconv_events: semconv_events({});

# Groups the processed events by their root namespace based on provided options.
# $options is an object that can contain:
# - stable_only: a boolean to exclude all non-stable events and non-stable attributes on stable events.
# - exclude_deprecated: a boolean to exclude deprecated events and deprecated attributes.
# - exclude_root_namespace: a list of root namespaces to exclude - applies to top-level events and does not apply to nested attributes.
# - exclude_stability: a list of stability statuses to exclude. Use `stable_only` to exclude all non-stable events instead. Applies to nested attributes as well.
# - ignore_code_generation_annotations: a boolean to ignore code generation annotations. Applies to signals and nested attributes.
# - v2: a boolean to use v2 schema.
def semconv_grouped_events($options): semconv_events($options) | semconv_group_events_by_root_namespace;

# Convenience function to group all events by their root namespace without any filtering options.
def semconv_grouped_events: semconv_grouped_events({});
Loading