telemetry(observations): fix the details flag check (#3960)
* telemetry(observations): fix the details flag check * telemetry(observations): fix the test names
This commit is contained in:
1 parent
b000aa3068
commit
4dce290aeb
6 files changed
+20
-8
No files matched your search
@@ -110,7 +110,8 @@ func WriteObservation(ctx context.Context, caller Op, opt ...Option) error {
|
||||
"%w", op, ErrInvalidParameter)
|
||||
}
|
||||
// For the case that the telemetry is not enabled, and we have events coming from interceptors.
|
||||
if !eventer.conf.TelemetryEnabled && (opts.withRequest != nil || opts.withResponse != nil) {
|
||||
// or the case that incoming call only has withDetails without enabling telemetry.
|
||||
if !eventer.conf.TelemetryEnabled && (opts.withRequest != nil || opts.withResponse != nil || opts.withDetails != nil) {
|
||||
return nil
|
||||
}
|
||||
// If telemetry is enabled, we add it to the options.
|
||||
|
||||
@@ -440,13 +440,18 @@ func Test_WriteObservation(t *testing.T) {
|
||||
cleanup: func() { event.TestResetSystEventer(t) },
|
||||
},
|
||||
{
|
||||
name: "simple",
|
||||
ctx: testCtx,
|
||||
telemetryFlag: true,
|
||||
observationPayload: testPayloads,
|
||||
header: testWantHeader,
|
||||
details: testWantDetails,
|
||||
observationSinkFileName: c.AllEvents.Name(),
|
||||
name: "simple-header",
|
||||
ctx: testCtx,
|
||||
telemetryFlag: true,
|
||||
observationPayload: testPayloads,
|
||||
header: testWantHeader,
|
||||
},
|
||||
{
|
||||
name: "simple-details",
|
||||
ctx: testCtx,
|
||||
telemetryFlag: true,
|
||||
observationPayload: testPayloads,
|
||||
details: testWantDetails,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -483,6 +488,7 @@ func Test_WriteObservation(t *testing.T) {
|
||||
if !tt.telemetryFlag {
|
||||
require.Nil(event.WriteObservation(tt.ctx, event.Op(tt.name), event.WithRequest(tt.Request),
|
||||
event.WithResponse(tt.Response)))
|
||||
require.Nil(event.WriteObservation(tt.ctx, event.Op(tt.name), event.WithDetails(tt.details)))
|
||||
}
|
||||
if tt.observationSinkFileName != "" {
|
||||
defer func() { _ = os.WriteFile(tt.observationSinkFileName, nil, 0o666) }()
|
||||
|
||||
Reference in new issue
Block a user