Telemetry initialization is currently split between the service/telemetry package and the service package in the telemetry.go package. This causes some issues:
Parts of telemetry are initialized in service/telemetry, while others are initialized in service. In particular, the logger is initialized in service/telemetry, the tracer provider can be initialized in both but only the service one is used, and the metrics provider is only initialized in service.
One challenge here is that proctelemetry depends on service/telemetry for the generated configuration; if we don't want to expose the OpenCensus registry we need to refactor the current package structure (e.g. by having a new service/telemetry/config package).
cc @codeboten since this may overlap with the work on #7532
Telemetry initialization is currently split between the
service/telemetry
package and theservice
package in thetelemetry.go
package. This causes some issues:telemetry.TracerProvider
method returns a tracer provider that is never used in practice. It is used here https://github.com/open-telemetry/opentelemetry-collector/blob/3089ea878eef022913a053600f3599b3fddffb95/service/service.go#L103 and then immediately overridden by the telemetry initializer one. https://github.com/open-telemetry/opentelemetry-collector/blob/3089ea878eef022913a053600f3599b3fddffb95/service/service.go#L115 The telemetry initializer tracer provider is built from scratch https://github.com/open-telemetry/opentelemetry-collector/blob/3089ea878eef022913a053600f3599b3fddffb95/service/telemetry.go#L101-L111 without usingtelemetry.TracerProvider
. I believe because of this the sampling configuration set onservice/telemetry
is ignored. https://github.com/open-telemetry/opentelemetry-collector/blob/3089ea878eef022913a053600f3599b3fddffb95/service/telemetry/telemetry.go#L47-L50service/telemetry
, while others are initialized inservice
. In particular, the logger is initialized inservice/telemetry
, the tracer provider can be initialized in both but only theservice
one is used, and the metrics provider is only initialized inservice
.I think we should consolidate telemetry initialization to the
service/telemetry
package and have methods to generate the telemetry providers from config as part of the public API. This would mean adding a new method totelemetry.Telemetry
to handle registration of process metrics, currently done in the service via the telemetry initializer https://github.com/open-telemetry/opentelemetry-collector/blob/3089ea878eef022913a053600f3599b3fddffb95/service/service.go#L210-L211One challenge here is that
proctelemetry
depends onservice/telemetry
for the generated configuration; if we don't want to expose the OpenCensus registry we need to refactor the current package structure (e.g. by having a newservice/telemetry/config
package).cc @codeboten since this may overlap with the work on #7532