Telemetry protocol

This page contains the core schema for telemetry event data that gets exported from Sourcegraph.

To learn more, refer to our telemetry documentation.

Table of Contents

Event

FieldTypeLabelDescription
idstring

Generated ID of the event, currently expected to be UUID v4.

timestampgoogle.protobuf.Timestamp

Timestamp of when the original event was recorded.

featurestring

Feature associated with the event in camelCase, e.g. 'myFeature'.

actionstring

Action associated with the event in camelCase, e.g. 'pageView'.

sourceEventSource

Source of the event.

parametersEventParameters

Parameters of the event.

userEventUseroptional

Optional user associated with the event.

This field should be hydrated by the Sourcegraph server, and not provided

by clients.

feature_flagsEventFeatureFlagsoptional

Optional feature flags configured in the context of the event.

marketing_trackingEventMarketingTrackingoptional

Optional marketing campaign tracking parameters.

🚨 SECURITY: This metadata is NEVER exported from single-tenant Sourcegraph

instances, and is only exported for events tracked in the public

Sourcegraph.com instance and managed services.

interactionEventInteractionoptional

Optional metadata identifying the interaction that generated the event.

EventBillingMetadata

FieldTypeLabelDescription
productstring

Billing product ID associated with the event.

categorystring

Billing category ID the event falls into.

EventFeatureFlags

FieldTypeLabelDescription
flagsEventFeatureFlags.FlagsEntryrepeated

Evaluated feature flags. In Soucegraph we currently only support boolean

feature flags, but in the API we allow arbitrary string values for future

extensibility.

This field should be hydrated by the Sourcegraph server, and not provided

by clients.

EventFeatureFlags.FlagsEntry

FieldTypeLabelDescription
keystring

valuestring

EventInteraction

FieldTypeLabelDescription
trace_idstringoptional

OpenTelemetry trace ID representing the interaction associated with the event.

interaction_idstringoptional

Custom interaction ID representing the interaction associated with the event.

geolocationEventInteraction.Geolocationoptional

Geolocation associated with the interaction, typically inferred from the

originating client's IP address (which we do not collect).

parent_interaction_idstringoptional

Parent interaction ID for tracking nested/sub-agent calls.

root_interaction_idstringoptional

Root interaction ID identifying the first interaction in the chain.

If there is no parent, root_interaction_id equals interaction_id.

session_idstringoptional

Session identifier from sourcegraphSessionId cookie, used for

session-level event correlation.

EventInteraction.Geolocation

FieldTypeLabelDescription
country_codestring

Inferred ISO 3166-1 alpha-2 or alpha-3 country code

EventMarketingTracking

Marketing campaign tracking metadata.

🚨 SECURITY: This metadata is NEVER exported from single-tenant Sourcegraph instances, and is only exported for events tracked in the public Sourcegraph.com instance and managed services.

FieldTypeLabelDescription
urlstringoptional

URL the event occurred on.

cohort_idstringoptional

Cohort ID to identify the user as part of a specific A/B test.

referrerstringoptional

Referrer URL that refers the user to Sourcegraph.

last_page_seen_urlstringoptional

URL the user last visited, in their current session.

most_recent_referrer_urlstringoptional

Most recent referrer URL, in their current session

first_page_seen_urlstringoptional

First URL the user visited, in their current session.

utm_campaignstringoptional

UTM campaign tracking parameters, in their current session.

utm_contentstringoptional

UTM content tracking parameters, in their current session.

utm_mediumstringoptional

UTM medium tracking parameters, in their current session.

utm_sourcestringoptional

UTM source tracking parameters, in their current session.

utm_termstringoptional

UTM term tracking parameters, in their current session.

EventParameters

FieldTypeLabelDescription
versionint32

Version of the event parameters, used for indicating the "shape" of this

event's metadata, beginning at 0. Useful for denoting if the shape of

metadata has changed in any way.

legacy_metadataEventParameters.LegacyMetadataEntryrepeatedDeprecated.

DEPRECATED, legacy metadata format that only accepted int64 - use the new

'metadata' field instead, which accepts float values. Values sent through

this proto field will be merged into the new metadata attributes.

metadataEventParameters.MetadataEntryrepeated

Strictly typed metadata, restricted to integer values to avoid accidentally

exporting sensitive or private data.

private_metadatagoogle.protobuf.Structoptional

Additional potentially sensitive metadata - i.e. not restricted to integer

values.

🚨 SECURITY: This metadata is NOT exported from instances by default, as it

can contain arbitrarily-shaped data that may accidentally contain sensitive

or private contents.

This metadata is only exported on an allowlist basis based on terms of

use agreements and combinations of event feature and action, alongside

careful audit of callsites.

billing_metadataEventBillingMetadataoptional

Optional billing-related metadata.

EventParameters.LegacyMetadataEntry

FieldTypeLabelDescription
keystring

valueint64

EventParameters.MetadataEntry

FieldTypeLabelDescription
keystring

valuedouble

EventSource

FieldTypeLabelDescription
serverEventSource.Server

Information about the server that is publishing the event, based on

