Skip to content

Commit

Permalink
[service] use mdatagen for service metrics
Browse files Browse the repository at this point in the history
This reverts the reverts open-telemetry#10271 and adds a mechanism to skip adding a create settings method for the service package component test. Will need to figure out if servicetelemetry.TelemetrySettings should be renamed to fit w/ the other CreateSettings structs before removing this check.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed Jun 7, 2024
1 parent 0d6e6bf commit 58a946a
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 88 deletions.
5 changes: 5 additions & 0 deletions cmd/mdatagen/templates/component_telemetry_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ import (
sdkmetric "go.opentelemetry.io/otel/sdk/metric"

"go.opentelemetry.io/collector/component"
{{- if or isConnector isExporter isExtension isProcessor isReceiver }}
"go.opentelemetry.io/collector/{{ .Status.Class }}"
"go.opentelemetry.io/collector/{{ .Status.Class }}/{{ .Status.Class }}test"
{{- end }}
)

type componentTestTelemetry struct {
reader *sdkmetric.ManualReader
meterProvider *sdkmetric.MeterProvider
}

{{- if or isConnector isExporter isExtension isProcessor isReceiver }}
func (tt *componentTestTelemetry) NewSettings() {{ .Status.Class }}.Settings {
settings := {{ .Status.Class }}test.NewNopSettings()
settings.MeterProvider = tt.meterProvider
Expand All @@ -29,6 +32,8 @@ func (tt *componentTestTelemetry) NewSettings() {{ .Status.Class }}.Settings {
return settings
}

{{- end }}

func setupTestTelemetry() componentTestTelemetry {
reader := sdkmetric.NewManualReader()
return componentTestTelemetry{
Expand Down
55 changes: 55 additions & 0 deletions service/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# service

## Internal Telemetry

The following telemetry is emitted by this component.

### process_cpu_seconds

Total CPU user and system time in seconds

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| s | Sum | Double | true |

### process_memory_rss

Total physical memory (resident set size)

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| By | Gauge | Int |

### process_runtime_heap_alloc_bytes

Bytes of allocated heap objects (see 'go doc runtime.MemStats.HeapAlloc')

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| By | Gauge | Int |

### process_runtime_total_alloc_bytes

Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc')

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| By | Sum | Int | true |

### process_runtime_total_sys_memory_bytes

Total bytes of memory obtained from the OS (see 'go doc runtime.MemStats.Sys')

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| By | Gauge | Int |

### process_uptime

Uptime of the process

| Unit | Metric Type | Value Type | Monotonic |
| ---- | ----------- | ---------- | --------- |
| s | Sum | Double | true |
64 changes: 64 additions & 0 deletions service/generated_component_telemetry_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions service/generated_package_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

179 changes: 179 additions & 0 deletions service/internal/metadata/generated_telemetry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58a946a

Please sign in to comment.