Skip to content

refactor(container-runtime): Tighten up exposure of ContainerRuntime's logger#20839

Merged
chentong7 merged 4 commits into
microsoft:mainfrom
chentong7:container-runtime
May 14, 2024
Merged

refactor(container-runtime): Tighten up exposure of ContainerRuntime's logger#20839
chentong7 merged 4 commits into
microsoft:mainfrom
chentong7:container-runtime

Conversation

@chentong7
Copy link
Copy Markdown
Contributor

Description

ContainerRuntime.logger is currently public, though ideally, it should not be, and it uses an internal type instead of the preferable base type. When sharing the logger, the standard practice should be to pass around the base logger, allowing each consumer to create a ChildLogger from it.

Changes

  • Rename ContainerRuntime.logger to ContainerRuntime.baseLogger, change its type to ITelemetryBaseLogger, and set its access level to private.

  • Adjust the dependencies that receive the logger to accept the ITelemetryBaseLogger type and utilize createChildLogger to create a child logger as needed (this operation will be a no-op if the logger is already a child logger).

  • Modify the following classes in Fluid Framework (FF) so they no longer directly access the logger from the runtime but instead receive their own base logger via constructor parameters:

BlobManager
Summarizer
DataStoreContext

  • DataStoreContext currently makes the same logger available through its public API. This may be unnecessary—as indicated by its lack of use in the FF codebase—especially since IFluidDataStoreRuntime already exposes a logger. This exposure could potentially be removed to streamline the API and enhance encapsulation.

@github-actions github-actions Bot added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct area: runtime Runtime related issues public api change Changes to a public API base: main PRs targeted against main branch labels Apr 25, 2024
@chentong7 chentong7 requested a review from markfields April 25, 2024 18:02
@msfluid-bot
Copy link
Copy Markdown
Collaborator

msfluid-bot commented Apr 25, 2024

@fluid-example/bundle-size-tests: +385 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 454.95 KB 455.04 KB +97 Bytes
azureClient.js 552.06 KB 552.16 KB +97 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 258.8 KB 258.89 KB +94 Bytes
fluidFramework.js 357.54 KB 357.54 KB No change
loader.js 132.78 KB 132.78 KB No change
map.js 41.45 KB 41.45 KB No change
matrix.js 143.67 KB 143.67 KB No change
odspClient.js 520.6 KB 520.69 KB +97 Bytes
odspDriver.js 97.29 KB 97.29 KB No change
odspPrefetchSnapshot.js 42.15 KB 42.15 KB No change
sharedString.js 160.19 KB 160.19 KB No change
sharedTree.js 357.53 KB 357.53 KB No change
Total Size 3.2 MB 3.2 MB +385 Bytes

Baseline commit: a5f84ed

Generated by 🚫 dangerJS against b201e17

Comment thread packages/runtime/container-runtime/api-report/container-runtime.api.md Outdated
Comment thread packages/runtime/container-runtime/src/containerRuntime.ts Outdated
@chentong7 chentong7 force-pushed the container-runtime branch from 8d2cad9 to 929e123 Compare May 14, 2024 00:17
Copy link
Copy Markdown
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still uneasy with the changes here. Didn't we decide to update it to be completely non-breaking to anything? Just add the new baseLogger property where it makes sense and deprecate the old one, pointing users to use the new one? There's still plenty of alpha types that are getting breaking changes here.

Comment thread packages/runtime/container-runtime-definitions/package.json
"typeValidation": {
"broken": {
"InterfaceDeclaration_IDataObjectProps": {
"forwardCompat": false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert since we don't have changes in this package.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it does affected this package. Type error was thrown after rebasing from main

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, because the interface has a property of a type that we're breaking... so back to my general comment on the last review, I thought we had decided to make all changes here non-breaking?

@chentong7 chentong7 force-pushed the container-runtime branch from b9073b9 to c4cf077 Compare May 14, 2024 18:16
@chentong7 chentong7 requested a review from alexvy86 May 14, 2024 21:17
@chentong7 chentong7 merged commit cfc3353 into microsoft:main May 14, 2024
@chentong7 chentong7 deleted the container-runtime branch May 14, 2024 22:18
kekachmar pushed a commit to kekachmar/FluidFramework that referenced this pull request May 21, 2024
…s logger (microsoft#20839)

## Description

ContainerRuntime.logger is currently public, though ideally, it should
not be, and it uses an internal type instead of the preferable base
type. When sharing the logger, the standard practice should be to pass
around the base logger, allowing each consumer to create a ChildLogger
from it.

## Changes

* Rename ContainerRuntime.logger to ContainerRuntime.baseLogger, change
its type to ITelemetryBaseLogger, and set its access level to private.

* Adjust the dependencies that receive the logger to accept the
ITelemetryBaseLogger type and utilize createChildLogger to create a
child logger as needed (this operation will be a no-op if the logger is
already a child logger).

* Modify the following classes in Fluid Framework (FF) so they no longer
directly access the logger from the runtime but instead receive their
own base logger via constructor parameters:

BlobManager
Summarizer
DataStoreContext

* DataStoreContext currently makes the same logger available through its
public API. This may be unnecessary—as indicated by its lack of use in
the FF codebase—especially since IFluidDataStoreRuntime already exposes
a logger. This exposure could potentially be removed to streamline the
API and enhance encapsulation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct area: runtime Runtime related issues base: main PRs targeted against main branch public api change Changes to a public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants