diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 377e531..adf875b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/bufbuild/buf - rev: v1.65.0 + rev: v1.68.4 hooks: - id: buf-lint - id: buf-format diff --git a/apis/workflows/v1/job.proto b/apis/workflows/v1/job.proto index 2d02502..3455886 100644 --- a/apis/workflows/v1/job.proto +++ b/apis/workflows/v1/job.proto @@ -5,6 +5,8 @@ edition = "2023"; package workflows.v1; import "buf/validate/validate.proto"; +import "opentelemetry/proto/logs/v1/logs.proto"; +import "opentelemetry/proto/trace/v1/trace.proto"; import "tilebox/v1/id.proto"; import "tilebox/v1/query.proto"; import "workflows/v1/core.proto"; diff --git a/apis/workflows/v1/telemetry.proto b/apis/workflows/v1/telemetry.proto new file mode 100644 index 0000000..06bce6f --- /dev/null +++ b/apis/workflows/v1/telemetry.proto @@ -0,0 +1,58 @@ +edition = "2023"; + +package workflows.v1; + +import "buf/validate/validate.proto"; +import "google/protobuf/timestamp.proto"; +import "opentelemetry/proto/logs/v1/logs.proto"; +import "opentelemetry/proto/trace/v1/trace.proto"; +import "tilebox/v1/id.proto"; +import "tilebox/v1/query.proto"; + +// SortDirection specifies the direction in which to sort log entries when querying logs. It can be used in combination +// with the cursor field in TelemetryPagination to paginate through log entries in either ascending or descending order. +enum SortDirection { + SORT_DIRECTION_UNSPECIFIED = 0; + // Sort in ascending order (oldest entries first). + SORT_DIRECTION_ASCENDING = 1; + // Sort in descending order (newest entries first). + SORT_DIRECTION_DESCENDING = 2; +} + +// QueryJobLogsRequest is the request message for querying logs of a specific job, in ascending or descending order, +// with pagination support. +message QueryJobLogsRequest { + // The ID of the job to query logs for. + tilebox.v1.ID job_id = 1 [(buf.validate.field).required = true]; + // The pagination parameters for this request. + tilebox.v1.Pagination page = 2 [features.field_presence = EXPLICIT]; + // The direction in which to sort log entries. If not specified, defaults to ascending order (oldest entries first). + SortDirection sort_direction = 3; +} + +// QueryLogsInIntervalRequest is the request message for querying logs in a specific time interval. +// It can be used to query all log messages across multiple jobs, and can be filtered by other parameters in the future. +message QueryLogsInIntervalRequest { + // The start time of the interval to query logs for. + tilebox.v1.TimeInterval time_interval = 1; + // The pagination parameters for this request. + tilebox.v1.Pagination page = 2 [features.field_presence = EXPLICIT]; + // The direction in which to sort log entries. If not specified, defaults to descending order (newest entries first). + SortDirection sort_direction = 3; +} + +// PaginatedLogsData is the response message for paginated log queries. It's a message compatible with LogsData, +// but with an additional field for pagination parameters for the next page. +message PaginatedLogsData { + // An array of ResourceLogs. + repeated .opentelemetry.proto.logs.v1.ResourceLogs resource_logs = 1; + // The pagination parameters for the next page. + tilebox.v1.Pagination next_page = 2 [features.field_presence = EXPLICIT]; +} + +// TelemetryQueryService is the service definition for querying telemetry data about workflows such as logs, traces +// and metrics. +service TelemetryQueryService { + rpc QueryJobLogs(QueryJobLogsRequest) returns (PaginatedLogsData); + rpc QueryLogsInInterval(QueryLogsInIntervalRequest) returns (PaginatedLogsData); +} diff --git a/buf.lock b/buf.lock index 49326c6..dba1a87 100644 --- a/buf.lock +++ b/buf.lock @@ -2,8 +2,11 @@ version: v2 deps: - name: buf.build/bufbuild/protovalidate - commit: 80ab13bee0bf4272b6161a72bf7034e0 - digest: b5:1aa6a965be5d02d64e1d81954fa2e78ef9d1e33a0c30f92bc2626039006a94deb3a5b05f14ed8893f5c3ffce444ac008f7e968188ad225c4c29c813aa5f2daa1 + commit: 50325440f8f24053b047484a6bf60b76 + digest: b5:74cb6f5c0853c3c10aafc701614194bbd63326bdb8ef4068214454b8894b03ba4113e04b3a33a8321cdf05336e37db4dc14a5e2495db8462566914f36086ba31 - name: buf.build/googleapis/googleapis - commit: 004180b77378443887d3b55cabc00384 - digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc + commit: c17df5b2beca46928cc87d5656bd5343 + digest: b5:648a01e0170d4512dea7d564016165decd1ed6e34bef79fe54753e51ad7e27545709ad9157d7551270147d551155c595a2fb0bf5bb33b1c83040ddbce915c604 + - name: buf.build/opentelemetry/opentelemetry + commit: 5f2c7d4f740541589805e0816dad4bb0 + digest: b5:935626c896cfe0f5efda467869c65df49843190c1d16ad24957d62ae840aef5f5da2474ec5c766e730b2727c6a24b39b5a2a073da70cf3f2611ce7d3934def86 diff --git a/buf.yaml b/buf.yaml index 9a992ec..91aca86 100644 --- a/buf.yaml +++ b/buf.yaml @@ -6,6 +6,7 @@ modules: deps: - buf.build/googleapis/googleapis - buf.build/bufbuild/protovalidate + - buf.build/opentelemetry/opentelemetry lint: # https://buf.build/docs/lint/rules/ use: # enable all linters - STANDARD