-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace.NewTracerProvider logs configuration before storing spanProcessors #3568
Comments
May I help with this? @MrAlias |
Thanks for ur advice! @kmai I've tested the issue as you mentioned above. All of the config msg(such as It's also possible that I misunderstood. Could you please offer more info to point out where the problem is? Thanks. |
Hi @hanyuancheung! When I start my application with the following snippet (just to try out logging when dealing with some troubleshooting): // Initialize Subsystems
logRus := providers.LoggingInit()
var logger logr.Logger
if zapLogger, err := zap.NewDevelopment(); err != nil {
logRus.Panic(fmt.Errorf("error while instantiating logger for OTEL: %w", err))
} else {
logger = zapr.NewLogger(zapLogger)
}
otel.SetLogger(logger)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
tracerProvider, err := providers.TracerInit()
if err != nil {
logRus.Warnf("error while initializing tracing subsystem: %v", err)
}
defer middleware.TracingShutdownSignal(ctx, tracerProvider)
// Register our TracerProvider as the global so any imported
// instrumentation in the future will default to using it.
otel.SetTracerProvider(tracerProvider)
otel.SetTextMapPropagator(b3.New(b3.WithInjectEncoding(b3.B3MultipleHeader))) I instantiate the TracerProvider with a Prometheus Exporter. The debug log dumps the struct configuration, but it shows the spanProcessors empty, while I should see a single one with my configured exporter: {
"config": {
"SpanProcessors": [
{}
],
"SamplerType": "trace.alwaysOnSampler",
"IDGeneratorType": "*trace.randomIDGenerator",
"SpanLimits": {
"AttributeValueLengthLimit": -1,
"AttributeCountLimit": 128,
"EventCountLimit": 128,
"LinkCountLimit": 128,
"AttributePerEventCountLimit": 128,
"AttributePerLinkCountLimit": 128
},
"Resource": [
{
"Key": "deployment.environment",
"Value": {
"Type": "STRING",
"Value": "development"
}
},
{
"Key": "host.name",
"Value": {
"Type": "STRING",
"Value": "192-168-0-74.static.private.lan"
}
},
{
"Key": "process.command_args",
"Value": {
"Type": "STRINGSLICE",
"Value": [
"/private/var/folders/p5/n87t8_wj24q7jg6r6dqjb2hr0000gn/T/GoLand/___Build_Server"
]
}
},
{
"Key": "process.executable.name",
"Value": {
"Type": "STRING",
"Value": "___Build_Server"
}
},
{
"Key": "process.executable.path",
"Value": {
"Type": "STRING",
"Value": "/private/var/folders/p5/n87t8_wj24q7jg6r6dqjb2hr0000gn/T/GoLand/___Build_Server"
}
},
{
"Key": "process.owner",
"Value": {
"Type": "STRING",
"Value": "kmai"
}
},
{
"Key": "process.pid",
"Value": {
"Type": "INT64",
"Value": 42386
}
},
{
"Key": "process.runtime.description",
"Value": {
"Type": "STRING",
"Value": "go version go1.19.4 darwin/arm64"
}
},
{
"Key": "process.runtime.name",
"Value": {
"Type": "STRING",
"Value": "go"
}
},
{
"Key": "process.runtime.version",
"Value": {
"Type": "STRING",
"Value": "go1.19.4"
}
},
{
"Key": "service.name",
"Value": {
"Type": "STRING",
"Value": "example-service"
}
}
]
}
} I expected to see my exporter configured, but I don't! Let me know if you need the full codebase. |
This looks to be I think the fix would be: |
Description
TracerProvider creation logs incomplete configuration, leaving out defined
SpanProcessor
structs.Environment
Steps To Reproduce
logr
compatible logger with verbosity set higher than 5 (as per OTEL documentation, to enable debug logging).go.opentelemetry.io/otel/sdk/trace.NewTracerProvider()
, with a configuredSpanProcessor
SpanProcessors
as empty.Expected behavior
The log message should promptly display the full configuration of the
TraceProvider
struct.Comments
I believe the offending block of code is the following:
As you can see,
tp.spanProcessors.Store(spss)
is called after the log entry has been created. For that reason, thespanProcessors
attribute is empty on the log message.The text was updated successfully, but these errors were encountered: