Skip to content

feat(otlp): record schema_url for traces and logs#344

Open
MikeGoldsmith wants to merge 6 commits intomainfrom
mike/otel-121/record-schema-url
Open

feat(otlp): record schema_url for traces and logs#344
MikeGoldsmith wants to merge 6 commits intomainfrom
mike/otel-121/record-schema-url

Conversation

@MikeGoldsmith
Copy link
Contributor

Which problem is this PR solving?

OTel schema URLs identify which version of OTel semantic conventions a service's instrumentation follows (e.g. https://opentelemetry.io/schemas/1.21.0). Husky was discarding these entirely. Without them, Canvas can't distinguish http.url from url.full or understand why column names differ across datasets.

Closes OTEL-121 (partial — traces/logs only; metrics handled in hound).

Short description of the changes

Records OTel schema URLs as event attributes across all OTLP translation paths:

  • resource.schema_url — from ResourceSpans.schema_url / ResourceLogs.schema_url
  • scope.schema_url — from ScopeSpans.schema_url / ScopeLogs.schema_url

Covers all 4 paths:

  • Proto path (traces.go, logs.go)
  • Binary msgp path (traces_direct.go)
  • JSON msgp path (traces_direct_json.go)

Per the OTel spec, scope-level schema_url takes precedence over resource-level when both are present (enforced at query time by Canvas, not at ingestion).

Assisted-by: Claude Sonnet 4.6

…logs

Records OTel schema URLs as event attributes across all OTLP translation paths:
- Proto path (traces.go, logs.go)
- Binary msgp path (traces_direct.go)
- JSON msgp path (traces_direct_json.go)

resource.schema_url comes from ResourceSpans/ResourceLogs.schema_url.
scope.schema_url comes from ScopeSpans/ScopeLogs.schema_url, which takes
precedence per the OTel spec when both are present.

Assisted-by: Claude Sonnet 4.6
@MikeGoldsmith MikeGoldsmith requested a review from a team as a code owner February 24, 2026 14:38
@MikeGoldsmith MikeGoldsmith changed the title feat(otlp): record resource.schema_url and scope.schema_url for traces and logs feat(otlp): record schema_url for traces and logs Feb 24, 2026
…-scan

Addresses review feedback:
- Restore break loop on field 1 (resource/scope) in the first pass, recovering
  the early-exit optimization that was lost when schema_url was added
- Add a dedicated pre-scan pass for schema_url (field 3) before the spans pass,
  since field 3 appears after field 2 (scope_spans/spans) in canonical proto
  encoding and must be in attrs before span processing begins
- Extract "resource.schema_url" and "scope.schema_url" as package-level consts

Assisted-by: Claude Sonnet 4.6
…ore span processing

Assisted-by: Claude Sonnet 4.6
@MikeGoldsmith
Copy link
Contributor Author

MikeGoldsmith commented Feb 25, 2026

Updated to add consts for resource.schema_url and scope.schema_url and update the pre-scan loops to do 3 passes:

  • resource
  • schema URL
  • spans

Let me know what you think 😄

if len(slice) > 0 {
resourceAttrs.addString([]byte(attrResourceSchemaURL), slice)
}
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we find the schema_url field, we can break out of this loop early

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

Suggested change
default:
break loop
default:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the outer for loop

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second loop iterates over the same data as the first for loop (which is somewhat confusingly named loop). I suggest introducing a distinct variable name for the second for loop on line 574, such as schemaURLLoop, to make the intent clearer.

We should also break out of that loop once a schemaURL field is found on line 591, since there’s no need to continue iterating after that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants