-
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
improvements for PR #1 #2
Conversation
…g), leaving almost only interfaces in OpenTracing.
…racing" (which equals nuget package name)
{ | ||
internal static readonly NullSpanContext Instance = new NullSpanContext(); | ||
|
||
private readonly Dictionary<string, string> _baggage = new Dictionary<string, string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there's no EMPTY_SET
like in Java?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's Enumerable.Empty<Type>()
for read-only lists (which returns a cached object), but there's no equivalent for dictionaries (maps) because they are mutable.
EOF for my comments... Basically looks really good overall, thanks again again. |
@bensigelman Is there anything from the comments above that we need to fix for this PR to be accepted? |
@dawallin I don't feel strongly about whether it happens before or after merging this PR, but I do think we should remove API surface area around SpanBuilder and/or StartSpanOptions before encouraging people to create dependencies on this code. On that note, here are pointers to how the startSpan calling code looks in other languages: Go: https://github.com/opentracing/opentracing-go/blob/master/tracer.go#L30 Python: https://github.com/opentracing/opentracing-python/blob/master/opentracing/tracer.py#L58 Javascript: https://github.com/opentracing/opentracing-javascript/blob/master/src/tracer.js#L33 It's important that the calling code has an easy way to adjust zero or more of the startSpan params without specifying all of them, and in that sense I think the SpanBuilder might actually be the part of the API we'd want to keep. Getting back to your question: I'd say "let's merge this", but please file issues about ^^^ as well as the fate of the helper/example implementations and so on. It would be good to see if @yurishkuro has any blocking concerns, too. |
Nope, since this isn't final. |
I added |
@@ -8,15 +11,15 @@ public static class Formats | |||
/// byte array instance. <see cref="ITracer.Inject"/> must append to the byte array carrier | |||
/// (rather than replace its contents).</para> | |||
/// </summary> | |||
public const string Binary = "binary"; | |||
public static readonly Format<byte[]> Binary = new Format<byte[]>("binary"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is byte array the right carrier for binary? I assume byte array has a fixed length, so especially for the injector how does the instrumentation know how long the tracing context in binary encoding will be? I don't know the native IO types in C#, but I would assume some sort of a byte buffer or i/o stream to be a better carrier than byte array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look this up. Probably not.
As of e9c8ae8, the format/carrier handling is now almost equal to the Java version.
I'm still not sure whether this is better or worse than our previous version 😄 but I guess it's more important to be equal to Java and solve any possible issues together when they arise. One thing I'm worried about is when we have a case where a format should accept multiple incompatible carriers. E.g. now I use Would be great if someone could merge this now. 😄 You could also give me contributor rights to this repository if you want - I would not do any non-trivial commits without a PR/your approval. |
I still have some problems with the format/carrier problem, but I will address that once this PR is accepted. |
We have now added some issues and made some changes according to the major comments. @bensigelman Is there anything more before you can accepting this PR ? |
@dawallin nope! I will just give you both write privs in this repo, you certainly have more C# knowledge than I. |
(done) |
awesome - thanks! |
Hi guys!
I came across this project yesterday and really like the idea, so I took Daniel's PR and tried to continue with it. That's what I've done:
General:
API:
IScopeContext
but IMO having the generics uglifies the API for end users and casting in the implementations is easy.DateTime
usages toDateTimeOffset
and used UTC everywhere.DateTime.Now
returns the local machine timezone and can't be used for such a library.DataTimeOffset
has in implicit cast fromDateTime
so it also accepts them and handles timezones correctly.ISpan
GetTracer()
- not in the spec and not necessary IMOSetTag
now acceptsobject
as the value. There's no base class for numeric types in C# and having separate overloads for each type would break all implementations whenever a new type should be added. I think it's better to leave this open and let the implementation decide whether the type is OK or not. An alternative would be to limit it tostruct
types (a separate overload for string would still be required though).SetBaggageItem
(which is a shortcut forContext.SetBaggageItem()
and typed methods for all built in tags (e.g.SetTagComponent
)ISpanContext
is now a separate interfaceITracer
no longer hasTryJoin
- instead it hasExtract
as defined in the spec.StartSpan
are inTracerExtensions.cs
IInjectCarrier
andIExtractCarrier
are now only marker interfaces and the different implementations are wrapper-objects around the carrier data structure (e.g. text-map, http-headers, byte array). Implementers have to decide based on this type how to inject/extract.NullTracer
-Null*
is more common in the .NET world thanNoop*
OpenTracing.Carrier.HttpClient:
OpenTracing
package (Propagation\HttpHeadersCarrier.cs
). I also changed the logic to no longer use the HttpClient as the carrier but instead theHttpHeaders
dictionary (which is part ofHttpRequestMessage
andHttpResponseMessage
). UsingHttpClient.DefaultRequestHeaders
was wrong becauseHttpClient
instances are often shared between requests. Therefore, the headers must be set for every individual request.OpenTracing.BasicTracer / OpenTracing.BasicTracer.Tests:
Usage: