Skip to content
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

Metadata storage type & enable MDC storage use cases #37

Open
ktoso opened this issue Apr 8, 2019 · 0 comments
Open

Metadata storage type & enable MDC storage use cases #37

ktoso opened this issue Apr 8, 2019 · 0 comments
Labels
kind/enhancement Improvements to existing feature.

Comments

@ktoso
Copy link
Member

ktoso commented Apr 8, 2019

This is the "later" follow up ticket to the "take out metadata to start with and make opaque later #31".

One use case of being able to "take the entire metadata" is keeping around data that is set for the lifetime of a resource, so a library may want to "1) store it 2) run user code, allowing it to shadow or remove metadata etc 3) restore the metadata for the next invocation"

This pattern is sometimes useful, and would be nice if we could support it, esp since without a "give me the metadata" a framework can not implement this without knowing all the keys that it should keep+restore.

Example test:

    func testMDCStyleMetadata() {
        let testLogging = TestLogging()
        LoggingSystem.bootstrapInternal(testLogging.make)

        var logger = Logger(label: "\(#function)")
        logger[metadataKey: "always"] = "there"

        func userCode() {
            logger[metadataKey: "always"] = "other"
            logger.info("hello world!")

            testLogging.history.assertExist(level: .info, message: "hello world!", metadata: ["always": "other"])
        }

        let old = logger.metadata
        userCode()
        logger.metadata = old

        func userCode2() {
            logger.info("hello world!")
            testLogging.history.assertExist(level: .info, message: "hello world!", metadata: ["always": "there"])
        }
        userCode2()
    }
@ktoso ktoso changed the title Design Metadata storage type Design Metadata storage type & enable MDC storage use cases Apr 8, 2019
@ktoso ktoso changed the title Design Metadata storage type & enable MDC storage use cases Metadata storage type & enable MDC storage use cases Apr 8, 2019
@ktoso ktoso added the kind/enhancement Improvements to existing feature. label Jul 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements to existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant