Closed ykvichare closed 4 years ago
Can you post the complete method where it is hooked up? Also do a .ToString() on your tracer and post the output to see if everything was wired up correctly, but looks fine on first view. Are you using ASP.NET Core? If yes, are you using the OpenTacing.Contrib.NetCore package?
Hello, Thanks for your suggestion. I am using opentracing with Asp.net and C#. Jaeger version : 0.3.6 Opentracing version : 0.12.0 .Net Framework : 4.6.1
Traces Output : Tracer(ServiceName=DotNet4.5, Version=CSharp-0.3.6.0, Reporter=CompositeReporter(Reporters=RemoteReporter(Sender=HttpSender), LoggingReporter(Logger=Microsoft.Extensions.Logging.Logger`1[Jaeger.Reporters.LoggingReporter])), Sampler=GuaranteedThroughputSampler(ProbabilisticSampler=ProbabilisticSampler(PositiveSamplingBoundary=9223372036854775807, NegativeSamplingBoundary=-9223372036854775808, SamplingRate=1), LowerBoundSampler=RateLimitingSampler(MaxTracesPerSecond=1, Tags=[sampler.type, ratelimiting], [sampler.param, 1]), Tags=[sampler.type, lowerbound], [sampler.param, 1]), IPv4=ID, Tags=[jaeger.version, CSharp-0.3.6.0], [hostname, HostName], [ip, IPAddress], ZipkinSharedRpcSpan=False, ExpandExceptionLogs=False, UseTraceId128Bit=False)
public void jaegerEndPointConfiguration(string ServiceName) { JaegerTracingOptions options = new JaegerTracingOptions();
try
{
options.ServiceName = ServiceName;
options.JaegerEndPoint = "https://HostName:448/api/traces";
options.JaegerAgentHost = "HostName";
options.JaegerAgentPort = 448;
var senderConfig = new Jaeger.Configuration.SenderConfiguration(options.LoggerFactory)
.WithAgentHost(options.JaegerAgentHost)
.WithAgentPort(options.JaegerAgentPort)
.WithAuthToken("tokenkey")
.WithEndpoint(options.JaegerEndPoint);
var reporter = new RemoteReporter.Builder()
.WithLoggerFactory(options.LoggerFactory)
.WithMaxQueueSize(100) // optional, defaults to 100
.WithFlushInterval(TimeSpan.FromSeconds(1)) // optional, defaults to TimeSpan.FromSeconds(1)
.WithSender(new Jaeger.Senders.HttpSender(options.JaegerEndPoint))
.Build();
var loggingReporter = new LoggingReporter(options.LoggerFactory);
var compositeReporter = new CompositeReporter(reporter, loggingReporter);
var sampler = new GuaranteedThroughputSampler(0.1d, 1d);
//var sampler = new ConstSampler(true);
var tracer = new Tracer.Builder(options.ServiceName)
.WithLoggerFactory(options.LoggerFactory)
//.WithReporter(reporter)
.WithReporter(compositeReporter)
.WithSampler(sampler)
.Build();
//
using (IScope scope = tracer.BuildSpan("Dotnet")
.WithTag(Tags.SpanKind.Key, Tags.SpanKindClient)
.WithTag(Tags.Component.Key, "example-client")
.StartActive(finishSpanOnDispose: true))
{
scope.Span.Log("Testing4.5").Finish();
// _tracer.Inject(scope.Span.Context, BuiltinFormats.TextMap, new TextMapInjectAdapter(message));
// _queue.Add(message);
for (int i = 0; i <= 10000; i++)
{
// delay
}
tracer.ScopeManager.Activate(scope.Span,false);
}
if (!GlobalTracer.IsRegistered())
{
GlobalTracer.Register(tracer);
}
}
catch (Exception ex)
{
string error = ex.Message;
}
}
Could you please help me on this .
Where is this sample from? This also differs from what you posted yesterday. Are you using both or which one is in use? JaegerEndpoint is set to HostName instead of localhost in this one.
Based on the output, it is not using the ConstSampler, so there might be a GlobalTracer registered that is used instead of your code. Just comment out that if for testing to find out if that’s the case. Because in that case, it might also have another sender (to jaeger-collector probably) configured. Sadly, HttpSender is not showing that information there.
If you would use both (sample first and then the snippet from yesterday), that would explain the output. Then it would be registered to HostName and since it registers the global tracer, the other snippet is exiting and returning the first one again. Make sure to just use one of both codes. Either adjust the endpoint in the later sample (and use const sampler for testing instead of the probabilistic one) or use only the example from yesterday.
Hello, I am using Today's code , I am using IP instead of "HostName" . Basically I am trying with secure connection. Used ConstSampler and commented GlobalTracer registered code
Traceing output :
Tracer(ServiceName=DotNet4.5, Version=CSharp-0.3.6.0, Reporter=CompositeReporter (Reporters=RemoteReporter(Sender=HttpSender), LoggingReporter(Logger=Microsoft.Extensions.Logging.Logger`1 [Jaeger.Reporters.LoggingReporter])), Sampler=ConstSampler(True), IPv4=173540660, Tags=[jaeger.version, CSharp-0.3.6.0], [hostname, localhost], [ip, localhost], ZipkinSharedRpcSpan=False, ExpandExceptionLogs=False, UseTraceId128Bit=False)
How to use httpSender for establishing secure (HTTPS) connection ?
Can you post exactly the method that you use? Are you seeing the tracing in console or are they shown neither in console nor in endpoint? Because then it might not be related to configuration of the tracer but usage.
Let me guess: You probably need to dispose of the Tracer as well. If the (example?) program exits immediately after calling the shown method, the tracer's backing queue might not be flushed properly, effectively not reporting to the http endpoint.
Hello, For authentication Part, using SSL certificate for validation and establish connection between client and server, need to integrate below code RemoteReporter.
var httpClientHandler= new HttpClientHandler();
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.SecurityProtocol = Tls12;
// Read Certificate from keyfile.p12 file.
X509Certificate2 clientCertificate = new X509Certificate2(@"..\keyfile.p12", "Tsasxasxas.akldjskd");
handler.ClientCertificates.Add(clientCertificate);
handler.ServerCertificateCustomValidationCallback = delegate { return true; };
How to integrate httpClientHandler object with .WithSender() method ? I think need create custom HttpSender class , I am not sure how to integrate this code. FYI For access ( https:10.20.30.40:443/api/traces ) this API, don't have user/password or token key, We have keyfile.p12 certificate to accessing this API.
Could you please help me on this ?
Thanks, Yuvraj
HttpSender uses THttpHandler. This can receive a X509Certificate. But we currently don’t offer that constructor through the builder. You can copy the code of HttpSender and modify it so that you can use the correct constructor to see if it works. This will set the client certificate. I think the server certificate validation cant‘t also be disabled with THttpHandler right now.
It might be good to change the code to let the user define the HttpClient also directly through the builder as this is often done in different implementations like ASP.NET as singleton. I will give it a look next week if I’m not too full with customer projects. But for now, modifying THttpTransport and HttpSender would be your best bet until the PR is here. Feel free to push your test as PR.
... or implement that in the Jaeger Agent so that all language clients could use https transport immediately and you have the option to put the client certificate in a different process environment or container to keep it a bit safer.
@yurishkuro Does the jaeger-agent support client certificates?
No it won’t even use http as a transport for architectural reasons burdening the work on all clients. Questionable IMHO.
@Lercher It uses http for the connection to jaeger-collector, where the client certificate would be needed. HttpSender also just talks to jaeger-collector and skips the agent.
How Can I proceed with client certificate on above scenario ?
I guess, https://github.com/jaegertracing/jaeger-client-csharp/issues/176#issuecomment-643103460 is the proposed solution.
I guess, #176 (comment) is the proposed solution.
@ykvichare: If @yurishkuro can't supply us with know-how on if the jaeger-agent
has integrated client certificate support, https://github.com/jaegertracing/jaeger-client-csharp/issues/176#issuecomment-643103460 is your best shot. I might look into having an option for HttpSender.Builder
to use your own HttpClient
, that would solve it too. But sadly, I currently have no time for this.
I will adjust the API to allow defining a user-owned HttpClient
for 0.4.0
now.
@Lercher @ykvichare Sorry again for the delays. I adjusted the API so that you can call WithCredentials
if you only want to add user credentials or use WithHttpHandler
if you also need to adjust more stuff like ServerCertificateCustomValidationCallback
. These can even be combined, depending on your preferences. I hope to release 0.4.0 soon. Just making sure there are no more things that could be added with little effort.
@Lercher @ykvichare 0.4.0 is now released. Hope this fixes your issues :)
Yes it's fixed thank you for your help.
On Fri 26 Jun, 2020, 20:31 Benjamin Krämer, notifications@github.com wrote:
@Lercher https://github.com/Lercher @ykvichare https://github.com/ykvichare 0.4.0 is now released. Hope this fixes your issues :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jaegertracing/jaeger-client-csharp/issues/176#issuecomment-650226816, or unsubscribe https://github.com/notifications/unsubscribe-auth/APBCBFHNXPGT6KKACMJE54LRYSZ4NANCNFSM4NYTFKIQ .
I am using below code for connecting HTTPS Jaeger endpoint in C#. Unable to see traces . could you please help on this?
if (GlobalTracer.IsRegistered()) { return GlobalTracer.Instance; }