public void FromLowerBase16() { Assert.Equal(SpanId.INVALID, SpanId.FromLowerBase16("0000000000000000")); Assert.Equal(first, SpanId.FromLowerBase16("0000000000000061")); Assert.Equal(second, SpanId.FromLowerBase16("ff00000000000041")); }
private string EncodeSpanId(SpanId spanId) { return(spanId.ToLowerBase16()); }
public bool Equals(ActivityContext value) => SpanId.Equals(value.SpanId) && TraceId.Equals(value.TraceId) && TraceFlags == value.TraceFlags && TraceState == value.TraceState;
/// <inheritdoc /> public bool ShouldSample(SpanContext parentContext, TraceId traceId, SpanId spanId, string name, IEnumerable <ILink> links) { return(false); }
public SpanTest() { timestamp = Timestamp.FromDateTimeOffset(startTime); timestampConverter = Timer.StartNew(startTime, () => interval); spanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), OpenTelemetry.Trace.TraceOptions.Default, Tracestate.Empty); parentSpanId = SpanId.GenerateRandomId(random); attributes.Add( "MyStringAttributeKey", AttributeValue.StringAttributeValue("MyStringAttributeValue")); attributes.Add("MyLongAttributeKey", AttributeValue.LongAttributeValue(123L)); attributes.Add("MyBooleanAttributeKey", AttributeValue.BooleanAttributeValue(false)); expectedAttributes = new Dictionary <String, IAttributeValue>(attributes); expectedAttributes.Add( "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue")); }
public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject() { // Arrange var timestamp = DateTimeOffset.MaxValue; var context = new TransactionContext( SpanId.Create(), SpanId.Create(), SentryId.Create(), "name123", "op123", "desc", SpanStatus.AlreadyExists, null, // sampling isn't serialized and getting FluentAssertions // to ignore that on Spans and contexts isn't really straight forward true); var transaction = new TransactionTracer(DisabledHub.Instance, context) { Description = "desc123", Status = SpanStatus.Aborted, User = new User { Id = "user-id" }, Request = new Request { Method = "POST" }, Sdk = new SdkVersion { Name = "SDK-test", Version = "1.1.1" }, Environment = "environment", Level = SentryLevel.Fatal, Contexts = { ["context_key"] = "context_value", [".NET Framework"] = new Dictionary <string, string> { [".NET Framework"] = "\"v2.0.50727\", \"v3.0\", \"v3.5\"", [".NET Framework Client"] = "\"v4.8\", \"v4.0.0.0\"", [".NET Framework Full"] = "\"v4.8\"" } }, }; // Don't overwrite the contexts object as it contains trace data. // See https://github.com/getsentry/sentry-dotnet/issues/752 transaction.Sdk.AddPackage(new Package("name", "version")); transaction.AddBreadcrumb(new Breadcrumb(timestamp, "crumb")); transaction.AddBreadcrumb(new Breadcrumb( timestamp, "message", "type", new Dictionary <string, string> { { "data-key", "data-value" } }, "category", BreadcrumbLevel.Warning) ); transaction.SetExtra("extra_key", "extra_value"); transaction.Fingerprint = new[] { "fingerprint" }; transaction.SetTag("tag_key", "tag_value"); var child1 = transaction.StartChild("child_op123", "child_desc123"); child1.Status = SpanStatus.Unimplemented; child1.SetTag("q", "v"); child1.SetExtra("f", "p"); child1.Finish(SpanStatus.Unimplemented); var child2 = transaction.StartChild("child_op999", "child_desc999"); child2.Status = SpanStatus.OutOfRange; child2.SetTag("xxx", "zzz"); child2.SetExtra("f222", "p111"); child2.Finish(SpanStatus.OutOfRange); transaction.Finish(SpanStatus.Aborted); // Act var finalTransaction = new Transaction(transaction); var actualString = finalTransaction.ToJsonString(); var actual = Transaction.FromJson(Json.Parse(actualString)); // Assert actual.Should().BeEquivalentTo(finalTransaction, o => { // Timestamps lose some precision when writing to JSON o.Using <DateTimeOffset>(ctx => ctx.Subject.Should().BeCloseTo(ctx.Expectation, TimeSpan.FromMilliseconds(1)) ).WhenTypeIs <DateTimeOffset>(); return(o); }); }
public void FromString_WithZeroes() { var spanId = SpanId.FromString("000000000000002a"); Assert.Equal("000000000000002a", _spanId.ToString()); }
public SpanExporterTest() { sampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty); notSampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Default, Tracestate.Empty); startEndHandler = new StartEndHandler(spanExporter, runningSpanStore, null, new SimpleEventQueue()); spanExporter.RegisterHandler("test.service", serviceHandler); }
internal static SpanData ProfiledCommandToSpanData(SpanContext context, string name, SpanId parentSpanId, IProfiledCommand command) { // use https://github.com/opentracing/specification/blob/master/semantic_conventions.md for now // Timing example: // command.CommandCreated; //2019-01-10 22:18:28Z // command.CreationToEnqueued; // 00:00:32.4571995 // command.EnqueuedToSending; // 00:00:00.0352838 // command.SentToResponse; // 00:00:00.0060586 // command.ResponseToCompletion; // 00:00:00.0002601 // Total: // command.ElapsedTime; // 00:00:32.4988020 // TODO: make timestamp with the better precision var startTimestamp = Timestamp.FromMillis(new DateTimeOffset(command.CommandCreated).ToUnixTimeMilliseconds()); var timestamp = new DateTimeOffset(command.CommandCreated).Add(command.CreationToEnqueued); var events = TimedEvents <IEvent> .Create( new List <ITimedEvent <IEvent> >() { TimedEvent <IEvent> .Create(Timestamp.FromMillis(timestamp.ToUnixTimeMilliseconds()), Event.Create("Enqueued")), TimedEvent <IEvent> .Create(Timestamp.FromMillis((timestamp = timestamp.Add(command.EnqueuedToSending)).ToUnixTimeMilliseconds()), Event.Create("Sent")), TimedEvent <IEvent> .Create(Timestamp.FromMillis(timestamp.Add(command.SentToResponse).ToUnixTimeMilliseconds()), Event.Create("ResponseRecieved")), }, droppedEventsCount : 0); var endTimestamp = Timestamp.FromMillis(new DateTimeOffset(command.CommandCreated.Add(command.ElapsedTime)).ToUnixTimeMilliseconds()); // TODO: deal with the re-transmission // command.RetransmissionOf; // command.RetransmissionReason; // TODO: determine what to do with Resource in this context var resource = Resource.Empty; var attributesMap = new Dictionary <string, IAttributeValue>() { // TODO: pre-allocate constant attribute and reuse { "db.type", AttributeValue.StringAttributeValue("redis") }, // Example: "redis.flags": None, DemandMaster { "redis.flags", AttributeValue.StringAttributeValue(command.Flags.ToString()) }, }; if (command.Command != null) { // Example: "db.statement": SET; attributesMap.Add("db.statement", AttributeValue.StringAttributeValue(command.Command)); } if (command.EndPoint != null) { // Example: "db.instance": Unspecified/localhost:6379[0] attributesMap.Add("db.instance", AttributeValue.StringAttributeValue(command.EndPoint.ToString() + "[" + command.Db + "]")); } var attributes = Attributes.Create(attributesMap, 0); ILinks links = null; int? childSpanCount = 0; // TODO: this is strange that IProfiledCommand doesn't give the result var status = Status.Ok; var kind = SpanKind.Client; return(SpanData.Create(context, parentSpanId, resource, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp)); }
public SpanIdTests() { _spanIdValue = 42; _spanId = new SpanId(_spanIdValue); }
internal static bool ShouldSample(SpanContext parentContext, string name, ISampler sampler, out SpanContext context, out SpanId parentSpanId) { var traceId = TraceId.Invalid; var tracestate = Tracestate.Empty; parentSpanId = SpanId.Invalid; var parentOptions = TraceOptions.Default; if (parentContext.IsValid) { traceId = parentContext.TraceId; parentSpanId = parentContext.SpanId; parentOptions = parentContext.TraceOptions; } else { traceId = TraceId.FromBytes(Guid.NewGuid().ToByteArray()); } var result = parentOptions.IsSampled; var spanId = SpanId.FromBytes(Guid.NewGuid().ToByteArray(), 8); var traceOptions = TraceOptions.Default; if (sampler != null) { var builder = TraceOptions.Builder(parentContext.TraceOptions); result = sampler.ShouldSample(parentContext, traceId, spanId, name, null); builder = builder.SetIsSampled(result); traceOptions = builder.Build(); } context = SpanContext.Create(traceId, spanId, traceOptions, parentContext.Tracestate); return(result); }
//// @Rule public readonly ExpectedException exception = ExpectedException.none(); public SpanTest() { spanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.DEFAULT); parentSpanId = SpanId.GenerateRandomId(random); testClock = TestClock.Create(timestamp); timestampConverter = TimestampConverter.Now(testClock); attributes.Add( "MyStringAttributeKey", AttributeValue.StringAttributeValue("MyStringAttributeValue")); attributes.Add("MyLongAttributeKey", AttributeValue.LongAttributeValue(123L)); attributes.Add("MyBooleanAttributeKey", AttributeValue.BooleanAttributeValue(false)); expectedAttributes = new Dictionary <string, IAttributeValue>(attributes) { { "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue") } }; }
public void GetSpanId() { Assert.Equal(SpanId.FromBytes(FirstSpanIdBytes), First.SpanId); Assert.Equal(SpanId.FromBytes(SecondSpanIdBytes), Second.SpanId); }
/// <summary> /// Creates a new <see cref="SpanContext"/> with the given identifiers and options. /// </summary> /// <param name="traceId">The <see cref="TraceId"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="spanId">The <see cref="SpanId"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="traceOptions">The <see cref="TraceOptions"/> to associate with the <see cref="SpanContext"/>.</param> /// <param name="tracestate">The <see cref="Tracestate"/> to associate with the <see cref="SpanContext"/>.</param> /// <returns>A new <see cref="SpanContext"/> with the given identifiers and options.</returns> public static SpanContext Create(TraceId traceId, SpanId spanId, TraceOptions traceOptions, Tracestate tracestate) { return(new SpanContext(traceId, spanId, traceOptions, tracestate)); }
private bool TryExtractTraceparent(string traceparent, out TraceId traceId, out SpanId spanId, out TraceOptions traceoptions) { // from https://github.com/w3c/distributed-tracing/blob/master/trace_context/HTTP_HEADER_FORMAT.md // traceparent: 00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01 traceId = TraceId.Invalid; spanId = SpanId.Invalid; traceoptions = TraceOptions.Default; var bestAttempt = false; if (string.IsNullOrWhiteSpace(traceparent)) { return(false); } // if version does not end with delimeter if (traceparent.Length < VersionPrefixIdLength || traceparent[VersionPrefixIdLength - 1] != '-') { return(false); } // or version is not a hex (will throw) var versionArray = Arrays.StringToByteArray(traceparent, 0, VersionLength); if (versionArray[0] == 255) { return(false); } if (versionArray[0] > 0) { // expected version is 00 // for higher versions - best attempt parsing of trace id, span id, etc. bestAttempt = true; } if (traceparent.Length < VersionAndTraceIdLength || traceparent[VersionAndTraceIdLength - 1] != '-') { return(false); } try { traceId = TraceId.FromBytes(Arrays.StringToByteArray(traceparent, VersionPrefixIdLength, TraceIdLength)); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if (traceparent.Length < VersionAndTraceIdAndSpanIdLength || traceparent[VersionAndTraceIdAndSpanIdLength - 1] != '-') { return(false); } try { spanId = SpanId.FromBytes(Arrays.StringToByteArray(traceparent, VersionAndTraceIdLength, SpanIdLength)); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if (traceparent.Length < VersionAndTraceIdAndSpanIdLength + OptionsLength) { return(false); } byte[] optionsArray; try { optionsArray = Arrays.StringToByteArray(traceparent, VersionAndTraceIdAndSpanIdLength, OptionsLength); } catch (ArgumentOutOfRangeException) { // it's ok to still parse tracestate return(false); } if ((optionsArray[0] | 1) == 1) { traceoptions = TraceOptions.Builder().SetIsSampled(true).Build(); } if ((!bestAttempt) && (traceparent.Length != VersionAndTraceIdAndSpanIdLength + OptionsLength)) { return(false); } if (bestAttempt) { if ((traceparent.Length > VersionAndTraceIdAndSpanIdLength + OptionsLength) && (traceparent[VersionAndTraceIdAndSpanIdLength + OptionsLength] != '-')) { return(false); } } return(true); }
public InProcessSampledSpanStoreTest() { sampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Builder().SetIsSampled(true).Build()); notSampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.DEFAULT); parentSpanId = SpanId.GenerateRandomId(random); startEndHandler = new TestStartEndHandler(sampleStore); sampleStore.RegisterSpanNamesForCollection(new List <string>() { REGISTERED_SPAN_NAME }); }
public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() { var configMock = Mock.Get <ITraceConfig>(traceConfig); configMock.Setup((c) => c.ActiveTraceParams).Returns(TraceParams.Default); // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long // is not less than probability * Long.MAX_VALUE; var traceId = TraceId.FromBytes( new byte[] { 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, }); // If parent is sampled then the remote child must be sampled. var childSpan = SpanBuilder.Create( SPAN_NAME, SpanKind.Internal, SpanContext.Create( traceId, SpanId.GenerateRandomId(randomHandler), TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty), spanBuilderOptions) .StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(traceId, childSpan.Context.TraceId); Assert.True(childSpan.Context.TraceOptions.IsSampled); childSpan.End(); Assert.Equal(TraceParams.Default, traceConfig.ActiveTraceParams); // If parent is not sampled then the remote child must be not sampled. childSpan = SpanBuilder.Create( SPAN_NAME, SpanKind.Internal, SpanContext.Create( traceId, SpanId.GenerateRandomId(randomHandler), TraceOptions.Default, Tracestate.Empty), spanBuilderOptions) .StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(traceId, childSpan.Context.TraceId); Assert.False(childSpan.Context.TraceOptions.IsSampled); childSpan.End(); }
public async Task Transaction_is_started_automatically_from_incoming_trace_header() { // Arrange var sentryClient = Substitute.For <ISentryClient>(); var hub = new Internal.Hub(new SentryOptions { Dsn = DsnSamples.ValidDsnWithoutSecret, TracesSampleRate = 1 }, sentryClient); var server = new TestServer(new WebHostBuilder() .UseDefaultServiceProvider(di => di.EnableValidation()) .UseSentry() .ConfigureServices(services => { services.AddRouting(); services.RemoveAll(typeof(Func <IHub>)); services.AddSingleton <Func <IHub> >(() => hub); }) .Configure(app => { app.UseRouting(); app.UseSentryTracing(); app.UseEndpoints(routes => routes.Map("/person/{id}", _ => Task.CompletedTask)); })); var client = server.CreateClient(); // Act using var request = new HttpRequestMessage(HttpMethod.Get, "/person/13") { Headers = { { "sentry-trace", "75302ac48a024bde9a3b3734a82e36c8-1000000000000000-0" } } }; await client.SendAsync(request); // Assert sentryClient.Received(1).CaptureTransaction(Arg.Is <Transaction>(t => t.Name == "GET /person/{id}" && t.TraceId == SentryId.Parse("75302ac48a024bde9a3b3734a82e36c8") && t.ParentSpanId == SpanId.Parse("1000000000000000") && t.IsSampled == false )); }
public override int GetHashCode() { int hash = 1; if (TraceId.Length != 0) { hash ^= TraceId.GetHashCode(); } if (SpanId.Length != 0) { hash ^= SpanId.GetHashCode(); } if (ParentSpanId.Length != 0) { hash ^= ParentSpanId.GetHashCode(); } if (SpanName.Length != 0) { hash ^= SpanName.GetHashCode(); } if (startTime_ != null) { hash ^= StartTime.GetHashCode(); } if (endTime_ != null) { hash ^= EndTime.GetHashCode(); } hash ^= SpanTags.GetHashCode(); if (HttpStatusCode != 0L) { hash ^= HttpStatusCode.GetHashCode(); } if (ClientSpan != false) { hash ^= ClientSpan.GetHashCode(); } if (RewriteClientSpanId != false) { hash ^= RewriteClientSpanId.GetHashCode(); } if (SourceName.Length != 0) { hash ^= SourceName.GetHashCode(); } if (sourceIp_ != null) { hash ^= SourceIp.GetHashCode(); } if (DestinationName.Length != 0) { hash ^= DestinationName.GetHashCode(); } if (destinationIp_ != null) { hash ^= DestinationIp.GetHashCode(); } if (RequestSize != 0L) { hash ^= RequestSize.GetHashCode(); } if (RequestTotalSize != 0L) { hash ^= RequestTotalSize.GetHashCode(); } if (ResponseSize != 0L) { hash ^= ResponseSize.GetHashCode(); } if (ResponseTotalSize != 0L) { hash ^= ResponseTotalSize.GetHashCode(); } if (ApiProtocol.Length != 0) { hash ^= ApiProtocol.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override string ToString() { return(string.Join("-", new[] { Version, TraceId.ToString(), SpanId.ToString(), ((int)Flags).ToString("00") })); }
public void ProbabilitySampler_SampleBasedOnTraceId() { ISampler defaultProbability = Samplers.GetProbabilitySampler(0.0001); // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long // is not less than probability * Long.MAX_VALUE; ITraceId notSampledtraceId = TraceId.FromBytes( new byte[] { (byte)0x8F, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0, 0, 0, 0, 0, 0, 0, 0 }); Assert.False( defaultProbability.ShouldSample( null, false, notSampledtraceId, SpanId.GenerateRandomId(random), SPAN_NAME, new List <ISpan>())); // This traceId will be sampled by the ProbabilitySampler because the first 8 bytes as long // is less than probability * Long.MAX_VALUE; ITraceId sampledtraceId = TraceId.FromBytes( new byte[] { (byte)0x00, (byte)0x00, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, 0, 0, 0, 0, 0, 0, 0, 0 }); Assert.True( defaultProbability.ShouldSample( null, false, sampledtraceId, SpanId.GenerateRandomId(random), SPAN_NAME, new List <ISpan>())); }
public void BuildJeagerThriftSpan() { var doubleTagKey = "doubleTag"; var doubleLogKey = "doubleLog"; var decimalLogKey = "decimalLog"; var int64TagKey = "int64Tag"; var stringTagKey = "stringTag"; var tracerTags = new Dictionary <string, object> { { doubleTagKey, 1.1 }, { int64TagKey, (Int64)1942 }, { stringTagKey, "stringValue" } }; var logTimestamp = new DateTime(2018, 2, 16, 11, 33, 29, DateTimeKind.Utc); var logFields1 = new Dictionary <string, object> { { doubleLogKey, 1.3 } }; var logFields2 = new Dictionary <string, object> { { decimalLogKey, 5.5m } }; var logs = new List <LogRecord> { new LogRecord(logTimestamp, logFields1), new LogRecord(logTimestamp, logFields2) }; var serialization = new JaegerThriftSerialization(); var span = Substitute.For <IJaegerCoreSpan>(); var traceId = new TraceId(10, 2); var spanId = new SpanId(15); var parentId = new SpanId(82); var context = new SpanContext(traceId, spanId, parentId); span.Context.Returns(context); var op = "op, yo"; span.OperationName.Returns(op); span.Tags.Returns(tracerTags); span.Logs.Returns(logs); var startTimestamp = new DateTime(2018, 2, 16, 11, 33, 28, DateTimeKind.Utc); var finishTimestamp = new DateTime(2018, 2, 16, 11, 33, 30, DateTimeKind.Utc); span.StartTimestampUtc.Returns(startTimestamp); span.FinishTimestampUtc.Returns(finishTimestamp); var parentRefType = References.ChildOf; var parentContext = Substitute.For <IJaegerCoreSpanContext>(); parentContext.TraceId.Returns(traceId); parentContext.SpanId.Returns(parentId); var reference = new Reference(parentRefType, context); span.References.Returns(new List <Reference> { reference }); var jSpan = serialization.BuildJaegerThriftSpan(span); Assert.Equal((long)traceId.Low, jSpan.TraceIdLow); Assert.Equal((long)traceId.High, jSpan.TraceIdHigh); Assert.Equal(spanId, jSpan.SpanId); Assert.Equal(parentId, jSpan.ParentSpanId); Assert.Equal(op, jSpan.OperationName); Assert.Equal(0, jSpan.Flags); Assert.Equal(1518780808000000, jSpan.StartTime); Assert.Equal(2000000, jSpan.Duration); // tags Assert.Equal(3, jSpan.Tags.Count); Assert.Equal(doubleTagKey, jSpan.Tags[0].Key); Assert.Equal(1.1, jSpan.Tags[0].VDouble); Assert.Equal(int64TagKey, jSpan.Tags[1].Key); Assert.Equal(1942, jSpan.Tags[1].VLong); Assert.Equal(stringTagKey, jSpan.Tags[2].Key); Assert.Equal("stringValue", jSpan.Tags[2].VStr); // logs Assert.Equal(JaegerTagType.DOUBLE, jSpan.Logs[0].Fields[0].VType); Assert.Equal(doubleLogKey, jSpan.Logs[0].Fields[0].Key); Assert.Equal(1.3, jSpan.Logs[0].Fields[0].VDouble); Assert.Equal(JaegerTagType.DOUBLE, jSpan.Logs[1].Fields[0].VType); Assert.Equal(decimalLogKey, jSpan.Logs[1].Fields[0].Key); Assert.Equal((double)5.5m, jSpan.Logs[1].Fields[0].VDouble); // references Assert.Single(jSpan.References); Assert.Equal(JaegerReferenceType.CHILD_OF, jSpan.References[0].RefType); Assert.Equal((long)traceId.Low, jSpan.References[0].TraceIdLow); Assert.Equal((long)traceId.High, jSpan.References[0].TraceIdHigh); Assert.Equal(spanId, jSpan.References[0].SpanId); }
public static extern void EventTracerSetActiveSpanId(EventTracer eventTracer, SpanId spanId);
private Span ConvertToSpan(TempSpan tempSpan, Tracer tracer) { var mySpan = tempSpan.Span; var tags = mySpan.Tags; var parentId = TryFindParentId(mySpan); var context = new SpanContext(TraceId.FromString(mySpan.TraceId), SpanId.FromString(mySpan.SpanId), parentId, (SpanContextFlags)mySpan.Flags); if (SpanAssembly == null) { var filePath = AppDomain.CurrentDomain.Combine("Jaeger.dll"); if (!File.Exists(filePath)) { throw new InvalidOperationException("SpanAssembly Not Found: " + filePath); } SpanAssembly = Assembly.LoadFile(filePath); } var references = new List <Reference>(); foreach (var reference in mySpan.References) { references.Add(new Reference(context, reference.Type)); } //hack it, attention for same types, or fail wit ex: System.MissingMethodException! //internal Span( // Tracer tracer, // string operationName, // SpanContext context, // DateTime startTimestampUtc, // Dictionary<string, object> tags, // IReadOnlyList<Reference> references) var span = CreateSpanWithReflection(SpanAssembly, tracer, mySpan.OpName, context, mySpan.StartTime.ToUniversalTime(), tags, references.AsReadOnly() ); var logs = mySpan.Logs; foreach (var log in logs) { if (log.Message != null) { //"fields": [ //{ // "key": "event", // "type": "string", // "value": "myLog by FooDomain" //} span.Log(log.TimestampUtc, log.Message); } else { span.Log(log.TimestampUtc, log.Fields); } } //span.Finish(mySpan.StopTime); return(span); }
public static extern Uint8 SpanIdEqual(SpanId a, SpanId b);
public InProcessSampledSpanStoreTest() { timestamp = Timestamp.FromDateTimeOffset(startTime); timestampConverter = Timer.StartNew(startTime, () => interval); sampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty); notSampledSpanContext = SpanContext.Create(TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), TraceOptions.Default, Tracestate.Empty); parentSpanId = SpanId.GenerateRandomId(random); startEndHandler = new TestStartEndHandler(sampleStore); sampleStore.RegisterSpanNamesForCollection(new List <string>() { REGISTERED_SPAN_NAME }); }
public static extern Uint8 SpanIdHash(SpanId spanId);
public void SpanId_CompareTo() { Assert.Equal(1, first.CompareTo(second)); Assert.Equal(-1, second.CompareTo(first)); Assert.Equal(0, first.CompareTo(SpanId.FromBytes(firstBytes))); }
public void GetSpanId() { Assert.Equal(SpanId.FromBytes(firstSpanIdBytes), first.SpanId); Assert.Equal(SpanId.FromBytes(secondSpanIdBytes), second.SpanId); }