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

moves clog into clues #56

Merged
merged 1 commit into from
Nov 4, 2024
Merged

moves clog into clues #56

merged 1 commit into from
Nov 4, 2024

Conversation

ryanfkeepers
Copy link
Contributor

Transferring Clog into Clues as a subpackage will solve:

  1. multi-package updates (clues -> clog -> something with both clog and clues)
  2. better preparation for OTEL support integration into clues and clog.
  3. sets up future extensions like metrics tracking via clues.

clog/README.md Outdated Show resolved Hide resolved
clog/builder.go Outdated Show resolved Hide resolved
//
// Unless you call this before initialization. Then it'll panic. We do want you to init
// the logger first, else you'll potentially lose these logs due different buffers.
func Singleton() *builder {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really a fan of having something like this. If we run into the situation described, it's probably a design issue that should be addressed. I'm concerned something like this will allow more design issues to slip through because they allow kind of papering over the root problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm back and forth on it. I do agree that not providing this method makes a good forcing function to resolve cases that would sloppily use it. I'm also aware that every now and then devs will hit a corner case where this sort of accessibility makes life much less painful or arduous. I'm not in a rush to do so, but we can take it out if there are strong feelings against the design. That's a two-way-door.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be best to remove something like this until we have more insight into what other SDKs clues will be used with (e.x. this wouldn't work if we needed to use it with temporal)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporal already has logging hooks built in, so there's no concerns with that. But, sure, I can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see: #67

}

// Returns the default location for log file storage.
func defaultLogLocation() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

setting the default location and using a global env var to set the location seem problematic. Now two programs that consume this package can't run on the same machine with the defaults, and it's not clear what could happen if people do run with the defaults

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Can we put a pin in this and follow up later? Current presumption is that live runs will feed to Stderr by default, not to log files, and that some background receiver will handle serialization of stderr logs to storage.

Copy link
Contributor

@ashmrtn ashmrtn Nov 4, 2024

Choose a reason for hiding this comment

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

I'm still rather uncomfortable with the assumptions being made about setup of the logging component. This is technically an open-source library and I'm sure we'd like to see usage in our own systems going forward. However, the logging setup has hidden configurations that will lead to difficult to debug issues if not noticed while also making some pretty heavy assumptions about usage in general (e.x. assume sent to stderr which isn't really the standard when it comes to outputting log files AFAIK)

If the goal is adoption and usage then, given that this is basically a core feature that everything is going to rely on, the implementation should be robust enough that folks can easily do what they need and are unlikely to hit unexpected issues (this kind of gets back to "how soon is later"?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no disagreement with your assesment. But is it really a blocker to punt on the issue for this PR? The code already matches this in the existing clog repo, so we're not avoiding the issue at this moment. And I will follow up on it. But this PR is supposed to be a copy-paste, not a fixup of the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see: #68

clog/logger.go Show resolved Hide resolved

for _, tt := range table {
suite.T().Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.expected, getValue(tt.value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not actually sure if this will just end up testing the interface test case a bunch of time since that's the type in the struct or if it will be testing the underlying types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we test both casses with this spread. I'll add some other cases for coverage, just to have that clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see: #69

Copy link
Contributor

Choose a reason for hiding this comment

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

I think maybe we're on slightly different trains of thought here? My concern is whether declaring the test table struct to have value any for the input will result in always testing the interface segment of the code under test since technically any is an alias to interface{}. If that is the way the code behaves, then adding additional test cases to this test won't change anything

I think to figure out how this is actually run, you'd need to add temporary print statements to the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think to figure out how this is actually run, you'd need to add temporary print statements to the code

Heh, no, I grok. And that's exactly what I did. All the other changes were because I figured I was already in the code and wanted to touch things up a bit.

@ashmrtn
Copy link
Contributor

ashmrtn commented Oct 17, 2024

sets up future extensions like metrics tracking via clues.

Overall, I think we need to be careful about scope creep. It's nice to have one thing that does everything and the kitchen sink, but the thing needs to work really well for that to really be a good situation. The larger the scope, the more likely it is for some areas or others to not be as high quality as we'd like

With a package like this, there's also the chance that we end up hooking together things in such a way that we're getting too much data back. Having too much data can be just as crippling as not having enough. If we really want to add metrics, we need to be very careful about doing so

@ryanfkeepers
Copy link
Contributor Author

If we really want to add metrics, we need to be very careful about doing so

Ah, metrics is intended to be a sort of isolated sub-package. I don't plan on a coupled implementatio with clues or clog as it stands. Expectation is for it to be loosely coupled in the way those two packages are. The primary connection being that the metrics subpackage would extract otel information from a clues context, the same way clog does in the next PR on this branch. Otherwise the goal is for it to feel separate and optional.

Transferring Clog into Clues as a subpackage will solve:
1. multi-package updates (clues -> clog -> something with both clog and
   clues)
2. better preparation for OTEL support integration into clues and clog.
3. sets up future extensions like metrics tracking via clues.
Copy link
Contributor

@ashmrtn ashmrtn left a comment

Choose a reason for hiding this comment

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

generally LGTM, unresolved comments still need addressed though

return b
}

// Label adds all of the appended labels to the error.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Label adds all of the appended labels to the error.
// Label adds all of the appended labels to the log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in another PR


for _, tt := range table {
suite.T().Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.expected, getValue(tt.value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think maybe we're on slightly different trains of thought here? My concern is whether declaring the test table struct to have value any for the input will result in always testing the interface segment of the code under test since technically any is an alias to interface{}. If that is the way the code behaves, then adding additional test cases to this test won't change anything

I think to figure out how this is actually run, you'd need to add temporary print statements to the code

@ryanfkeepers ryanfkeepers merged commit 5fd5083 into main Nov 4, 2024
1 check passed
@ryanfkeepers ryanfkeepers deleted the add-clog branch November 4, 2024 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants