(REPRO) Trace messaging issues repro #1048
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This change creates a repro resource, tests, and example configuration to enumerate issues with the current model for bubbling up trace messages from resources.
The
resources/repro.trace
folder contains the relevant files:repro.trace.dsc.resource.json
- resource manifestrepro.trace.resource.ps1
- resource scriptrepro.trace.tests.ps1
- failing tests for behaviorrepro.config.dsc.yaml
- config file with every repro caserepro.config.result.yaml
- snapshot of output from configThe repro covers several test cases to show how DSC behaves when a resource emits trace messages as compressed JSON to stderr:
simpleMessaging
shows the behavior for emitting a string for a given trace level, like{"warn":"my warning"}
.minimalStruct
shows the behavior for emitting a struct that defines thelevel
,timestamp
, andfields.message
properties.structWithMetadata
also defines thetarget
andlineNumber
properties to bubble up for the resource.structWithAdditionalFields
defines fields.extraString
andfields
extraInteger` to bubble up related context.structWithMetadataAndAdditionalFields
includes definestarget
,lineNumber
,fields.extraString
, andfields.extraInteger
.The resource itself returns the name of the test case and uses the
emittedData
read-only property to return the data that it emitted to stderr for DSC to interpret as a trace message.Findings:
timestamp
,target
,lineNumber
, and additional fields are all ignored or dropped.PID 1234: <message>
.trace_message
field instead ofmessage
.dsc config get
, DSC doesn't seem to capture the emitted messages in the result object, only emitting them to stderr.This repro shows that we have some unexpected behaviors for resource messaging that may guide a review and update of the implementation.
PR Context
While working on the resource authoring design guide, I started to write up how and when a resource author should implement trace messaging for the resource. To accurately advise authors, I needed a better understanding of how to implement tracing and how it would behave when invoked through DSC.