⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
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
5 changes: 5 additions & 0 deletions .changeset/trace-attrs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"github.com/livekit/protocol": patch
---

Add helpers for tracing attributes.
47 changes: 47 additions & 0 deletions livekit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,31 @@ import (

"buf.build/go/protoyaml"
"github.com/dennwc/iters"
"go.opentelemetry.io/otel/attribute"
proto "google.golang.org/protobuf/proto"
"gopkg.in/yaml.v3"
)

const (
TraceKeyPref = "lk."

TraceKeyRoomPrefix = TraceKeyPref + "room."
TraceKeyRoomID = attribute.Key(TraceKeyRoomPrefix + "id")
TraceKeyRoomName = attribute.Key(TraceKeyRoomPrefix + "name")

TraceKeyParticipantPrefix = TraceKeyPref + "participant."
TraceKeyParticipantID = attribute.Key(TraceKeyParticipantPrefix + "id")
TraceKeyParticipantIdentity = attribute.Key(TraceKeyParticipantPrefix + "identity")

TraceKeyTrackPrefix = TraceKeyPref + "track."
TraceKeyTrackID = attribute.Key(TraceKeyTrackPrefix + "id")

TraceKeySIPPrefix = TraceKeyPref + "sip."
TraceKeySIPHeaderPrefix = TraceKeySIPPrefix + "h."
TraceKeySIPCallID = attribute.Key(TraceKeySIPPrefix + "callID")
TraceKeySIPCallIDHeader = attribute.Key(TraceKeySIPHeaderPrefix + "CallID")
Copy link
Contributor

Choose a reason for hiding this comment

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

key case. also should these be call.id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just follows the name of the header in this case. Maybe the first one (non-header) should have dot as well. Let me fix that.

Copy link
Contributor

@paulwe paulwe Jan 13, 2026

Choose a reason for hiding this comment

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

if we were following existing conventions wouldn't all of them be camel case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

)

type TrackID string
type ParticipantID string
type ParticipantIdentity string
Expand All @@ -47,6 +68,8 @@ type ParticipantKey struct {
type JobID string
type DispatchID string
type AgentName string
type SIPCallID string
type SIPCallIDHeader string

func (s TrackID) String() string { return string(s) }
func (s ParticipantID) String() string { return string(s) }
Expand All @@ -59,10 +82,34 @@ func (s NodeID) String() string { return string(s) }
func (s JobID) String() string { return string(s) }
func (s DispatchID) String() string { return string(s) }
func (s AgentName) String() string { return string(s) }
func (s SIPCallID) String() string { return string(s) }
func (s SIPCallIDHeader) String() string { return string(s) }
func (s ParticipantKey) String() string {
return fmt.Sprintf("%s_%s_%s", s.ProjectID, s.RoomName, s.Identity)
}

func (s ParticipantID) Trace() attribute.KeyValue {
return TraceKeyParticipantID.String(string(s))
}
func (s ParticipantIdentity) Trace() attribute.KeyValue {
return TraceKeyParticipantIdentity.String(string(s))
}
func (s RoomID) Trace() attribute.KeyValue {
return TraceKeyRoomID.String(string(s))
}
func (s RoomName) Trace() attribute.KeyValue {
return TraceKeyRoomName.String(string(s))
}
func (s TrackID) Trace() attribute.KeyValue {
return TraceKeyTrackID.String(string(s))
}
func (s SIPCallID) Trace() attribute.KeyValue {
return TraceKeySIPCallID.String(string(s))
}
func (s SIPCallIDHeader) Trace() attribute.KeyValue {
return TraceKeySIPCallIDHeader.String(string(s))
}

type stringTypes interface {
ParticipantID | RoomID | TrackID | ParticipantIdentity | ParticipantName | RoomName | ConnectionID | NodeID
}
Expand Down
Loading