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   荣锋亮  阅读(137)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-04-01 cube.js dremio driver基于补偿机制提升查询速度
2019-04-01 hasura graphql-engine 集成zombodb
2019-04-01 zombodb安装试用
2017-04-01 linux 磁盘挂载操作
2017-04-01 nginx 缓存处理
2016-04-01 jQuery.retryAjax
2015-04-01 C# 通用DataTable 拆分小表

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示