RecordEventsRequestMetadata.Identifier.

clientEventSource.Clientoptional

Information about the client that generated the event.

EventSource.Client

FieldTypeLabelDescription
namestring

Source client of the event.

versionstringoptional

Version of the client.

EventSource.Server

FieldTypeLabelDescription
versionstring

Version of the server emitting the event, corresponding to

RecordEventsRequestMetadata.Identifier. For example, if the Identifier

indicates the publisher is a Sourcegraph instance, the version represents

the version of the Sourcegraph server.

request_clientEventSource.Server.RequestClientoptional

Information about the original client that made the request that triggered

this serverside event.

EventSource.Server.RequestClient

FieldTypeLabelDescription
user_agentstring

The user agent of the original client that made the request that triggered

this serverside event.

api_client_namestring

The name of the original client that made the request that triggered

this serverside event.

api_client_versionstring

The version of the original client that made the request that triggered

this serverside event.

requested_withstring

The X-Requested-With header from the original client that made the request

that triggered this serverside event.

api_client_featurestring

The client-reported feature from the original client that made the request

that triggered this serverside event.

EventUser

EventUser represents a user in the context of an event, and thus must be free of sensitive sensitive metadata and PII about the user.

PublishInstanceUserMetadata is used to allow instances to submit additional metadata about users for instances that consent to it.

FieldTypeLabelDescription
user_idint64optional

Sourcegraph instance database user ID of the user. User IDs are specific to

a Sourcegraph instance, and are not universal across Sourcegraph instances.

We use an int64 as an ID because in Sourcegraph, database user IDs are

always integers.

anonymous_user_idstringoptional

Randomized unique identifier representing the user (typically stored in

localstorage in web clients, or similar mechanisms elsewhere). This is

often used for unauthenticated users, but can persist to authenticated

users as well.

sams_external_idstringoptional

Sourcegraph Accounts Management System (SAMS) account associated with the

user, represented by a SAMS external user ID in a UUID format. This is only

valid for services leveraging SAMS as an identity provider - in other words,

traditional Sourcegraph instances will not provide this.

Learn more about SAMS: https://handbook.sourcegraph.com/departments/engineering/teams/core-services/sams

Identifier

FieldTypeLabelDescription
licensed_instanceIdentifier.LicensedInstanceIdentifier

A licensed Sourcegraph instance.

unlicensed_instanceIdentifier.UnlicensedInstanceIdentifier

An unlicensed Sourcegraph instance.

managed_serviceIdentifier.ManagedServiceIdentifier

A service operated and managed by the Sourcegraph team, for example

a service deployed by MSP: https://handbook.sourcegraph.com/departments/engineering/teams/core-services/managed-services/platform/

Valid SAMS client credentials are required to publish events under a

managed service identifier. The required scope is

'telemetry_gateway::events::publish'. See go/sams-client-credentials and

go/sams-token-scopes for more information.

workspaceIdentifier.WorkspaceIdentifier

A workspace within a tenant host.

Valid SAMS client credentials are required to publish events under a

workspace identifier. The required scope is

'telemetry_gateway::events::publish'. See go/sams-client-credentials and

go/sams-token-scopes for more information.

Identifier.LicensedInstanceIdentifier

FieldTypeLabelDescription
license_keystring

License key configured in the Sourcegraph instance emitting the event.

instance_idstring

Self-reported Sourcegraph instance identifier.

external_urlstring

Instance external URL defined in the instance site configuration.

Identifier.ManagedServiceIdentifier

FieldTypeLabelDescription
service_idstring

Self-reported service identifier, for example 'my-service'.

service_environmentstringoptional

Self-reported service environment, for example 'prod' or 'dev'.

Identifier.UnlicensedInstanceIdentifier

FieldTypeLabelDescription
instance_idstring

Self-reported Sourcegraph instance identifier.

external_urlstring

Instance external URL defined in the instance site configuration.

Identifier.WorkspaceIdentifier

FieldTypeLabelDescription
workspace_idstring

Self-reported Sourcegraph workspace identifier, for example 'ws_$UUID'.

external_urlstring

The workspace's assigned external URL.

InstanceOrganizationMetadata

🚨 SECURITY: This metadata is NOT exported from instances by default.

FieldTypeLabelDescription
idint64

Internal ID of the organization from the 'orgs' table.

namestring

Name of the organization.

display_namestring

Display name of the organization.

user_idsint64repeated

The IDs of users that are members of this organization. We allow a single

repeated set here as the repeated ID-only format should be fairly compact

for realistic scenarios.

InstanceUserMetadata

🚨 SECURITY: This metadata is NOT exported from instances by default.

FieldTypeLabelDescription
idint64

Internal ID of the user from the 'users' table.

usernamestring

Username of the user.

primary_emailstring

Primary email of the user.

assigned_rbac_rolesstringrepeated

Assigned RBAC roles for the user.

PublishInstanceUserMetadataRequest

🚨 SECURITY: This metadata is NOT exported from instances by default.

FieldTypeLabelDescription
metadataPublishInstanceUserMetadataRequestMetadata

Metadata about the events being recorded.

