Sentry Protobuf Definitions (Generated Python Code)

0.8.12 · active · verified Fri Apr 17

sentry-protos provides the auto-generated Python code for Sentry's internal Protobuf definitions. It encapsulates the data structures used across various Sentry services, allowing Python applications to interact with Sentry's protobuf-based APIs. The library is actively maintained with frequent minor releases to incorporate new or updated protobuf schemas.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import a specific generated protobuf message (Snuba QueryRequest) and instantiate it, setting its fields. Remember to replace `snuba.v1` and `snuba_pb2` with the actual service and version you intend to use.

from sentry_protos.snuba.v1 import snuba_pb2

# Create a QueryRequest message
query_request = snuba_pb2.QueryRequest(
    dataset='events',
    query="MATCH (event) SELECT event.id"
)

print(f"Successfully created Snuba QueryRequest:")
print(f"  Dataset: {query_request.dataset}")
print(f"  Query: {query_request.query}")

# You can also set fields dynamically
another_query = snuba_pb2.QueryRequest()
another_query.dataset = 'transactions'
another_query.query = 'MATCH (transaction) SELECT transaction.duration'

print(f"\nAnother QueryRequest: {another_query.query}")

view raw JSON →