Support enum and array based attributes in codegen#1898
Open
bidetofevil wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Kotlin semantic-convention codegen templates to support enum-typed attributes (and prepares support for array-typed attributes), then switches a few Android internal semantic conventions and instrumentations to use the generated enums instead of hard-coded strings.
Changes:
- Update Kotlin weaver/codegen templates to (a) skip
any-typed event attributes, (b) generateAttributeKeyconstants for array types, and (c) generate enum “Values” types for enum attributes. - Update the Android semconv registry to express
screen.orientation,start.type, andwebsocket.message.typeas enums. - Update instrumentation code to use the generated enum values (e.g.,
StartTypeValues.COLD.value) instead of string literals.
PR Merge Tier: Tier 3 (build/codegen changes + cross-module behavior wiring)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
semconv/templates/registry/kotlin/weaver.yaml |
Adds type mappings for array AttributeKey generation and filters out any-typed event attributes. |
semconv/templates/registry/kotlin/kotlin_semconv_template.kt.j2 |
Generates AttributeKey fields for array types and emits enum value classes for enum attributes. |
semconv/templates/registry/kotlin/kotlin_event_template.kt.j2 |
Adds array-attribute handling via AttributeKey.*ArrayKey(...) when emitting event attributes. |
semconv/model/android/registry.yaml |
Converts several attributes from string to enum definitions with members. |
instrumentation/screen-orientation/.../ScreenOrientationDetector.kt |
Uses generated ScreenOrientationValues instead of hard-coded orientation strings. |
instrumentation/okhttp3-websocket/.../WebsocketListenerWrapper.kt |
Uses generated WebsocketMessageTypeValues instead of hard-coded message type strings. |
instrumentation/activity/.../AppStartupTimer.kt |
Uses generated StartTypeValues.COLD.value instead of "cold". |
instrumentation/activity/.../ActivityTracer.kt |
Uses generated StartTypeValues.{WARM,HOT}.value instead of "warm"/"hot". |
Comment on lines
7
to
11
| package io.opentelemetry.android.semconv.events | ||
|
|
||
| import io.opentelemetry.api.common.AttributeKey | ||
| import io.opentelemetry.api.common.Attributes | ||
| import io.opentelemetry.api.logs.Logger |
LikeTheSalad
approved these changes
Jul 15, 2026
LikeTheSalad
left a comment
Contributor
There was a problem hiding this comment.
Thanks! I think it's worth checking the comment from Copilot, but overall LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed attribute templates to work with enum and array-based attribute values. Add in some codegen to create enums and then changed a few internal semconv to use them.