public void WithAnnotation_with_dynamic_value_should_call_value_provider_delegate_for_each_event() { var counter = 0; enrichedTracer = baseTracer.WithAnnotation("key", () => ++ counter, true); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", 1, Arg.Any <bool>()); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", 2, Arg.Any <bool>()); }
public void WithAnnotation_with_dynamic_value_should_filter_out_null_values_by_default() { enrichedTracer = baseTracer.WithAnnotation("key", () => null as string); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().BeEmpty(); }
public void WithAnnotation_with_dynamic_value_should_overwrite_existing_values_when_explicitly_asked_to() { enrichedTracer = baseTracer.WithAnnotation("key", () => "value", true); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation(Arg.Any <string>(), Arg.Any <string>(), true); }
public void TestSetup() { tracer = Substitute.For <ITracer>(); tracer.BeginSpan().Returns(builder = Substitute.For <ISpanBuilder>()); absoluteUrl = new Uri("https://vostok.tools/version/123?q=a", UriKind.Absolute); relativeUrl = new Uri("version/123?q=a", UriKind.Relative); }
public void WithAnnotation_with_dynamic_value_should_pass_null_values_when_asked_to() { enrichedTracer = baseTracer.WithAnnotation("key", () => null as string, allowNullValues: true); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", null, Arg.Any <bool>()); }
public void WithAnnotation_should_overwrite_existing_values_when_asked_to() { enrichedTracer = baseTracer.WithAnnotation("key", "value", true); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", "value"); }
public void TestSetup() { tracer = Substitute.For <ITracer>(); tracer.CurrentContext.Returns(new TraceContext(Guid.NewGuid(), Guid.NewGuid())); tracer.BeginSpan().Returns(spanBuilder = Substitute.For <ISpanBuilder>()); baseTransport = Substitute.For <ITransport>(); baseTransport.SendAsync(default, default, default, default).ReturnsForAnyArgs(_ => response);
public void WithAnnotation_should_return_a_tracer_that_adds_given_annotation_when_value_is_null() { enrichedTracer = baseTracer.WithAnnotation("key", null as string); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", null, Arg.Any <bool>()); }
public void WithAnnotation_should_not_overwrite_existing_values_by_default() { enrichedTracer = baseTracer.WithAnnotation("key", "value"); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key", "value", false); }
public void WithAnnotations_with_dynamic_provider_should_handle_null_object_returned() { enrichedTracer = baseTracer.WithAnnotations(() => null); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().BeEmpty(); }
public void WithAnnotation_with_dynamic_value_should_not_overwrite_existing_values_by_default() { enrichedTracer = baseTracer.WithAnnotation("key", () => "value"); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation(Arg.Any <string>(), Arg.Any <string>(), false); }
public void TestSetup() { spanBuilder = Substitute.For <ISpanBuilder>(); baseTracer = Substitute.For <ITracer>(); baseTracer.BeginSpan().Returns(spanBuilder); baseTracer.CurrentContext.Returns(new TraceContext(Guid.Empty, Guid.Empty)); }
/// <summary> /// <para>Begins a span of <see cref="WellKnownSpanKinds.HttpRequest.Cluster"/> kind and returns a specialized builder to aid in filling relevant annotations.</para> /// <para>See <see cref="IHttpRequestClusterSpanBuilder"/> for more details.</para> /// <para>If provided <paramref name="operationName"/> is <c>null</c>, <see cref="WellKnownAnnotations.Common.Operation"/> annotation will be inferred from request properties.</para> /// </summary> public static IHttpRequestClusterSpanBuilder BeginHttpClusterSpan([NotNull] this ITracer tracer, [CanBeNull] string operationName = null) { if (tracer == null) { throw new ArgumentNullException(nameof(tracer)); } return(new HttpRequestClusterSpanBuilder(tracer.BeginSpan(), operationName)); }
public void WithFlowingContextProperty_should_pass_overwrite_flag_to_span_builder(bool allowOverwrite) { FlowingContext.Properties.Set(propertyName1, "value"); enrichedTracer = baseTracer.WithFlowingContextProperty(propertyName1, allowOverwrite: allowOverwrite); enrichedTracer.BeginSpan(); spanBuilder.Received(1).SetAnnotation(Arg.Any <string>(), Arg.Any <string>(), allowOverwrite); }
public void WithFlowingContextGlobal_should_add_null_values_when_explicitly_asked_to() { FlowingContext.Globals.Set(null as string); enrichedTracer = baseTracer.WithFlowingContextGlobal <string>(globalName, allowNullValues: true); enrichedTracer.BeginSpan(); spanBuilder.Received(1).SetAnnotation(globalName, null, Arg.Any <bool>()); }
public void WithFlowingContextGlobal_should_not_add_null_values_by_default() { FlowingContext.Globals.Set(null as string); enrichedTracer = baseTracer.WithFlowingContextGlobal <string>(globalName); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().BeEmpty(); }
public void WithFlowingContextGlobal_should_return_a_tracer_that_adds_global_value_of_given_type_to_spans() { FlowingContext.Globals.Set("123"); enrichedTracer = baseTracer.WithFlowingContextGlobal <string>(globalName); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation(globalName, "123", Arg.Any <bool>()); }
public void WithFlowingContextGlobal_should_pass_ovewrite_flag_to_span_builder(bool allowOverwrite) { FlowingContext.Globals.Set("123"); enrichedTracer = baseTracer.WithFlowingContextGlobal <string>(globalName, allowOverwrite); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation(Arg.Any <string>(), Arg.Any <string>(), allowOverwrite); }
public void WithFlowingContextProperty_should_allow_null_values_when_asked_to() { FlowingContext.Properties.Set(propertyName1, null); enrichedTracer = baseTracer.WithFlowingContextProperty(propertyName1, allowNullValues: true); enrichedTracer.BeginSpan(); spanBuilder.Received(1).SetAnnotation(propertyName1, null, Arg.Any <bool>()); }
public void WithFlowingContextProperty_should_not_allow_null_values_by_default() { FlowingContext.Properties.Set(propertyName1, null); enrichedTracer = baseTracer.WithFlowingContextProperty(propertyName1); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().BeEmpty(); }
public void WithFlowingContextProperties_should_pass_overwrite_flag_to_span_builder(bool allowOverwrite) { FlowingContext.Properties.Set(propertyName1, "value1"); FlowingContext.Properties.Set(propertyName2, "value2"); enrichedTracer = baseTracer.WithFlowingContextProperties(new[] { propertyName1, propertyName2, propertyName3 }, allowOverwrite); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().HaveCount(2); spanBuilder.Received(2).SetAnnotation(Arg.Any <string>(), Arg.Any <string>(), allowOverwrite); }
public void WithFlowingContextProperties_should_allow_null_values_when_asked_to() { FlowingContext.Properties.Set(propertyName1, null); FlowingContext.Properties.Set(propertyName2, null); enrichedTracer = baseTracer.WithFlowingContextProperties(new[] { propertyName1, propertyName2, propertyName3 }, allowNullValues: true); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().HaveCount(2); spanBuilder.Received(1).SetAnnotation(propertyName1, null, Arg.Any <bool>()); spanBuilder.Received(1).SetAnnotation(propertyName2, null, Arg.Any <bool>()); }
public void WithFlowingContextProperties_should_return_a_tracer_that_adds_given_context_properties_to_spans() { FlowingContext.Properties.Set(propertyName1, "value1"); FlowingContext.Properties.Set(propertyName2, "value2"); enrichedTracer = baseTracer.WithFlowingContextProperties(new[] { propertyName1, propertyName2, propertyName3 }); enrichedTracer.BeginSpan(); spanBuilder.ReceivedCalls().Should().HaveCount(2); spanBuilder.Received(1).SetAnnotation(propertyName1, "value1", Arg.Any <bool>()); spanBuilder.Received(1).SetAnnotation(propertyName2, "value2", Arg.Any <bool>()); }
public void WithAnnotations_should_return_a_tracer_that_adds_given_annotations_to_span() { enrichedTracer = baseTracer.WithAnnotations( new Dictionary <string, object> { { "key1", "value1" }, { "key2", "value2" } }); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key1", "value1", Arg.Any <bool>()); spanBuilder.Received().SetAnnotation("key2", "value2", Arg.Any <bool>()); }
public void WithAnnotations_should_filter_out_null_values_by_default() { enrichedTracer = baseTracer.WithAnnotations( new Dictionary <string, object> { { "key1", "value1" }, { "key2", null } }); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key1", "value1", Arg.Any <bool>()); spanBuilder.DidNotReceive().SetAnnotation("key2", Arg.Any <string>(), Arg.Any <bool>()); }
public void WithAnnotations_should_pass_null_values_when_asked_to() { enrichedTracer = baseTracer.WithAnnotations( new Dictionary <string, object> { { "key1", "value1" }, { "key2", null } }, allowNullValues: true); enrichedTracer.BeginSpan(); spanBuilder.Received().SetAnnotation("key1", "value1", Arg.Any <bool>()); spanBuilder.Received().SetAnnotation("key2", null, Arg.Any <bool>()); }
/// <summary> /// <para>Begins a span of <see cref="WellKnownSpanKinds.Custom.Operation"/> kind and returns a specialized builder to aid in filling relevant annotations.</para> /// <para>See <see cref="ICustomOperationSpanBuilder"/> for more details.</para> /// </summary> public static ICustomOperationSpanBuilder BeginCustomOperationSpan([NotNull] this ITracer tracer, [NotNull] string operationName) { if (tracer == null) { throw new ArgumentNullException(nameof(tracer)); } if (operationName == null) { throw new ArgumentNullException(nameof(operationName)); } return(new CustomOperationSpanBuilder(tracer.BeginSpan(), operationName)); }
public void TestSetup() { baseTracer = Substitute.For <ITracer>(); spanBuilder = Substitute.For <ISpanBuilder>(); baseTracer.BeginSpan().Returns(spanBuilder); FlowingContext.Properties.Clear(); globalName = Guid.NewGuid().ToString(); propertyName1 = Guid.NewGuid().ToString(); propertyName2 = Guid.NewGuid().ToString(); propertyName3 = Guid.NewGuid().ToString(); }