Skip to content

Conversation

@shunjiazhu
Copy link
Contributor

@shunjiazhu shunjiazhu commented Dec 21, 2025

Change-Id: I74af3156bbc37e047cfc7f7b6c26a807973aceb5

  1. 自监控API,支持在打点时动态的传入TagValue,用于观测在插件初始化时无法确定label value的场景,比如http code等。
// ExportMetricRecords exports all metrics bound to this metric record.
// The results may be a list of map[string]string, each map[string]string is a set of measurements has the same labels.
// for example:
// []{
// {"counters":"{\"http_flusher_dropped_events\":\"3.0000\",\"http_flusher_flush_failure_count\":\"6.0000\",\"http_flusher_matched_events\":\"1.0000\",\"http_flusher_retry_count\":\"5.0000\",\"http_flusher_unmatched_events\":\"2.0000\"}","gauges":"{\"http_flusher_flush_latency_ns\":\"7.0000\"}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\"}"}
// {"counters":"{\"http_flusher_status_code_count\":\"8.0000\"}","gauges":"{}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\",\"status_code\":\"200\"}"}
// {"counters":"{\"http_flusher_status_code_count\":\"9.0000\"}","gauges":"{}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\",\"status_code\":\"400\"}"}
// {"counters":"{\"http_flusher_error_count\":\"10.0000\"}","gauges":"{}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\",\"level\":\"error\",\"reason\":\"timeout\"}"}
// {"counters":"{\"http_flusher_error_count\":\"11.0000\"}","gauges":"{}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\",\"level\":\"warn\",\"reason\":\"retry\"}"}
// {"counters":"{\"http_flusher_error_count\":\"12.0000\"}","gauges":"{}","labels":"{\"PluginId\":\"13\",\"PluginType\":\"flusher_http\",\"RemoteURL\":\"http://localhost:8081\",\"level\":\"error\",\"reason\":\"dropped\"}"}
// }
// Note:
// A metric may have three levels of labels
// 1. MetricsRecord Level Const Labels, like PluginType=flusher_http, PluginId=1
// 2. Metric Level Const Labels, for example, flusher_http may have a const label: RemoteURL=http://aliyun.com/write
// 3. Metric Level Dynamic Labels, like status_code=200, status_code=204
  1. 自监控支持序列过期,当一个指标的一个特定的Tags组合长期没有打点时,允许其gc掉,防止因为内存中常驻维度过高而产生的内存开销。
	cumulativeCounter := NewCumulativeCounterMetricVector("test", constLabels, getTagNames(allTags),
		WithExpiration(time.Hour),
		WithCardinalityLimit(1000),
	)

Change-Id: I74af3156bbc37e047cfc7f7b6c26a807973aceb5
…mic-labels

Change-Id: Ic6dc62cf5675332857d79385be33f522c9f8c97c
Change-Id: I68d30400a1c319ed3a79235c4931825c907b20b8
Change-Id: If2681139c5acec1ea11b317558cf92b63b3fa48e
Change-Id: Id1d9a4eafd958bee780a617db5874d587f0148cb
Change-Id: I7054bded1154c5d653129262e052215f0106f5a3
Change-Id: I61956711952f596559f9be940cfd746d60191403
…mic-labels

Change-Id: Ica0541be7679d97cbd81b1f598e5c2865e047841
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant