signoz reader 接口定义

reader 属于signoz的核心,提供了数据的查询处理(包含service,metrics,trace。。。)

参考定义

pkg/query-service/app/interface.go

type Reader interface {
  GetChannel(id string) (*model.ChannelItem, *model.ApiError)
  GetChannels() (*[]model.ChannelItem, *model.ApiError)
  DeleteChannel(id string) *model.ApiError
  CreateChannel(receiver *am.Receiver) (*am.Receiver, *model.ApiError)
  EditChannel(receiver *am.Receiver, id string) (*am.Receiver, *model.ApiError)
 
  GetRule(id string) (*model.RuleResponseItem, *model.ApiError)
  ListRulesFromProm() (*model.AlertDiscovery, *model.ApiError)
  CreateRule(alert string) *model.ApiError
  EditRule(alert string, id string) *model.ApiError
  DeleteRule(id string) *model.ApiError
 
  GetInstantQueryMetricsResult(ctx context.Context, query *model.InstantQueryMetricsParams) (*promql.Result, *stats.QueryStats, *model.ApiError)
  GetQueryRangeResult(ctx context.Context, query *model.QueryRangeParams) (*promql.Result, *stats.QueryStats, *model.ApiError)
  GetServiceOverview(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceOverviewItem, error)
  GetServices(ctx context.Context, query *model.GetServicesParams) (*[]model.ServiceItem, error)
  // GetApplicationPercentiles(ctx context.Context, query *model.ApplicationPercentileParams) ([]godruid.Timeseries, error)
  GetServiceDBOverview(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceDBOverviewItem, error)
  GetServiceExternalAvgDuration(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceExternalItem, error)
  GetServiceExternalErrors(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceExternalItem, error)
  GetServiceExternal(ctx context.Context, query *model.GetServiceOverviewParams) (*[]model.ServiceExternalItem, error)
  GetTopEndpoints(ctx context.Context, query *model.GetTopEndpointsParams) (*[]model.TopEndpointsItem, error)
  GetUsage(ctx context.Context, query *model.GetUsageParams) (*[]model.UsageItem, error)
  GetOperations(ctx context.Context, serviceName string) (*[]string, error)
  GetTags(ctx context.Context, serviceName string) (*[]model.TagItem, error)
  GetServicesList(ctx context.Context) (*[]string, error)
  GetServiceMapDependencies(ctx context.Context, query *model.GetServicesParams) (*[]model.ServiceMapDependencyResponseItem, error)
  GetTTL(ctx context.Context, ttlParams *model.GetTTLParams) (*model.GetTTLResponseItem, *model.ApiError)
 
  // GetDisks returns a list of disks configured in the underlying DB. It is supported by
  // clickhouse only.
  GetDisks(ctx context.Context) (*[]model.DiskItem, *model.ApiError)
  GetSpanFilters(ctx context.Context, query *model.SpanFilterParams) (*model.SpanFiltersResponse, *model.ApiError)
  GetTagFilters(ctx context.Context, query *model.TagFilterParams) (*[]model.TagFilters, *model.ApiError)
  GetTagValues(ctx context.Context, query *model.TagFilterParams) (*[]model.TagValues, *model.ApiError)
  GetFilteredSpans(ctx context.Context, query *model.GetFilteredSpansParams) (*model.GetFilterSpansResponse, *model.ApiError)
  GetFilteredSpansAggregates(ctx context.Context, query *model.GetFilteredSpanAggregatesParams) (*model.GetFilteredSpansAggregatesResponse, *model.ApiError)
 
  GetErrors(ctx context.Context, params *model.GetErrorsParams) (*[]model.Error, *model.ApiError)
  GetErrorForId(ctx context.Context, params *model.GetErrorParams) (*model.ErrorWithSpan, *model.ApiError)
  GetErrorForType(ctx context.Context, params *model.GetErrorParams) (*model.ErrorWithSpan, *model.ApiError)
  // Search Interfaces
  SearchSpansAggregate(ctx context.Context, queryParams *model.SpanSearchAggregatesParams) ([]model.SpanSearchAggregatesResponseItem, error)
  SearchSpans(ctx context.Context, query *model.SpanSearchParams) (*[]model.SearchSpansResult, error)
  SearchTraces(ctx context.Context, traceID string) (*[]model.SearchSpansResult, error)
 
  // Setter Interfaces
  SetTTL(ctx context.Context, ttlParams *model.TTLParams) (*model.SetTTLResponseItem, *model.ApiError)
}
 

clickhouse 实现

clickhouse 的实现对于部分配置是直接存储在本地db中的,这点不是很好,但是可以通过自己扩展支持其他db
对于metrics 以及trace 使用了prometheus 以及clickhouse 的查询处理,整体实现代码不难,但是还是很值得借鉴的

参考资料

https://github.com/SigNoz/signoz

posted on 2022-04-01 23:13  荣锋亮  阅读(134)  评论(0编辑  收藏  举报

导航