Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#10949 from fcfang123/issue-10891
Browse files Browse the repository at this point in the history
feat:活跃用户记录操作和次数 TencentBlueKing#10891
  • Loading branch information
bkci-bot authored Sep 11, 2024
2 parents 5a0e77b + ffa3850 commit 369a660
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ object MQ {
const val ROUTE_AUTH_RESOURCE_GROUP_MODIFY = "r.auth.resource.group.modify"
const val QUEUE_AUTH_RESOURCE_GROUP_MODIFY = "q.auth.resource.group.modify"

const val EXCHANGE_PROJECT_USER_DAILY_FANOUT = "e.metrics.project.user.daily.exchange.fanout"
const val QUEUE_PROJECT_USER_DAILY_METRICS = "q.metrics.project.user.daily.queue"
const val ROUTE_PROJECT_USER_DAILY_METRICS = "r.metrics.project.user.daily"
const val EXCHANGE_PROJECT_USER_DAILY_FANOUT = "e.metrics.project.user.daily.fanout"
const val QUEUE_PROJECT_USER_DAILY_METRICS = "q.metrics.project.user.daily.new.queue"

const val QUEUE_PROJECT_USER_DAILY_OPERATE_METRICS = "q.metrics.project.user.daily.operate.queue"
const val ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS = "r.metrics.project.user.daily.operate"
const val EXCHANGE_PROJECT_USER_DAILY_OPERATE = "e.metrics.project.user.daily.operate.exchange"
const val QUEUE_PROJECT_USER_DAILY_OPERATE_METRICS = "q.metrics.project.user.daily.operate.new.queue"
const val ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS = "r.metrics.project.user.daily.new.operate"

// 项目启用同步组和成员事件
const val QUEUE_PROJECT_ENABLED_SYNC_GROUP_AND_MEMBER = "q.project.enabled.sync.group.and.member"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ
import io.swagger.v3.oas.annotations.media.Schema
import java.time.LocalDate

@Event(exchange = MQ.EXCHANGE_PROJECT_USER_DAILY_FANOUT, routeKey = MQ.ROUTE_PROJECT_USER_DAILY_METRICS)
@Event(exchange = MQ.EXCHANGE_PROJECT_USER_DAILY_FANOUT)
data class ProjectUserDailyEvent(
@get:Schema(title = "项目ID")
override val projectId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.tencent.devops.common.event.annotation.Event
import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ
import io.swagger.v3.oas.annotations.media.Schema

@Event(exchange = MQ.EXCHANGE_PROJECT_USER_DAILY_FANOUT, routeKey = MQ.ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS)
@Event(exchange = MQ.EXCHANGE_PROJECT_USER_DAILY_OPERATE, routeKey = MQ.ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS)
data class ProjectUserOperateMetricsEvent(
@get:Schema(title = "项目用户操作度量数据")
val userOperateCounterData: UserOperateCounterData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ class MetricsListenerConfiguration {
}

/**
* 用户审计数据上报交换机
* 插件监控数据上报广播交换机
*/
@Bean
fun projectUserDailyMetricsExchange(): DirectExchange {
val directExchange = DirectExchange(MQ.EXCHANGE_PROJECT_USER_DAILY_FANOUT, true, false)
directExchange.isDelayed = true
return directExchange
fun projectUserDailyMetricsFanoutExchange(): FanoutExchange {
val fanoutExchange = FanoutExchange(MQ.EXCHANGE_PROJECT_USER_DAILY_FANOUT, true, false)
fanoutExchange.isDelayed = true
return fanoutExchange
}

@Bean
Expand All @@ -115,10 +115,10 @@ class MetricsListenerConfiguration {
@Bean
fun projectUserDailyMetricsQueueBind(
@Autowired projectUserDailyMetricsQueue: Queue,
@Autowired projectUserDailyMetricsExchange: DirectExchange
@Autowired projectUserDailyMetricsFanoutExchange: FanoutExchange
): Binding {
return BindingBuilder.bind(projectUserDailyMetricsQueue)
.to(projectUserDailyMetricsExchange).with(MQ.ROUTE_PROJECT_USER_DAILY_METRICS)
.to(projectUserDailyMetricsFanoutExchange)
}

@Bean
Expand All @@ -142,16 +142,26 @@ class MetricsListenerConfiguration {
)
}

/**
* 用户操作度量数据上报交换机
*/
@Bean
fun projectUserDailyOperateMetricsExchange(): DirectExchange {
val directExchange = DirectExchange(MQ.EXCHANGE_PROJECT_USER_DAILY_OPERATE, true, false)
directExchange.isDelayed = true
return directExchange
}

@Bean
fun projectUserDailyOperateMetricsQueue() = Queue(QUEUE_PROJECT_USER_DAILY_OPERATE_METRICS)

@Bean
fun projectUserDailyOperateMetricsQueueBind(
@Autowired projectUserDailyOperateMetricsQueue: Queue,
@Autowired projectUserDailyMetricsExchange: DirectExchange
@Autowired projectUserDailyOperateMetricsExchange: DirectExchange
): Binding {
return BindingBuilder.bind(projectUserDailyOperateMetricsQueue)
.to(projectUserDailyMetricsExchange).with(MQ.ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS)
.to(projectUserDailyOperateMetricsExchange).with(MQ.ROUTE_PROJECT_USER_DAILY_OPERATE_METRICS)
}

@Bean
Expand Down

0 comments on commit 369a660

Please sign in to comment.