Interrogate orchestrion for trace id and span id? #638
Replies: 3 comments 2 replies
-
Hi @ksargent1216 , Yes, this is possible in some cases! Can you confirm which log library you're using? |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late reply. We are currently working on a Zap integration that will help both dd-trace-go manual instrumented and orchestrion users. This integration will automatically add Span and Traces IDs into your Zap logs. If everything goes to plan it will be made available in next release Quick question about your Zap usage, are you using the structured logger (default one) or a Sugared one ?
|
Beta Was this translation helpful? Give feedback.
-
Benjamin, thanks for reaching out and for the update. We’re using both across the ecosystem. Here are two examples of Sugared…
1…
"gitlab.com/ciorg/bridge/sbc/observability/metrics"
"go.uber.org/zap"
)
sugaredLogger, err := logging.NewSugar(prefix)
if err != nil {
fastLogger.Info("success",
zap.Time("oneHourAgo", oneHourAgo),
zap.Int("ten", 10),
zap.Any("message", exampleMessage),
zap.String("logger", "fast"),
)
)
sugaredLogger.Infow("success",
"oneHourAgo", oneHourAgo,
"message", exampleMessage,
"logger", "sugar",
)
2…
s Service
l *zap.SugaredLogger
}
func NewHandler(s Service, l *zap.SugaredLogger) *Handler {
return &Handler{
"go.uber.org/zap"
h.l.Infow("batch-analyzer completed processing",
zap.Any("start-status", status),
zap.Any("end-status", r.Status),
zap.String("global-id", r.SupporterGlobalID))
processed++
h.l.Infow("done running",
zap.Int("records-processed", processed),
zap.Any("records-initial-status", status))
return nil
Here are two examples of zap with the structured logger…
3….
// NewZapLogger creates a new logger
func NewZapLogger() (*zap.Logger, zap.AtomicLevel) {
consoleOutput := zapcore.AddSync(os.Stdout)
consoleEncoder := zapcore.NewJSONEncoder(zapcore.EncoderConfig{
TimeKey: "Timestamp",
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
level := zap.NewAtomicLevel()
zapCore := zapcore.NewCore(consoleEncoder, consoleOutput, level)
return zap.New(zapCore), level
}
case "debug":
return zap.DebugLevel
case "warn":
return zap.WarnLevel
case "error":
return zap.ErrorLevel
default:
return zap.InfoLevel
}
StacktraceKey: "Stack",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: zapcore.CapitalLevelEncoder,
EncodeDuration: zapcore.StringDurationEncoder,
EncodeCaller: zapcore.ShortCallerEncoder,
EncodeTime: zapcore.RFC3339TimeEncoder,
})
4…
package zaplogger
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
StacktraceKey: "Stack",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: zapcore.CapitalLevelEncoder,
EncodeDuration: zapcore.StringDurationEncoder,
EncodeCaller: zapcore.ShortCallerEncoder,
})
level := zap.NewAtomicLevel()
zapCore := zapcore.NewCore(consoleEncoder, consoleOutput, level)
return zap.New(zapCore), level
}
// New creates a new zap logger and configurable logging level
func New() (*zap.Logger, zap.AtomicLevel) {
consoleOutput := zapcore.AddSync(os.Stdout)
consoleEncoder := zapcore.NewJSONEncoder(zapcore.EncoderConfig{
TimeKey: "Timestamp",
Let me know if you have any further questions or want to see anything else.
Thanks!
Kenny
From: Benjamin De Bernardi ***@***.***>
Date: Wednesday, June 25, 2025 at 2:31 AM
To: DataDog/orchestrion ***@***.***>
Cc: Kenny Sargent ***@***.***>, Mention ***@***.***>
Subject: Re: [DataDog/orchestrion] Interrogate orchestrion for trace id and span id? (Discussion #638)
Hi @ksargent1216<https://github.com/ksargent1216>
Sorry for the late reply.
We are currently working on a Zap integration that will help both dd-trace-go manual instrumented and orchestrion users.
This integration will automatically add Span and Traces IDs into your Zap logs. If everything goes to plan it will be made available in next ***@***.*** in July.
Quick question about your Zap usage, are you using the structured logger (default one) or a Sugared one ?
* If it's a Sugared one, which functions are you using ? Supporting Infof and Infoln functions is not trivial, they imply modifying parsing rules as the data is sent in the message and not log fields.
—
Reply to this email directly, view it on GitHub<#638 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEI3HUGAY6LTRV23GWSREFL3FJM2XAVCNFSM6AAAAAB6Q6B642VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNJXGA4TOMY>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to retrieve a trace id or span id (or both) so they can be logged as part of a log statement? I'm using native orchestrion (no manual instrumentation) and the //dd:span directive on functions. I'm not sure if I'm asking the right question. The goal is to link APM traces in Datadog with the associated logs. Any help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions