Represent missing instrumentation scope values as null in Rego input

Open Beginner friendly
#1,753 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start with the test named test_custom_rego_can_inspect_span_instrumentation_scope and trace how Weaver builds the Rego input for instrumentation_scope. Update the missing version and schema_url representation so the test's null checks pass, then run that test and confirm it reports the expected finding.

Written by the indexing model from the issue text.

Description

live-check

PR open-telemetry/semantic-conventions-conformance#180 validates instrumentation scope fields with custom Rego policies.

When version or schema_url is not provided, Weaver exposes it to Rego as an empty string:

input.instrumentation_scope.version == ""
input.instrumentation_scope.schema_url == ""

Missing values should instead be represented as null:

input.instrumentation_scope.version == null
input.instrumentation_scope.schema_url == null

The following test added to test_custom_rego_can_inspect_span_instrumentation_scope demonstrates the expected behavior:

deny contains make_advice(advice_type, advice_level, advice_context, message) if {
    input.instrumentation_scope.name == "framework"
    input.instrumentation_scope.version == null
    input.instrumentation_scope.schema_url == null
    advice_type := "instrumentation_scope_missing_values"
    advice_level := "information"
    advice_context := {"scope_name": "framework"}
    message := "Missing instrumentation scope values are explicitly null"
}

The test constructs a scope with missing optional values and expects this finding. On current main, it fails with:

expected missing scope values to be explicitly null for Rego: []
Dominant language
Rust
Stars
489
Forks
108
Avg merge
3d 4h
Merged PRs (30d)
40

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from open-telemetry/weaver

All issues in open-telemetry/weaver

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.