-
Notifications
You must be signed in to change notification settings - Fork 73
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
Key-Value Logging instead of LogEvent #13
Conversation
@cwe1ss I think the way you describe to create a list of different generic types is usually how it is done, also the way I do it in #10 . +1 for the static factory method. Alternatively we could do something like |
(I did change to |
I renamed it to @dawallin if we would have |
Forget the LogFields builder. I agree that it is not worth adding more types and complexity. The static Field factory is enough. |
Java now uses two variations: Log(IEnumerable<KeyValuePair<string, object>> fields);
Log(string @event); // "event" is a reserved word in C# so we need the @prefix)
The new builtin Usage: // Using a Fields collection initializer (does not do unique key checks).
span.Log(new Fields {
{ "event", "soft error" },
{ "type", "cache timeout" },
{ "waited.millis", 1500 }
});
// Using the Fields factory methods (does not do unique key checks).
span.Log(Fields.Create("event", "soft error", "type", "cache timeout", "waited.millis", 1500));
// Using an arbitrary dictionary (does unique key checks).
span.Log(new Dictionary<string, object> {
{ "event", "soft error" },
{ "type", "cache timeout" },
{ "waited.millis", 1500 }
});
// Using the Fields collection with its Add method.
var fields = new Fields();
fields.Add("event", "soft error");
fields.Add("type", "cache timeout");
fields.Add("waited.millis", 1500);
span.Log(fields); Looking forward to your feedback!! |
resolves #9 * Already uses `DateTime` instead of `DateTimeOffset` (see #11) * @yurishkuro commented in the Java PR that the type could be called just "Field". I'll update this PR if they change it.
…introduce another concept
…upport non-dictionaries.
@bensigelman @dawallin @yurishkuro sorry to ping you again, but this is a blocker for a release. I think the main question here is just whether you think that having the custom It would be great if you could post a short feedback until Thursday. |
@cwe1ss just my two cents, but I would leave the Is |
Oh, one more thing: the enumerable of pairs allows for duplicate keys whereas a dictionary does not... comments should probably leave duplicate key semantics undefined since other languages don't even support them. |
I agree with @bensigelman and think we can wait with the extra code to keep the API as small as possible. But maybe it is time to start a util repository somewhere where we can try all these extensions out. |
@bensigelman Yes, |
The travis build is broken for the test project. Guess this is the problem: 1.0.x host is removed when installing 1.1 preview. Everything works on my machine. |
Having a possibility that does not do duplicate checks was intentional. my thinking was that people don't pass duplicate keys in 99,99%, so it's quite wasteful to do the duplicate checks. We could have left it to the trace implementations to decide whether they want to check the duplicates or not. But I'll change it to accept only dictionaries with unique keys ( I'll also remove the |
@cwe1ss I'm actually ok with the |
OK - then I'll keep it :) |
I removed the fields type and added a comment. I'll merge this right now since this is the last open issue for a release. I'll do a final check in the master-branch myself and will then ask you for a final review before I'll actually release it. |
resolves #9
As expected, it's not possible in C# to use types with different generics in one List (like
LogField<?>
in Java).It would be possible to use the following workaround, but implementations would have to cast/resolve the type anyway.
Open questions/tasks:
DateTime
instead ofDateTimeOffset
- DateTime instead of DateTimeOffset; resolves #4 #11 should be merged first.LogField.Create(string key, object value)
)? What would be the benefit?