Skip to content

Commit a47e27c

Browse files
codebotenchengchuanpeng
authored andcommitted
[cmd/opampsupervisor] report own metrics via OTLP (open-telemetry#37346)
1 parent 7dd08f4 commit a47e27c

File tree

3 files changed

+47
-56
lines changed

3 files changed

+47
-56
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: opampsupervisor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: report own metrics via OTLP instead of prometheus receiver
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [37346]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

cmd/opampsupervisor/supervisor/supervisor_test.go

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ func Test_onMessage(t *testing.T) {
364364
require.Equal(t, newID, s.persistentState.InstanceID)
365365
t.Log(s.cfgState.Load())
366366
mergedCfg := s.cfgState.Load().(*configState).mergedConfig
367-
require.Contains(t, mergedCfg, "prometheus/own_metrics")
368367
require.Contains(t, mergedCfg, newID.String())
369368
require.Contains(t, mergedCfg, "runtime.type: test")
370369
})
@@ -1129,27 +1128,16 @@ func TestSupervisor_setupOwnMetrics(t *testing.T) {
11291128
DestinationEndpoint: "localhost",
11301129
})
11311130

1132-
expectedOwnMetricsSection := `receivers:
1133-
# Collect own metrics
1134-
prometheus/own_metrics:
1135-
config:
1136-
scrape_configs:
1137-
- job_name: 'otel-collector'
1138-
scrape_interval: 10s
1139-
static_configs:
1140-
- targets: ['0.0.0.0:55555']
1141-
exporters:
1142-
otlphttp/own_metrics:
1143-
metrics_endpoint: "localhost"
1144-
1131+
expectedOwnMetricsSection := `
11451132
service:
11461133
telemetry:
11471134
metrics:
1148-
address: ":55555"
1149-
pipelines:
1150-
metrics/own_metrics:
1151-
receivers: [prometheus/own_metrics]
1152-
exporters: [otlphttp/own_metrics]
1135+
readers:
1136+
- periodic:
1137+
exporter:
1138+
otlp:
1139+
protocol: http/protobuf
1140+
endpoint: localhost
11531141
`
11541142

11551143
assert.True(t, configChanged)
@@ -1209,10 +1197,7 @@ func TestSupervisor_loadAndWriteInitialMergedConfig(t *testing.T) {
12091197
debug/remote:
12101198
`
12111199

1212-
const expectedMergedConfig = `exporters:
1213-
otlphttp/own_metrics:
1214-
metrics_endpoint: localhost
1215-
extensions:
1200+
const expectedMergedConfig = `extensions:
12161201
health_check:
12171202
endpoint: ""
12181203
opamp:
@@ -1226,30 +1211,20 @@ extensions:
12261211
insecure: true
12271212
receiver:
12281213
debug/remote: null
1229-
receivers:
1230-
prometheus/own_metrics:
1231-
config:
1232-
scrape_configs:
1233-
- job_name: otel-collector
1234-
scrape_interval: 10s
1235-
static_configs:
1236-
- targets:
1237-
- 0.0.0.0:55555
12381214
service:
12391215
extensions:
12401216
- health_check
12411217
- opamp
1242-
pipelines:
1243-
metrics/own_metrics:
1244-
exporters:
1245-
- otlphttp/own_metrics
1246-
receivers:
1247-
- prometheus/own_metrics
12481218
telemetry:
12491219
logs:
12501220
encoding: json
12511221
metrics:
1252-
address: :55555
1222+
readers:
1223+
- periodic:
1224+
exporter:
1225+
otlp:
1226+
endpoint: localhost
1227+
protocol: http/protobuf
12531228
resource:
12541229
service.name: otelcol
12551230
`
Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
receivers:
2-
# Collect own metrics
3-
prometheus/own_metrics:
4-
config:
5-
scrape_configs:
6-
- job_name: 'otel-collector'
7-
scrape_interval: 10s
8-
static_configs:
9-
- targets: ['0.0.0.0:{{.PrometheusPort}}']
10-
exporters:
11-
otlphttp/own_metrics:
12-
metrics_endpoint: "{{.MetricsEndpoint}}"
131

142
service:
153
telemetry:
164
metrics:
17-
address: ":{{.PrometheusPort}}"
18-
pipelines:
19-
metrics/own_metrics:
20-
receivers: [prometheus/own_metrics]
21-
exporters: [otlphttp/own_metrics]
5+
readers:
6+
- periodic:
7+
exporter:
8+
otlp:
9+
protocol: http/protobuf
10+
endpoint: {{.MetricsEndpoint}}

0 commit comments

Comments
 (0)