user_metadataPublishInstanceUserMetadataRequest.UserMetadataPayload

Batch of user metadata to publish in a single message. Clients should aim

to batch large uploads into a series of smaller requests in the RecordEvents

stream, being mindful of common limits in individual message sizes:

https://protobuf.dev/programming-guides/api/#bound-req-res-sizes

🚨 SECURITY: Callers exporting for single-tenant Sourcegraph should always

respect in-instance toggles for what user metadata should be exported.

organization_metadataPublishInstanceUserMetadataRequest.OrganizationMetadataPayload

Batch of organization metadata to publish in a single message. Clients

should aim to batch large uploads into a series of smaller requests in the

RecordEvents stream, being mindful of common limits in individual message

sizes: https://protobuf.dev/programming-guides/api/#bound-req-res-sizes

🚨 SECURITY: Callers exporting for single-tenant Sourcegraph should always

respect in-instance toggles for what user metadata should be exported.

PublishInstanceUserMetadataRequest.OrganizationMetadataPayload

🚨 SECURITY: This metadata is NOT exported from instances by default.

FieldTypeLabelDescription
organizationsInstanceOrganizationMetadatarepeated

Organization metadata from the 'orgs' table in a Sourcegraph instance.

PublishInstanceUserMetadataRequest.UserMetadataPayload

🚨 SECURITY: This metadata is NOT exported from instances by default.

FieldTypeLabelDescription
usersInstanceUserMetadatarepeated

User metadata from the 'users' table in a Sourcegraph instance.

PublishInstanceUserMetadataRequestMetadata

FieldTypeLabelDescription
request_idstring

Client-provided request identifier for diagnostics purposes.

identifierIdentifier

Telemetry publisher self-identification. Only LicensedInstanceIdentifier

and UnlicensedInstanceIdentifier are accepted for this RPC.

PublishInstanceUserMetadataResponse

RecordEventRequest

FieldTypeLabelDescription
metadataRecordEventsRequestMetadata

Metadata about the events being recorded.

eventEvent

Event to record.

RecordEventResponse

RecordEventsRequest

FieldTypeLabelDescription
metadataRecordEventsRequestMetadata

Metadata about the events being recorded.

eventsRecordEventsRequest.EventsPayload

Batch of events to record in a single request. Clients should aim to

batch large event backlogs into a series of smaller requests in the

RecordEvents stream, being mindful of common limits in individual message

sizes: https://protobuf.dev/programming-guides/api/#bound-req-res-sizes

RecordEventsRequest.EventsPayload

FieldTypeLabelDescription
eventsEventrepeated

RecordEventsRequestMetadata

FieldTypeLabelDescription
request_idstring

Client-provided request identifier for diagnostics purposes.

identifierIdentifier

Telemetry publisher self-identification - for example, a Sourcegraph

instance of some other kind of service.

RecordEventsResponse

FieldTypeLabelDescription
succeeded_eventsstringrepeated

IDs of all events that were successfully recorded in the request.

Note that if succeeded_events is a subset of events that were submitted,

then some events failed to record and should be retried.

TelemeteryGatewayService

TelemetryGatewayService accepts telemetry and related data from Sourcegraph instances and managed services.

Method NameRequest TypeResponse TypeDescription
RecordEventsRecordEventsRequest streamRecordEventsResponse stream

RecordEvents streams telemetry events in batches to the Telemetry Gateway

service. Events should only be considered delivered if recording is

acknowledged in RecordEventsResponse.

This is the preferred mechanism for exporting large volumes of events in

bulk.

🚨 SECURITY: Callers exporting for single-tenant Sourcegraph should check

the attributes of the Event type to ensure that only the appropriate fields

are exported, as some fields should only be exported on an allowlist basis.

RecordEventRecordEventRequestRecordEventResponse

RecordEvent records a single telemetry event to the Telemetry Gateway service.

If the RPC succeeds, then the event was successfully published.

This RPC currently ONLY accepts events published by ManagedServiceIdentifier,

as this mechanism is intended for low-volume managed services. Higher-volume

use cases should implement a batching mechanism and use the RecordEvents

RPC instead.

🚨 SECURITY: Callers exporting for single-tenant Sourcegraph should check

the attributes of the Event type to ensure that only the appropriate fields

are exported, as some fields should only be exported on an allowlist basis.

PublishInstanceUserMetadataPublishInstanceUserMetadataRequest streamPublishInstanceUserMetadataResponse

PublishInstanceUserMetadata uploads additional user metadata from a

Sourcegraph instance. This matadata is used to enrich recorded events with

attributes that are considered sensitive and thus not part of the RecordEvents

and RecordEvent RPCs.

🚨 SECURITY: Callers exporting for single-tenant Sourcegraph should always

respect in-instance toggles for what user metadata should be exported.

Scalar Value Types

.proto TypeNotes
double
float
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.
uint32Uses variable-length encoding.
uint64Uses variable-length encoding.
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.
sfixed32Always four bytes.
sfixed64Always eight bytes.
bool
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.
bytesMay contain any arbitrary sequence of bytes.