AsperforMias opened a new pull request, #3862:
URL: https://github.com/apache/dubbo-go/pull/3862
### Description
Fixes #3856
Metrics can only be exported in the Prometheus format, while traces already
go over OTLP. This adds an opt-in OTLP metrics exporter:
```yaml
dubbo:
metrics:
enable: true
otlp:
enabled: true
endpoint: otel-collector:4318
protocol: http # or grpc
insecure: true
export-interval: 30 # seconds
```
or `metrics.WithOtlpExporterEnabled()`, `WithOtlpEndpoint`, `WithOtlpGrpc`,
`WithOtlpInsecure` and `WithOtlpExportInterval`.
- It reads the same Prometheus registry through the OpenTelemetry Prometheus
bridge (`go.opentelemetry.io/contrib/bridges/prometheus`) and a periodic
reader, so metric names and labels are the same as on the Prometheus endpoint.
The resource carries the application name as `service.name`, as traces do, and
a per-process `service.instance.id` (unless `OTEL_RESOURCE_ATTRIBUTES` sets
one), since unlike a Prometheus scrape OTLP has no target to tell replicas
apart.
- The Prometheus endpoint and Pushgateway are unchanged, and nothing changes
unless `otlp.enabled` is set.
- The meter provider is shut down (with a final export) on graceful shutdown.
**Dependencies:** the bridge version matching OpenTelemetry v1.45 (v0.70.0)
requires `prometheus/client_golang` v1.24.1, up from v1.19.1, which also bumps
`client_model`, `common` and `procfs`. To check the Prometheus endpoint, I
compared `/metrics` from develop and this branch after the same calls: metric
names, `# TYPE` lines and the `requests_total` series are identical.
Verified end to end: a provider exporting to a local OTLP/HTTP receiver sent
`dubbo_provider_requests_total` = 5 for `greet.GreetService` after 5 calls,
with the same labels as on `/metrics` and `service.name` set to the application
name.
The same flow through an OpenTelemetry Collector into Prometheus, with the
provider's Prometheus endpoint disabled: the Collector's Prometheus exporter
maps `service.name` to `job` and `service.instance.id` to `instance`.

Tests cover export over HTTP and gRPC to in-process receivers, the final
export on shutdown, the instance ID, configuration errors, YAML-to-URL mapping
and config cloning.
### Checklist
- [x] I confirm the target branch is `develop`
- [x] I have run `make fmt` to format my code
- [x] I have run `make test` to run local tests
- [x] I have added tests that prove my fix is effective or that my feature
works
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]