From 97c4ad9f010ada89d66c857746b0d0329879be77 Mon Sep 17 00:00:00 2001 From: Austin Parker Date: Fri, 31 May 2019 11:13:43 -0400 Subject: [PATCH 1/7] add fork guidance (fix #47) (#51) --- CONTRIBUTING.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ba9ea20842..0e456765f7f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Report a bug or requesting feature -Reporting bug is an important contribution. Please make sure to include: +Reporting bugs is an important contribution. Please make sure to include: - expected and actual behavior. - dotnet version that application is compiled on and running with (it may be @@ -13,15 +13,36 @@ Reporting bug is an important contribution. Please make sure to include: ## How to contribute -### Before started +### Before you start Please read project contribution [guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md) for general practices for OpenTelemetry project. +### Fork + +In the interest of keeping this repository clean and manageable, you should work from a fork. To create a fork, click the 'Fork' button at the top of the repository, then clone the fork locally using `git clone git@github.com:USERNAME/opentelemetry-dotnet.git`. + +You should also add this repository as an "upstream" repo to your local copy, in order to keep it up to date. You can add this as a remote like so: +``` +git remote add upstream https://github.com/open-telemetry/opentelemetry-dotnet.git + +#verify that the upstream exists +git remote -v +``` + +To update your fork, fetch the upstream repo's branches and commits, then merge your master with upstream's master: +``` +git fetch upstream +git checkout master +git merge upstream/master +``` + +Remember to always work in a branch of your local copy, as you might otherwise have to contend with conflicts in master. + ### Build -You can use Visual Studio 2017+ or VS code to contribute. Just open root folder +You can use Visual Studio 2017+ or VS Code to contribute. Just open root folder or `OpenTelemetry.sln` in your editor and follow normal development process. To build from command line you need `dotnet` version `2.0+`. @@ -32,7 +53,7 @@ dotnet build OpenTelemetry.sln ### Test -You can use Visual Studio 2017 or VS code to test your contribution. Open root +You can use Visual Studio 2017 or VS Code to test your contribution. Open root folder or `OpenTelemetry.sln` in your editor and follow normal development process. From c51479f2c6f452427eca09b508b47d572db7ba5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Neum=C3=BCller?= Date: Fri, 31 May 2019 17:39:42 +0200 Subject: [PATCH 2/7] add editorconfig with the defaults that Visual Studio 2019 created for .NET (#50) --- .editorconfig | 123 ++++++++++++++++++++++++++++++++++++++++++++++ OpenTelemetry.sln | 1 + 2 files changed, 124 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..9d558a04e94 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,123 @@ +# To learn more about .editorconfig see https://aka.ms/editorconfigdocs +############################### +# Core EditorConfig Options # +############################### +# All files +[*] +indent_style = space +# Code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 +insert_final_newline = true +charset = utf-8-bom +############################### +# .NET Coding Conventions # +############################### +[*.{cs,vb}] +# Organize usings +dotnet_sort_system_directives_first = true +# this. preferences +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_readonly_field = true:suggestion +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_prefer_inferred_tuple_names = true:suggestion +dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +############################### +# Naming Conventions # +############################### +# Style Definitions +dotnet_naming_style.pascal_case_style.capitalization = pascal_case +# Use PascalCase for constant fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * +dotnet_naming_symbols.constant_fields.required_modifiers = const +############################### +# C# Coding Conventions # +############################### +[*.cs] +# var preferences +csharp_style_var_for_built_in_types = true:silent +csharp_style_var_when_type_is_apparent = true:silent +csharp_style_var_elsewhere = true:silent +# Expression-bodied members +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +# Pattern matching preferences +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +# Null-checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +# Expression-level preferences +csharp_prefer_braces = true:silent +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +############################### +# C# Formatting Rules # +############################### +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true +# Indentation preferences +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left +# Space preferences +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +# Wrapping preferences +csharp_preserve_single_line_statements = true +csharp_preserve_single_line_blocks = true +############################### +# VB Coding Conventions # +############################### +[*.vb] +# Modifier preferences +visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index ed48a308d04..2970a72a304 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Tests", "test EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B7408D66-487A-40E1-BDB7-BC17BD28F721}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig CHANGELOG.md = CHANGELOG.md CONTRIBUTING.md = CONTRIBUTING.md NuGet.config = NuGet.config From af40a9b78cd365fd68f00f47886096b2d6e3fc5e Mon Sep 17 00:00:00 2001 From: Tim Wegner Date: Fri, 31 May 2019 16:30:14 -0700 Subject: [PATCH 3/7] Dev/twegner/issue 17 (#55) * Removing remote parent references * Removing remote parent references * Last remoteParent references removed and test updates to reflect changes --- .../Trace/ISampler.cs | 3 +- .../Trace/ISpanData.cs | 5 - .../Trace/ITracer.cs | 14 +- .../Trace/Sampler/AlwaysSampleSampler.cs | 2 +- .../Trace/Sampler/NeverSampleSampler.cs | 2 +- .../Trace/Sampler/ProbabilitySampler.cs | 2 +- .../Trace/Sampler/Samplers.cs | 19 +- .../Trace/SpanData.cs | 12 - .../Implementation/HttpInListener.cs | 2 +- .../RedisProfilerEntryToSpanConverter.cs | 9 +- .../Implementation/TraceExporterHandler.cs | 9 +- .../Implementation/SpanDataExtentions.cs | 5 +- .../Implementation/TraceExporterHandler.cs | 5 - src/OpenTelemetry/Trace/NoopSpanBuilder.cs | 8 +- src/OpenTelemetry/Trace/NoopTracer.cs | 8 +- src/OpenTelemetry/Trace/Span.cs | 62 +--- src/OpenTelemetry/Trace/SpanBuilder.cs | 44 ++- src/OpenTelemetry/Trace/Tracer.cs | 10 +- src/OpenTelemetry/Trace/TracerBase.cs | 6 +- .../BasicTests.cs | 2 +- ...ofilerEntryToSpanConverterSamplingTests.cs | 25 +- .../RedisProfilerEntryToSpanConverterTests.cs | 2 +- .../TraceExporterHandlerTests.cs | 264 ++++++++---------- .../Export/InProcessRunningSpanStoreTest.cs | 1 - .../Export/InProcessSampledSpanStoreTest.cs | 2 - .../Impl/Trace/Export/SpanDataTest.cs | 10 - .../Impl/Trace/Export/SpanExporterTest.cs | 2 - .../Impl/Trace/Sampler/SamplersTest.cs | 77 +++-- .../Impl/Trace/SpanBuilderTest.cs | 88 +++--- .../Impl/Trace/SpanTest.cs | 15 - .../Impl/Trace/TracerBaseTest.cs | 20 +- .../Impl/Trace/TracerTest.cs | 4 +- 32 files changed, 302 insertions(+), 437 deletions(-) diff --git a/src/OpenTelemetry.Abstractions/Trace/ISampler.cs b/src/OpenTelemetry.Abstractions/Trace/ISampler.cs index 1c7b361f544..e57715d95db 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISampler.cs @@ -32,7 +32,6 @@ public interface ISampler /// Checks whether span needs to be created and tracked. /// /// Parent span context. Typically taken from the wire. - /// Indicates whether it was a remote parent. /// Trace ID of a span to be created. /// Span ID of a span to be created. /// Name of a span to be created. Note, that the name of the span is settable. @@ -42,6 +41,6 @@ public interface ISampler /// /// Links associated with the parent span. /// True of span needs to be created. False otherwise. - bool ShouldSample(ISpanContext parentContext, bool hasRemoteParent, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks); + bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks); } } diff --git a/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs b/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs index 7ea37879c20..537077012dd 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs @@ -34,11 +34,6 @@ public interface ISpanData /// ISpanId ParentSpanId { get; } - /// - /// Gets a value indicating whether span has a remote parent. - /// - bool? HasRemoteParent { get; } - /// /// Gets the span name. /// diff --git a/src/OpenTelemetry.Abstractions/Trace/ITracer.cs b/src/OpenTelemetry.Abstractions/Trace/ITracer.cs index 749da9f3345..7fe44245841 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ITracer.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ITracer.cs @@ -46,20 +46,20 @@ public interface ITracer /// /// Gets the span builder for the span with the given name and parent. /// - /// Span name. - /// Span kind. + /// Span name. + /// Span kind. /// Parent of the span. /// Span builder for the span with the given name and specified parent. - ISpanBuilder SpanBuilderWithExplicitParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null); + ISpanBuilder SpanBuilderWithParent(string name, SpanKind kind = SpanKind.Internal, ISpan parent = null); /// /// Gets the span builder for the span with the give name and remote parent context. /// - /// Span name. - /// Span kind. - /// Remote parent context extracted from the wire. + /// Span name. + /// Span kind. + /// Remote parent context extracted from the wire. /// Span builder for the span with the given name and specified parent span context. - ISpanBuilder SpanBuilderWithRemoteParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null); + ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null); /// /// Records . This API allows to send a pre-populated span object to the diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs index bed70f0138d..01632df5de4 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs @@ -32,7 +32,7 @@ public string Description } } - public bool ShouldSample(ISpanContext parentContext, bool hasRemoteParent, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { return true; } diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs index b56f5c9c36a..3b915a1c905 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs @@ -32,7 +32,7 @@ public string Description } } - public bool ShouldSample(ISpanContext parentContext, bool hasRemoteParent, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { return false; } diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs index 553994ff9dc..c2e9a7887f2 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs @@ -40,7 +40,7 @@ public string Description public long IdUpperBound { get; } - public bool ShouldSample(ISpanContext parentContext, bool hasRemoteParent, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { // If the parent is sampled keep the sampling decision. if (parentContext != null && parentContext.TraceOptions.IsSampled) diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs index 88fed881837..423bfff6deb 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs @@ -21,30 +21,15 @@ namespace OpenTelemetry.Trace.Sampler /// public sealed class Samplers { - private static readonly ISampler AlwaysSampleInstance = new AlwaysSampleSampler(); - private static readonly ISampler NeverSampleInstance = new NeverSampleSampler(); - /// /// Gets the sampler that always sample. /// - public static ISampler AlwaysSample - { - get - { - return AlwaysSampleInstance; - } - } + public static ISampler AlwaysSample { get; } = new AlwaysSampleSampler(); /// /// Gets the sampler than never samples. /// - public static ISampler NeverSample - { - get - { - return NeverSampleInstance; - } - } + public static ISampler NeverSample { get; } = new NeverSampleSampler(); /// /// Gets the probability sampler. diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanData.cs b/src/OpenTelemetry.Abstractions/Trace/SpanData.cs index ff085d2e2c1..99e4f5f4098 100644 --- a/src/OpenTelemetry.Abstractions/Trace/SpanData.cs +++ b/src/OpenTelemetry.Abstractions/Trace/SpanData.cs @@ -28,7 +28,6 @@ public sealed class SpanData : ISpanData internal SpanData( ISpanContext context, ISpanId parentSpanId, - bool? hasRemoteParent, string name, Timestamp startTimestamp, IAttributes attributes, @@ -41,7 +40,6 @@ internal SpanData( { this.Context = context ?? throw new ArgumentNullException(nameof(context)); this.ParentSpanId = parentSpanId; - this.HasRemoteParent = hasRemoteParent; this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.StartTimestamp = startTimestamp ?? throw new ArgumentNullException(nameof(startTimestamp)); this.Attributes = attributes ?? Export.Attributes.Create(new Dictionary(), 0); @@ -59,9 +57,6 @@ internal SpanData( /// public ISpanId ParentSpanId { get; } - /// - public bool? HasRemoteParent { get; } - /// public string Name { get; } @@ -94,7 +89,6 @@ internal SpanData( /// /// The of the . /// The parent of the . null if the is a root. - /// Indicates whether has a remote parent. /// The name of the . /// The start of the . /// The associated with the . @@ -108,7 +102,6 @@ internal SpanData( public static ISpanData Create( ISpanContext context, ISpanId parentSpanId, - bool? hasRemoteParent, string name, Timestamp startTimestamp, IAttributes attributes, @@ -127,7 +120,6 @@ public static ISpanData Create( return new SpanData( context, parentSpanId, - hasRemoteParent, name, startTimestamp, attributes, @@ -145,7 +137,6 @@ public override string ToString() return "SpanData{" + "context=" + this.Context + ", " + "parentSpanId=" + this.ParentSpanId + ", " - + "hasRemoteParent=" + this.HasRemoteParent + ", " + "name=" + this.Name + ", " + "startTimestamp=" + this.StartTimestamp + ", " + "attributes=" + this.Attributes + ", " @@ -169,7 +160,6 @@ public override bool Equals(object o) { return this.Context.Equals(that.Context) && ((this.ParentSpanId == null) ? (that.ParentSpanId == null) : this.ParentSpanId.Equals(that.ParentSpanId)) - && this.HasRemoteParent.Equals(that.HasRemoteParent) && this.Name.Equals(that.Name) && this.StartTimestamp.Equals(that.StartTimestamp) && this.Attributes.Equals(that.Attributes) @@ -192,8 +182,6 @@ public override int GetHashCode() h *= 1000003; h ^= (this.ParentSpanId == null) ? 0 : this.ParentSpanId.GetHashCode(); h *= 1000003; - h ^= (this.HasRemoteParent == null) ? 0 : this.HasRemoteParent.GetHashCode(); - h *= 1000003; h ^= this.Name.GetHashCode(); h *= 1000003; h ^= this.StartTimestamp.GetHashCode(); diff --git a/src/OpenTelemetry.Collector.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Collector.AspNetCore/Implementation/HttpInListener.cs index 8645f80ce0c..b12a0773f6c 100644 --- a/src/OpenTelemetry.Collector.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Collector.AspNetCore/Implementation/HttpInListener.cs @@ -63,7 +63,7 @@ public override void OnStartActivity(Activity activity, object payload) string path = (request.PathBase.HasValue || request.Path.HasValue) ? (request.PathBase + request.Path).ToString() : "/"; ISpan span = null; - this.Tracer.SpanBuilderWithRemoteParent(path, SpanKind.Server, ctx).SetSampler(this.SamplerFactory(request)).StartScopedSpan(out span); + this.Tracer.SpanBuilderWithParentContext(path, SpanKind.Server, ctx).SetSampler(this.SamplerFactory(request)).StartScopedSpan(out span); if (span == null) { // Debug.WriteLine("span is null"); diff --git a/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs b/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs index 7da3880630e..3dcac2c98f3 100644 --- a/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs +++ b/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs @@ -64,14 +64,13 @@ internal static bool ShouldSample(ISpanContext parentContext, string name, ISamp } var result = parentOptions.IsSampled; - bool hasRemoteParent = false; 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, hasRemoteParent, traceId, spanId, name, null); + result = sampler.ShouldSample(parentContext, traceId, spanId, name, null); builder = builder.SetIsSampled(result); traceOptions = builder.Build(); } @@ -83,8 +82,6 @@ internal static bool ShouldSample(ISpanContext parentContext, string name, ISamp internal static ISpanData ProfiledCommandToSpanData(ISpanContext context, string name, ISpanId parentSpanId, IProfiledCommand command) { - var hasRemoteParent = false; - // use https://github.com/opentracing/specification/blob/master/semantic_conventions.md for now // Timing example: @@ -107,7 +104,7 @@ internal static ISpanData ProfiledCommandToSpanData(ISpanContext context, string { TimedEvent.Create(Timestamp.FromMillis(timestamp.ToUnixTimeMilliseconds()), Event.Create("Enqueued")), TimedEvent.Create(Timestamp.FromMillis((timestamp = timestamp.Add(command.EnqueuedToSending)).ToUnixTimeMilliseconds()), Event.Create("Sent")), - TimedEvent.Create(Timestamp.FromMillis((timestamp = timestamp.Add(command.SentToResponse)).ToUnixTimeMilliseconds()), Event.Create("ResponseRecieved")), + TimedEvent.Create(Timestamp.FromMillis(timestamp.Add(command.SentToResponse).ToUnixTimeMilliseconds()), Event.Create("ResponseRecieved")), }, droppedEventsCount: 0); @@ -147,7 +144,7 @@ internal static ISpanData ProfiledCommandToSpanData(ISpanContext context, string Status status = Status.Ok; SpanKind kind = SpanKind.Client; - return SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + return SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); } } } diff --git a/src/OpenTelemetry.Exporter.ApplicationInsights/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.ApplicationInsights/Implementation/TraceExporterHandler.cs index 73d9847bd92..f227bff7e49 100644 --- a/src/OpenTelemetry.Exporter.ApplicationInsights/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.ApplicationInsights/Implementation/TraceExporterHandler.cs @@ -262,14 +262,7 @@ private void ExtractGenericProperties(ISpanData span, out SpanKind resultKind, o // TODO: Should this be a part of generic logic? if (resultKind == SpanKind.Internal) { - if (span.HasRemoteParent.HasValue && span.HasRemoteParent.Value) - { - resultKind = SpanKind.Server; - } - else - { - resultKind = SpanKind.Client; - } + resultKind = SpanKind.Client; } // 1 tick is 100 ns diff --git a/src/OpenTelemetry.Exporter.Ocagent/Implementation/SpanDataExtentions.cs b/src/OpenTelemetry.Exporter.Ocagent/Implementation/SpanDataExtentions.cs index bb92a0bc965..45e005ccc98 100644 --- a/src/OpenTelemetry.Exporter.Ocagent/Implementation/SpanDataExtentions.cs +++ b/src/OpenTelemetry.Exporter.Ocagent/Implementation/SpanDataExtentions.cs @@ -37,7 +37,7 @@ internal static Span ToProtoSpan(this ISpanData spanData) { Name = new TruncatableString { Value = spanData.Name }, - // TODO: Utilize new Span.Types.SpanKind below when updated protos are incorporated + // TODO: Utilize new Span.Types.SpanKind below when updated protos are incorporated, also confirm default for SpanKind.Internal Kind = spanData.Kind == SpanKind.Client || spanData.Kind == SpanKind.Producer ? Span.Types.SpanKind.Client : Span.Types.SpanKind.Server, TraceId = ByteString.CopyFrom(spanData.Context.TraceId.Bytes), @@ -62,8 +62,7 @@ internal static Span ToProtoSpan(this ISpanData spanData) Code = (int)spanData.Status.CanonicalCode, Message = spanData.Status.Description ?? string.Empty, }, - SameProcessAsParentSpan = - !spanData.HasRemoteParent.GetValueOrDefault() && spanData.ParentSpanId != null, + SameProcessAsParentSpan = spanData.ParentSpanId != null, ChildSpanCount = spanData.ChildSpanCount.HasValue ? (uint)spanData.ChildSpanCount.Value : 0, Attributes = FromIAttributes(spanData.Attributes), TimeEvents = FromITimeEvents(spanData.Events), diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs index e2f05ebcbdc..64ed4f95f92 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs @@ -147,11 +147,6 @@ private ZipkinSpanKind ToSpanKind(ISpanData spanData) } else if (spanData.Kind == SpanKind.Client) { - if (spanData.HasRemoteParent.HasValue && spanData.HasRemoteParent.Value) - { - return ZipkinSpanKind.SERVER; - } - return ZipkinSpanKind.CLIENT; } diff --git a/src/OpenTelemetry/Trace/NoopSpanBuilder.cs b/src/OpenTelemetry/Trace/NoopSpanBuilder.cs index 5312dbb6b39..b491c755c1d 100644 --- a/src/OpenTelemetry/Trace/NoopSpanBuilder.cs +++ b/src/OpenTelemetry/Trace/NoopSpanBuilder.cs @@ -50,14 +50,14 @@ public override ISpanBuilder SetRecordEvents(bool recordEvents) return this; } - internal static ISpanBuilder CreateWithParent(string spanName, SpanKind kind, ISpan parent = null) + internal static ISpanBuilder SetParent(string name, SpanKind kind, ISpan parent = null) { - return new NoopSpanBuilder(spanName, kind); + return new NoopSpanBuilder(name, kind); } - internal static ISpanBuilder CreateWithRemoteParent(string spanName, SpanKind kind, ISpanContext remoteParentSpanContext = null) + internal static ISpanBuilder SetParent(string name, SpanKind kind, ISpanContext parentContext = null) { - return new NoopSpanBuilder(spanName, kind); + return new NoopSpanBuilder(name, kind); } } } diff --git a/src/OpenTelemetry/Trace/NoopTracer.cs b/src/OpenTelemetry/Trace/NoopTracer.cs index c9b8b2fa7df..17c680fe8f6 100644 --- a/src/OpenTelemetry/Trace/NoopTracer.cs +++ b/src/OpenTelemetry/Trace/NoopTracer.cs @@ -26,15 +26,15 @@ internal NoopTracer() } /// - public override ISpanBuilder SpanBuilderWithExplicitParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null) + public override ISpanBuilder SpanBuilderWithParent(string name, SpanKind kind = SpanKind.Internal, ISpan parent = null) { - return NoopSpanBuilder.CreateWithParent(spanName, spanKind, parent); + return NoopSpanBuilder.SetParent(name, kind, parent); } /// - public override ISpanBuilder SpanBuilderWithRemoteParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null) + public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null) { - return NoopSpanBuilder.CreateWithRemoteParent(spanName, spanKind, remoteParentSpanContext); + return NoopSpanBuilder.SetParent(name, kind, parentContext); } /// diff --git a/src/OpenTelemetry/Trace/Span.cs b/src/OpenTelemetry/Trace/Span.cs index 9431c9b3e31..33a086a2e03 100644 --- a/src/OpenTelemetry/Trace/Span.cs +++ b/src/OpenTelemetry/Trace/Span.cs @@ -18,7 +18,6 @@ namespace OpenTelemetry.Trace { using System; using System.Collections.Generic; - using System.Linq; using OpenTelemetry.Common; using OpenTelemetry.Internal; using OpenTelemetry.Trace.Config; @@ -29,10 +28,8 @@ namespace OpenTelemetry.Trace public sealed class Span : SpanBase { private readonly ISpanId parentSpanId; - private readonly bool? hasRemoteParent; private readonly ITraceParams traceParams; private readonly IStartEndHandler startEndHandler; - private readonly Timer timestampConverter; private readonly DateTimeOffset startTime; private readonly object @lock = new object(); private AttributesWithCapacity attributes; @@ -48,14 +45,12 @@ private Span( SpanOptions options, string name, ISpanId parentSpanId, - bool? hasRemoteParent, ITraceParams traceParams, IStartEndHandler startEndHandler, Timer timestampConverter) : base(context, options) { this.parentSpanId = parentSpanId; - this.hasRemoteParent = hasRemoteParent; this.Name = name; this.traceParams = traceParams ?? throw new ArgumentNullException(nameof(traceParams)); this.startEndHandler = startEndHandler; @@ -65,19 +60,19 @@ private Span( { if (timestampConverter == null) { - this.timestampConverter = Timer.StartNew(); - this.startTime = this.timestampConverter.StartTime; + this.TimestampConverter = Timer.StartNew(); + this.startTime = this.TimestampConverter.StartTime; } else { - this.timestampConverter = timestampConverter; - this.startTime = this.timestampConverter.Now; + this.TimestampConverter = timestampConverter; + this.startTime = this.TimestampConverter.Now; } } else { this.startTime = DateTimeOffset.MinValue; - this.timestampConverter = timestampConverter; + this.TimestampConverter = timestampConverter; } } @@ -130,7 +125,7 @@ public override DateTimeOffset EndTime { lock (this.@lock) { - return this.hasBeenEnded ? this.endTime : this.timestampConverter.Now; + return this.hasBeenEnded ? this.endTime : this.TimestampConverter.Now; } } } @@ -142,7 +137,7 @@ public override TimeSpan Latency { lock (this.@lock) { - return this.hasBeenEnded ? this.endTime - this.startTime : this.timestampConverter.Now - this.startTime; + return this.hasBeenEnded ? this.endTime - this.startTime : this.TimestampConverter.Now - this.startTime; } } } @@ -165,30 +160,12 @@ public override bool IsSampleToLocalSpanStore } /// - public override ISpanId ParentSpanId - { - get - { - return this.parentSpanId; - } - } + public override ISpanId ParentSpanId => this.parentSpanId; /// - public override bool HasEnded - { - get - { - return this.hasBeenEnded; - } - } + public override bool HasEnded => this.hasBeenEnded; - internal Timer TimestampConverter - { - get - { - return this.timestampConverter; - } - } + internal Timer TimestampConverter { get; private set; } private AttributesWithCapacity InitializedAttributes { @@ -230,13 +207,7 @@ private TraceEvents InitializedLinks } } - private Status StatusWithDefault - { - get - { - return this.status ?? Trace.Status.Ok; - } - } + private Status StatusWithDefault => this.status ?? Trace.Status.Ok; /// public override void SetAttribute(string key, IAttributeValue value) @@ -294,7 +265,7 @@ public override void AddEvent(string name, IDictionary return; } - this.InitializedEvents.AddEvent(new EventWithTime(this.timestampConverter.Now, Event.Create(name, attributes))); + this.InitializedEvents.AddEvent(new EventWithTime(this.TimestampConverter.Now, Event.Create(name, attributes))); } } @@ -319,7 +290,7 @@ public override void AddEvent(IEvent addEvent) throw new ArgumentNullException(nameof(addEvent)); } - this.InitializedEvents.AddEvent(new EventWithTime(this.timestampConverter.Now, addEvent)); + this.InitializedEvents.AddEvent(new EventWithTime(this.TimestampConverter.Now, addEvent)); } } @@ -370,7 +341,7 @@ public override void End(EndSpanOptions options) } this.sampleToLocalSpanStore = options.SampleToLocalSpanStore; - this.endTime = this.timestampConverter.Now; + this.endTime = this.TimestampConverter.Now; this.hasBeenEnded = true; } @@ -388,13 +359,12 @@ public override ISpanData ToSpanData() Attributes attributesSpanData = this.attributes == null ? Attributes.Create(new Dictionary(), 0) : Attributes.Create(this.attributes, this.attributes.NumberOfDroppedAttributes); - ITimedEvents annotationsSpanData = CreateTimedEvents(this.InitializedEvents, this.timestampConverter); + ITimedEvents annotationsSpanData = CreateTimedEvents(this.InitializedEvents, this.TimestampConverter); LinkList linksSpanData = this.links == null ? LinkList.Create(new List(), 0) : LinkList.Create(this.links.Events, this.links.NumberOfDroppedEvents); return SpanData.Create( this.Context, this.parentSpanId, - this.hasRemoteParent, this.Name, Timestamp.FromDateTimeOffset(this.startTime), attributesSpanData, @@ -411,7 +381,6 @@ internal static ISpan StartSpan( SpanOptions options, string name, ISpanId parentSpanId, - bool? hasRemoteParent, ITraceParams traceParams, IStartEndHandler startEndHandler, Timer timestampConverter) @@ -421,7 +390,6 @@ internal static ISpan StartSpan( options, name, parentSpanId, - hasRemoteParent, traceParams, startEndHandler, timestampConverter); diff --git a/src/OpenTelemetry/Trace/SpanBuilder.cs b/src/OpenTelemetry/Trace/SpanBuilder.cs index 53791b60c54..d4071f8c2d6 100644 --- a/src/OpenTelemetry/Trace/SpanBuilder.cs +++ b/src/OpenTelemetry/Trace/SpanBuilder.cs @@ -22,13 +22,14 @@ namespace OpenTelemetry.Trace using OpenTelemetry.Internal; using OpenTelemetry.Trace.Config; + /// public class SpanBuilder : SpanBuilderBase { - private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpanContext remoteParentSpanContext = null, ISpan parent = null) : base(kind) + private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpanContext parentContext = null, ISpan parent = null) : base(kind) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.Parent = parent; - this.RemoteParentSpanContext = remoteParentSpanContext; + this.ParentSpanContext = parentContext; this.Options = options; } @@ -38,7 +39,7 @@ private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpa private ISpan Parent { get; set; } - private ISpanContext RemoteParentSpanContext { get; set; } + private ISpanContext ParentSpanContext { get; set; } private ISampler Sampler { get; set; } @@ -46,17 +47,16 @@ private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpa private bool RecordEvents { get; set; } + /// public override ISpan StartSpan() { - ISpanContext parentContext = this.RemoteParentSpanContext; - bool hasRemoteParent = true; + ISpanContext parentContext = this.ParentSpanContext; Timer timestampConverter = null; - if (this.RemoteParentSpanContext == null) + if (this.ParentSpanContext == null) { // This is not a child of a remote Span. Get the parent SpanContext from the parent Span if // any. ISpan parent = this.Parent; - hasRemoteParent = false; if (parent != null) { parentContext = parent.Context; @@ -68,15 +68,10 @@ public override ISpan StartSpan() timestampConverter = ((Span)parent).TimestampConverter; } } - else - { - hasRemoteParent = false; - } } return this.StartSpanInternal( parentContext, - hasRemoteParent, this.Name, this.Sampler, this.ParentLinks, @@ -84,32 +79,35 @@ public override ISpan StartSpan() timestampConverter); } + /// public override ISpanBuilder SetSampler(ISampler sampler) { this.Sampler = sampler ?? throw new ArgumentNullException(nameof(sampler)); return this; } + /// public override ISpanBuilder SetParentLinks(IEnumerable parentLinks) { this.ParentLinks = parentLinks ?? throw new ArgumentNullException(nameof(parentLinks)); return this; } + /// public override ISpanBuilder SetRecordEvents(bool recordEvents) { this.RecordEvents = recordEvents; return this; } - internal static ISpanBuilder CreateWithParent(string spanName, SpanKind kind, ISpan parent, SpanBuilderOptions options) + internal static ISpanBuilder Create(string name, SpanKind kind, ISpan parent, SpanBuilderOptions options) { - return new SpanBuilder(spanName, kind, options, null, parent); + return new SpanBuilder(name, kind, options, null, parent); } - internal static ISpanBuilder CreateWithRemoteParent(string spanName, SpanKind kind, ISpanContext remoteParentSpanContext, SpanBuilderOptions options) + internal static ISpanBuilder Create(string name, SpanKind kind, ISpanContext parentContext, SpanBuilderOptions options) { - return new SpanBuilder(spanName, kind, options, remoteParentSpanContext, null); + return new SpanBuilder(name, kind, options, parentContext, null); } private static bool IsAnyParentLinkSampled(IEnumerable parentLinks) @@ -140,7 +138,6 @@ private static void LinkSpans(ISpan span, IEnumerable parentLinks) private static bool MakeSamplingDecision( ISpanContext parent, - bool hasRemoteParent, string name, ISampler sampler, IEnumerable parentLinks, @@ -151,16 +148,16 @@ private static bool MakeSamplingDecision( // If users set a specific sampler in the SpanBuilder, use it. if (sampler != null) { - return sampler.ShouldSample(parent, hasRemoteParent, traceId, spanId, name, parentLinks); + return sampler.ShouldSample(parent, traceId, spanId, name, parentLinks); } // Use the default sampler if this is a root Span or this is an entry point Span (has remote // parent). - if (hasRemoteParent || parent == null || !parent.IsValid) + if (parent == null || !parent.IsValid) { return activeTraceParams .Sampler - .ShouldSample(parent, hasRemoteParent, traceId, spanId, name, parentLinks); + .ShouldSample(parent, traceId, spanId, name, parentLinks); } // Parent is always different than null because otherwise we use the default sampler. @@ -169,7 +166,6 @@ private static bool MakeSamplingDecision( private ISpan StartSpanInternal( ISpanContext parent, - bool hasRemoteParent, string name, ISampler sampler, IEnumerable parentLinks, @@ -187,10 +183,6 @@ private ISpan StartSpanInternal( // New root span. traceId = TraceId.GenerateRandomId(random); traceOptionsBuilder = TraceOptions.Builder(); - - // This is a root span so no remote or local parent. - // hasRemoteParent = null; - hasRemoteParent = false; } else { @@ -203,7 +195,6 @@ private ISpan StartSpanInternal( traceOptionsBuilder.SetIsSampled( MakeSamplingDecision( parent, - hasRemoteParent, name, sampler, parentLinks, @@ -223,7 +214,6 @@ private ISpan StartSpanInternal( spanOptions, name, parentSpanId, - hasRemoteParent, activeTraceParams, this.Options.StartEndHandler, timestampConverter); diff --git a/src/OpenTelemetry/Trace/Tracer.cs b/src/OpenTelemetry/Trace/Tracer.cs index def7918cc85..f9d569cb5a8 100644 --- a/src/OpenTelemetry/Trace/Tracer.cs +++ b/src/OpenTelemetry/Trace/Tracer.cs @@ -16,9 +16,9 @@ namespace OpenTelemetry.Trace { + using System.Threading; using OpenTelemetry.Trace.Config; using OpenTelemetry.Trace.Export; - using System.Threading; /// public sealed class Tracer : TracerBase @@ -38,15 +38,15 @@ public override void RecordSpanData(ISpanData span) } /// - public override ISpanBuilder SpanBuilderWithExplicitParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null) + public override ISpanBuilder SpanBuilderWithParent(string name, SpanKind kind = SpanKind.Internal, ISpan parent = null) { - return Trace.SpanBuilder.CreateWithParent(spanName, spanKind, parent, this.spanBuilderOptions); + return Trace.SpanBuilder.Create(name, kind, parent, this.spanBuilderOptions); } /// - public override ISpanBuilder SpanBuilderWithRemoteParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null) + public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null) { - return Trace.SpanBuilder.CreateWithRemoteParent(spanName, spanKind, remoteParentSpanContext, this.spanBuilderOptions); + return Trace.SpanBuilder.Create(name, kind, parentContext, this.spanBuilderOptions); } } } diff --git a/src/OpenTelemetry/Trace/TracerBase.cs b/src/OpenTelemetry/Trace/TracerBase.cs index 2128b1bfb2d..3b4b03aa02b 100644 --- a/src/OpenTelemetry/Trace/TracerBase.cs +++ b/src/OpenTelemetry/Trace/TracerBase.cs @@ -55,14 +55,14 @@ public IScope WithSpan(ISpan span) /// public ISpanBuilder SpanBuilder(string spanName, SpanKind spanKind = SpanKind.Internal) { - return this.SpanBuilderWithExplicitParent(spanName, spanKind, CurrentSpanUtils.CurrentSpan); + return this.SpanBuilderWithParent(spanName, spanKind, CurrentSpanUtils.CurrentSpan); } /// - public abstract ISpanBuilder SpanBuilderWithExplicitParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null); + public abstract ISpanBuilder SpanBuilderWithParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null); /// - public abstract ISpanBuilder SpanBuilderWithRemoteParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null); + public abstract ISpanBuilder SpanBuilderWithParentContext(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null); /// public abstract void RecordSpanData(ISpanData span); diff --git a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs index e4d96b9db41..e751f82c36f 100644 --- a/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Collector.AspNetCore.Tests/BasicTests.cs @@ -89,7 +89,7 @@ void ConfigureTestServices(IServiceCollection services) => } [Fact] - public async Task SuccesfulTemplateControllerCallUsesRemoteParentContext() + public async Task SuccesfulTemplateControllerCallUsesParentContext() { var startEndHandler = new Mock(); var tracer = new Tracer(new RandomGenerator(), startEndHandler.Object, new TraceConfig(), null); diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs index 28265b9ada2..58a08dbbe32 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs @@ -30,11 +30,23 @@ public class RedisProfilerEntryToSpanConverterSamplingTests public void ShouldSampleRespectsSamplerChoice() { var m = new Mock(); - m.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); + m.Setup(x => x.ShouldSample( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>())).Returns(true); + Assert.True(RedisProfilerEntryToSpanConverter.ShouldSample(SpanContext.Blank, "SET", m.Object, out var context, out var parentId)); m = new Mock(); - m.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(false); + m.Setup(x => x.ShouldSample( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>())).Returns(false); + Assert.False(RedisProfilerEntryToSpanConverter.ShouldSample(SpanContext.Blank, "SET", m.Object, out context, out parentId)); } @@ -55,7 +67,6 @@ public void ShouldSamplePassesArgumentsToSamplerAndReturnsInContext() m.Verify(x => x.ShouldSample( It.Is(y => y == parentContext), - It.Is(y => y == false), It.Is(y => y == traceId && y == context.TraceId), It.Is(y => y.IsValid && y == context.SpanId), It.Is(y => y == "SET"), @@ -66,13 +77,17 @@ public void ShouldSamplePassesArgumentsToSamplerAndReturnsInContext() public void ShouldSampleGeneratesNewTraceIdForInvalidContext() { var m = new Mock(); - m.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns((ISpanContext parentContext, bool hasRemoteParent, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) => parentContext.TraceOptions.IsSampled); + m.Setup(x => x.ShouldSample( + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny(), + It.IsAny>())).Returns((ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) => parentContext.TraceOptions.IsSampled); RedisProfilerEntryToSpanConverter.ShouldSample(SpanContext.Blank, "SET", m.Object, out var context, out var parentId); m.Verify(x => x.ShouldSample( It.Is(y => y == SpanContext.Blank), - It.Is(y => y == false), It.Is(y => y.IsValid && y == context.TraceId), It.Is(y => y.IsValid && y == context.SpanId), It.Is(y => y == "SET"), diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs index fdb73ba56fd..f5835797cb2 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs @@ -34,7 +34,7 @@ public void DrainSessionUsesCommandAsName() var parentSpan = BlankSpan.Instance; var profiledCommand = new Mock(); var sampler = new Mock(); - sampler.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); + sampler.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = new List(); RedisProfilerEntryToSpanConverter.DrainSession(parentSpan, new IProfiledCommand[] { profiledCommand.Object }, sampler.Object, result); diff --git a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs index 7a4a8ec9570..617f6706d0c 100644 --- a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs +++ b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs @@ -79,8 +79,8 @@ private ConcurrentQueue ConvertSpan(ISpanData data) public void OpenTelemetryTelemetryConverterTests_TracksRequest() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -111,7 +111,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithTracestate() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); context = SpanContext.Create( context.TraceId, @@ -122,7 +122,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithTracestate() .Set("k2", "v2") .Build()); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -142,11 +142,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithTracestate() public void OpenTelemetryTelemetryConverterTests_TracksRequestWithParent() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); parentSpanId = SpanId.FromBytes(this.testParentSpanIdBytes); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -159,11 +159,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithParent() public void OpenTelemetryTelemetryConverterTests_TracksRequestWithInvalidParent() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); parentSpanId = SpanId.Invalid; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -176,11 +176,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithInvalidParent( public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStatus() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); status = Status.Ok; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -197,11 +197,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStatus() public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStatusAndDescription() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); status = Status.Ok.WithDescription("all good"); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -219,11 +219,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStatusAndDescr public void OpenTelemetryTelemetryConverterTests_TracksRequestWithNonSuccessStatusAndDescription() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); status = Status.Cancelled.WithDescription("all bad"); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT @@ -241,11 +241,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithNonSuccessStat [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestErrorAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); attributes = Attributes.Create(new Dictionary() { { "error", AttributeValue.BooleanAttributeValue(true) } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -258,11 +258,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestErrorAttribute() public void OpenTelemetryTelemetryConverterTests_TracksClientDependency() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -292,11 +292,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksClientDependency() public void OpenTelemetryTelemetryConverterTests_TracksProducerDependency() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Producer; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -326,7 +326,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksProducerDependency() public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithTracestate() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; context = SpanContext.Create( @@ -339,7 +339,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithTracestate( .Build()); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -363,11 +363,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithAnnotations // ARRANGE var now = DateTime.UtcNow; - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); span.TimeEvents = new Span.Types.TimeEvents @@ -433,10 +433,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithAnnotations public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithParent() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; parentSpanId = SpanId.FromBytes(this.testParentSpanIdBytes); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -450,10 +450,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithParent() public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStatus() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; status = Status.Ok; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -471,10 +471,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStatus() public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStatusAndDescription() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; status = Status.Ok.WithDescription("all good"); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -494,10 +494,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStatusAndDe public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithNonSuccessStatusAndDescription() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; status = Status.Cancelled.WithDescription("all bad"); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -515,10 +515,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithNonSuccessS [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependencyErrorAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "error", AttributeValue.BooleanAttributeValue(true) } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -530,11 +530,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyErrorAttribute( [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnServerSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("server") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -544,11 +544,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnServerSpanK [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnClientSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("client") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -558,11 +558,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnClientSpanK [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnProducerSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("producer") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -572,11 +572,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnProducerSpa [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnConsumerSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("consumer") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -586,11 +586,11 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnConsumerSpa [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnOtherSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("other") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -600,10 +600,9 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnOtherSpanKi [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnSpanKindProperty() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); parentSpanId = SpanId.FromBytes(this.testParentSpanIdBytes); - hasRemoteParent = null; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -613,11 +612,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnSpanKindPro [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependencyBasedOnSpanKindProperty() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Client; parentSpanId = SpanId.FromBytes(this.testParentSpanIdBytes); - hasRemoteParent = null; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -625,12 +623,12 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyBasedOnSpanKind } [Fact] - public void OpenTelemetryTelemetryConverterTests_TracksDependenciesBasedOnSpanKindAttribute() + public void OpenTelemetryTelemetryConverterTests_TracksDependencyBasedOnSpanKindAttribute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Internal; attributes = Attributes.Create(new Dictionary() { { "span.kind", AttributeValue.StringAttributeValue("client") } }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -638,36 +636,22 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependenciesBasedOnSpanKi } [Fact] - public void OpenTelemetryTelemetryConverterTests_TracksRequestBasedOnSameProcessAsParentFlag() + public void OpenTelemetryTelemetryConverterTests_TracksDependencyBasedOnSameProcessAsParentFlag() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Internal; - hasRemoteParent = true; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); - var sentItems = this.ConvertSpan(span); - - Assert.True(sentItems.Single() is RequestTelemetry); - } - - [Fact] - public void OpenTelemetryTelemetryConverterTests_TracksDepednencyBasedOnSameProcessAsParentFlag() - { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); - kind = SpanKind.Internal; - hasRemoteParent = false; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); Assert.True(sentItems.Single() is DependencyTelemetry); } [Fact] - public void OpenTelemetryTelemetryConverterTests_TracksDepednencyBasedOnSameProcessAsParentFlagNotSet() + public void OpenTelemetryTelemetryConverterTests_TracksDependencyBasedOnSameProcessAsParentFlagNotSet() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Internal; - hasRemoteParent = null; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -678,9 +662,9 @@ public void OpenTelemetryTelemetryConverterTests_TracksDepednencyBasedOnSameProc //[Fact] //public void OpenTelemetryTelemetryConverterTests_TracksRequestWithoutName() //{ - // this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + // this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); // name = null; - // var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + // var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // var sentItems = this.ConvertSpan(span); @@ -690,9 +674,9 @@ public void OpenTelemetryTelemetryConverterTests_TracksDepednencyBasedOnSameProc [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithoutKind() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); kind = SpanKind.Internal; - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -703,10 +687,10 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithoutKind() //[Fact] //public void OpenTelemetryTelemetryConverterTests_TracksRequestWithoutStartAndEndTime() //{ - // this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + // this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); // startTimestamp = null; // endTimestamp = null; - // var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + // var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // var sentItems = this.ConvertSpan(span); @@ -718,7 +702,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithoutKind() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrl() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -727,7 +711,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrl() { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(409) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -740,7 +724,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrl() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithRelativeUrl() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -749,7 +733,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithRelativeUr { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(409) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -762,7 +746,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithRelativeUr [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndRoute() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -772,7 +756,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndRout { "http.route", AttributeValue.StringAttributeValue("route") }, { "http.status_code", AttributeValue.LongAttributeValue(503) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -785,7 +769,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndRout [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndNoMethod() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -793,7 +777,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndNoMe { "http.url", AttributeValue.StringAttributeValue(url.ToString()) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -806,7 +790,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlAndNoMe [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlOtherAttributesAreIgnored() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -818,7 +802,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlOtherAt { "http.port", AttributeValue.LongAttributeValue(8080) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -832,14 +816,14 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestWithUrlOtherAt public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStringStatusCode() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() { { "http.status_code", AttributeValue.LongAttributeValue(201) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -853,7 +837,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithStringStatusCo [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPortPathAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -864,7 +848,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPortPathAt { "http.port", AttributeValue.LongAttributeValue(123) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -877,7 +861,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPortPathAt [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestPortPathAndEmptyHostAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() { @@ -887,7 +871,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestPortPathAndEmp { "http.port", AttributeValue.LongAttributeValue(123) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -900,7 +884,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestPortPathAndEmp [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPathAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -910,7 +894,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPathAttrib { "http.host", AttributeValue.StringAttributeValue("host") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -923,7 +907,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostPathAttrib [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() { @@ -931,7 +915,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostAttributes { "http.host", AttributeValue.StringAttributeValue("host") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -944,7 +928,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestHostAttributes [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestOnlyMethodAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpIn"; attributes = Attributes.Create(new Dictionary() @@ -952,7 +936,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestOnlyMethodAttr { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -966,7 +950,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestOnlyMethodAttr public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStringStatusCode() { // ARRANGE - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); kind = SpanKind.Client; name = "HttpIn"; @@ -974,7 +958,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStringStatu { { "http.status_code", AttributeValue.LongAttributeValue(201) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); // ACT var sentItems = this.ConvertSpan(span); @@ -988,7 +972,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithStringStatu [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestUserAgent() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host/path"); var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"; name = "HttpIn"; @@ -997,7 +981,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestUserAgent() { "http.url", AttributeValue.StringAttributeValue(url.ToString()) }, { "http.user_agent", AttributeValue.StringAttributeValue(userAgent) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1008,7 +992,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpRequestUserAgent() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrl() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1018,7 +1002,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrl() { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1033,7 +1017,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrl() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithRelativeUrl() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1043,7 +1027,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithRelativ { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1058,7 +1042,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithRelativ [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrlIgnoresHostPortPath() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1071,7 +1055,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrlIgno { "http.port", AttributeValue.LongAttributeValue(8080) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1086,7 +1070,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithUrlIgno [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPortPath() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "HttpOut"; kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() @@ -1097,7 +1081,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPor { "http.port", AttributeValue.LongAttributeValue(123) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1112,7 +1096,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPor [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPort() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "HttpOut"; kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() @@ -1122,7 +1106,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPor { "http.port", AttributeValue.LongAttributeValue(123) }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1137,7 +1121,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHostPor [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithPathAndEmptyHost() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "HttpOut"; kind = SpanKind.Client; attributes = Attributes.Create(new Dictionary() @@ -1147,7 +1131,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithPathAnd { "http.host", AttributeValue.StringAttributeValue("") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1162,7 +1146,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithPathAnd [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHost() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1172,7 +1156,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHost() { "http.host", AttributeValue.StringAttributeValue("host") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1187,7 +1171,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithHost() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithMethod() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1196,7 +1180,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithMethod( { "http.method", AttributeValue.StringAttributeValue("POST") }, { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1212,7 +1196,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithMethod( [Fact] public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithStatusCodeOnly() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "HttpOut"; kind = SpanKind.Client; @@ -1220,7 +1204,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithStatusC { { "http.status_code", AttributeValue.LongAttributeValue(200) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1235,7 +1219,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksHttpDependencyWithStatusC [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithCustomAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "spanName"; kind = SpanKind.Client; @@ -1245,7 +1229,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithCustomAttri { "custom.longAttribute", AttributeValue.LongAttributeValue(long.MaxValue) }, { "custom.boolAttribute", AttributeValue.BooleanAttributeValue(true) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1265,7 +1249,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithCustomAttri [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestsWithCustomAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); var url = new Uri("https://host:123/path?query"); name = "spanName"; kind = SpanKind.Server; @@ -1275,7 +1259,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestsWithCustomAttribu { "custom.longAttribute", AttributeValue.LongAttributeValue(long.MaxValue) }, { "custom.boolAttribute", AttributeValue.BooleanAttributeValue(true) }, }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1303,7 +1287,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithLinks() var (link1SpanId, link1SpanIdBytes) = GenerateRandomId(8); var (link2SpanId, link2SpanIdBytes) = GenerateRandomId(8); - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "spanName"; kind = SpanKind.Client; @@ -1318,7 +1302,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithLinks() SpanContext.Create(TraceId.FromBytes(link2TraceIdBytes), SpanId.FromBytes(link2SpanIdBytes), TraceOptions.Default, Tracestate.Empty), LinkType.Unspecified), }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1353,7 +1337,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithLinks() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithLinksAndAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "spanName"; kind = SpanKind.Client; @@ -1376,7 +1360,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependencyWithLinksAndAtt }, droppedLinksCount: 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1404,7 +1388,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinks() var (link1SpanId, link1SpanIdBytes) = GenerateRandomId(8); var (link2SpanId, link2SpanIdBytes) = GenerateRandomId(8); - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "spanName"; kind = SpanKind.Server; @@ -1418,7 +1402,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinks() SpanContext.Create(TraceId.FromBytes(link2TraceIdBytes), SpanId.FromBytes(link2SpanIdBytes), TraceOptions.Default, Tracestate.Empty), LinkType.Unspecified), }, 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1453,7 +1437,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinks() [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinksAndAttributes() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); name = "spanName"; kind = SpanKind.Server; @@ -1476,7 +1460,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinksAndAttrib }, droppedLinksCount: 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1496,7 +1480,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithLinksAndAttrib [Fact] public void OpenTelemetryTelemetryConverterTests_TracksRequestWithEvents() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); Thread.Sleep(TimeSpan.FromTicks(10)); name = "spanName"; kind = SpanKind.Server; @@ -1514,7 +1498,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithEvents() }, droppedEventsCount: 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1621,7 +1605,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksRequestWithEventsAndNode( [Fact] public void OpenTelemetryTelemetryConverterTests_TracksDependenciesWithEvents() { - this.GetDefaults(out var context, out var parentSpanId, out var hasRemoteParent, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); + this.GetDefaults(out var context, out var parentSpanId, out var name, out var startTimestamp, out var attributes, out var events, out var links, out var childSpanCount, out var status, out var kind, out var endTimestamp); nowDateTimeOffset = nowDateTimeOffset.Subtract(TimeSpan.FromSeconds(1)); name = "spanName"; kind = SpanKind.Client; @@ -1639,7 +1623,7 @@ public void OpenTelemetryTelemetryConverterTests_TracksDependenciesWithEvents() }, droppedEventsCount: 0); - var span = SpanData.Create(context, parentSpanId, hasRemoteParent, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); + var span = SpanData.Create(context, parentSpanId, name, startTimestamp, attributes, events, links, childSpanCount, status, kind, endTimestamp); var sentItems = this.ConvertSpan(span); @@ -1901,7 +1885,6 @@ internal static string GetAssemblyVersionString() private void GetDefaults( out ISpanContext context, out ISpanId parentSpanId, - out bool? hasRemoteParent, out string name, out Timestamp startTimestamp, out IAttributes attributes, @@ -1914,7 +1897,6 @@ private void GetDefaults( { context = SpanContext.Create(TraceId.FromBytes(this.testTraceIdBytes), SpanId.FromBytes(this.testSpanIdBytes), TraceOptions.Default, Tracestate.Empty); parentSpanId = SpanId.Invalid; - hasRemoteParent = null; name = "spanName"; startTimestamp = NowTimestamp.AddDuration(Duration.Create(TimeSpan.FromSeconds(-1))); attributes = null; diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs index 299af2039de..cf560cd16d8 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs @@ -50,7 +50,6 @@ private ISpan CreateSpan(string spanName) recordSpanOptions, spanName, SpanId.GenerateRandomId(random), - false, TraceParams.Default, startEndHandler, null); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs index 72b09f17fa2..a61b6136632 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs @@ -316,7 +316,6 @@ private ISpan CreateSampledSpan(string spanName) recordSpanOptions, spanName, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -329,7 +328,6 @@ private ISpan CreateNotSampledSpan(string spanName) recordSpanOptions, spanName, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs index 74f9ef8b17d..6e4d4b9c085 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs @@ -70,7 +70,6 @@ public void SpanData_AllValues() SpanData.Create( spanContext, parentSpanId, - true, SPAN_NAME, startTimestamp, attributes, @@ -82,7 +81,6 @@ public void SpanData_AllValues() endTimestamp); Assert.Equal(spanContext, spanData.Context); Assert.Equal(parentSpanId, spanData.ParentSpanId); - Assert.True(spanData.HasRemoteParent); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(startTimestamp, spanData.StartTimestamp); Assert.Equal(attributes, spanData.Attributes); @@ -100,7 +98,6 @@ public void SpanData_RootActiveSpan() SpanData.Create( spanContext, null, - null, SPAN_NAME, startTimestamp, attributes, @@ -112,7 +109,6 @@ public void SpanData_RootActiveSpan() null); Assert.Equal(spanContext, spanData.Context); Assert.Null(spanData.ParentSpanId); - Assert.Null(spanData.HasRemoteParent); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(startTimestamp, spanData.StartTimestamp); Assert.Equal(attributes, spanData.Attributes); @@ -130,7 +126,6 @@ public void SpanData_AllDataEmpty() SpanData.Create( spanContext, parentSpanId, - false, SPAN_NAME, startTimestamp, Attributes.Create(new Dictionary(), 0), @@ -143,7 +138,6 @@ public void SpanData_AllDataEmpty() Assert.Equal(spanContext, spanData.Context); Assert.Equal(parentSpanId, spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(startTimestamp, spanData.StartTimestamp); Assert.Empty(spanData.Attributes.AttributeMap); @@ -161,7 +155,6 @@ public void SpanDataEquals() SpanData.Create( spanContext, parentSpanId, - false, SPAN_NAME, startTimestamp, attributes, @@ -175,7 +168,6 @@ public void SpanDataEquals() SpanData.Create( spanContext, parentSpanId, - false, SPAN_NAME, startTimestamp, attributes, @@ -189,7 +181,6 @@ public void SpanDataEquals() SpanData.Create( spanContext, parentSpanId, - false, SPAN_NAME, startTimestamp, Attributes.Create(new Dictionary(), 0), @@ -213,7 +204,6 @@ public void SpanData_ToString() SpanData.Create( spanContext, parentSpanId, - false, SPAN_NAME, startTimestamp, attributes, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs index 653e41d8ab8..4d0fa8cc9f8 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs @@ -60,7 +60,6 @@ private Span CreateSampledEndedSpan(string spanName) recordSpanOptions, spanName, null, - false, TraceParams.Default, startEndHandler, null); @@ -76,7 +75,6 @@ private Span CreateNotSampledEndedSpan(string spanName) recordSpanOptions, spanName, null, - false, TraceParams.Default, startEndHandler, null); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs index 9fb39fff388..4b81884bca9 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs @@ -53,7 +53,6 @@ public void AlwaysSampleSampler_AlwaysReturnTrue() Samplers.AlwaysSample .ShouldSample( sampledSpanContext, - false, traceId, spanId, "Another name", @@ -64,7 +63,6 @@ public void AlwaysSampleSampler_AlwaysReturnTrue() Samplers.AlwaysSample .ShouldSample( notSampledSpanContext, - false, traceId, spanId, "Yet another name", @@ -86,7 +84,6 @@ public void NeverSampleSampler_AlwaysReturnFalse() Samplers.NeverSample .ShouldSample( sampledSpanContext, - false, traceId, spanId, "bar", @@ -96,7 +93,6 @@ public void NeverSampleSampler_AlwaysReturnFalse() Samplers.NeverSample .ShouldSample( notSampledSpanContext, - false, traceId, spanId, "quux", @@ -190,28 +186,28 @@ public void ProbabilitySampler_SampleBasedOnTraceId() // is not less than probability * Long.MAX_VALUE; ITraceId notSampledtraceId = TraceId.FromBytes( - new byte[] { - 0x8F, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + new byte[] + { + 0x8F, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, }); Assert.False( defaultProbability.ShouldSample( null, - false, notSampledtraceId, SpanId.GenerateRandomId(random), SPAN_NAME, @@ -220,28 +216,28 @@ public void ProbabilitySampler_SampleBasedOnTraceId() // is less than probability * Long.MAX_VALUE; ITraceId sampledtraceId = TraceId.FromBytes( - new byte[] { - 0x00, - 0x00, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + new byte[] + { + 0x00, + 0x00, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, }); Assert.True( defaultProbability.ShouldSample( null, - false, sampledtraceId, SpanId.GenerateRandomId(random), SPAN_NAME, @@ -271,7 +267,6 @@ private static void AssertSamplerSamplesWithProbability( { if (sampler.ShouldSample( parent, - false, TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), SPAN_NAME, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs index e7478add20b..5545fdb9a4c 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs @@ -47,14 +47,13 @@ public SpanBuilderTest() [Fact] public void StartSpanNullParent() { - ISpan span = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions).StartSpan(); + var span = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions).StartSpan(); Assert.True(span.Context.IsValid); Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); Assert.InRange(spanData.StartTimestamp, Timestamp.FromDateTimeOffset(DateTimeOffset.Now).AddDuration(Duration.Create(-1, 0)), Timestamp.FromDateTimeOffset(DateTimeOffset.Now).AddDuration(Duration.Create(1, 0))); Assert.Equal(SPAN_NAME, spanData.Name); } @@ -62,8 +61,8 @@ public void StartSpanNullParent() [Fact] public void StartSpanNullParentWithRecordEvents() { - ISpan span = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var span = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .SetRecordEvents(true) .StartSpan(); @@ -72,14 +71,13 @@ public void StartSpanNullParentWithRecordEvents() Assert.False(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); } [Fact] public void StartSpanNullParentNoRecordOptions() { - ISpan span = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var span = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(span.Context.IsValid); @@ -90,46 +88,42 @@ public void StartSpanNullParentNoRecordOptions() [Fact] public void StartChildSpan() { - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions).StartSpan(); + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions).StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.True(rootSpan.Options.HasFlag(SpanOptions.RecordEvents)); Assert.True(rootSpan.Context.TraceOptions.IsSampled); - Assert.False(((Span)rootSpan).ToSpanData().HasRemoteParent); ISpan childSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions).StartSpan(); + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions).StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(rootSpan.Context.TraceId, childSpan.Context.TraceId); Assert.Equal(rootSpan.Context.SpanId, ((Span)childSpan).ToSpanData().ParentSpanId); - Assert.False(((Span)childSpan).ToSpanData().HasRemoteParent); Assert.Equal(((Span)rootSpan).TimestampConverter, ((Span)childSpan).TimestampConverter); } [Fact] - public void StartRemoteSpan_NullParent() + public void StartSpan_NullParent() { - ISpan span = - SpanBuilder.CreateWithRemoteParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions).StartSpan(); + var span = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpanContext)null, spanBuilderOptions).StartSpan(); Assert.True(span.Context.IsValid); Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); } [Fact] - public void StartRemoteSpanInvalidParent() + public void StartSpanInvalidParent() { ISpan span = - SpanBuilder.CreateWithRemoteParent(SPAN_NAME, SpanKind.Internal, SpanContext.Blank, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, SpanContext.Blank, spanBuilderOptions) .StartSpan(); Assert.True(span.Context.IsValid); Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); } [Fact] @@ -141,22 +135,22 @@ public void StartRemoteSpan() SpanId.GenerateRandomId(randomHandler), TraceOptions.Default, Tracestate.Empty); ISpan span = - SpanBuilder.CreateWithRemoteParent(SPAN_NAME, SpanKind.Internal, spanContext, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, spanContext, spanBuilderOptions) + .SetRecordEvents(true) .StartSpan(); Assert.True(span.Context.IsValid); Assert.Equal(spanContext.TraceId, span.Context.TraceId); - Assert.True(span.Context.TraceOptions.IsSampled); + Assert.False(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Equal(spanContext.SpanId, spanData.ParentSpanId); - Assert.True(spanData.HasRemoteParent); } [Fact] public void StartRootSpan_WithSpecifiedSampler() { // Apply given sampler before default sampler for root spans. - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(rootSpan.Context.IsValid); @@ -167,8 +161,8 @@ public void StartRootSpan_WithSpecifiedSampler() public void StartRootSpan_WithoutSpecifiedSampler() { // Apply default sampler (always true in the tests) for root spans. - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions).StartSpan(); + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions).StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.True(rootSpan.Context.TraceOptions.IsSampled); } @@ -176,15 +170,15 @@ public void StartRootSpan_WithoutSpecifiedSampler() [Fact] public void StartRemoteChildSpan_WithSpecifiedSampler() { - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.AlwaysSample) .StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.True(rootSpan.Context.TraceOptions.IsSampled); // Apply given sampler before default sampler for spans with remote parent. ISpan childSpan = - SpanBuilder.CreateWithRemoteParent(SPAN_NAME, SpanKind.Internal, rootSpan.Context, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan.Context, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(childSpan.Context.IsValid); @@ -195,33 +189,33 @@ public void StartRemoteChildSpan_WithSpecifiedSampler() [Fact] public void StartRemoteChildSpan_WithoutSpecifiedSampler() { - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.False(rootSpan.Context.TraceOptions.IsSampled); // Apply default sampler (always true in the tests) for spans with remote parent. ISpan childSpan = - SpanBuilder.CreateWithRemoteParent(SPAN_NAME, SpanKind.Internal, rootSpan.Context, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan.Context, spanBuilderOptions) .StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(rootSpan.Context.TraceId, childSpan.Context.TraceId); - Assert.True(childSpan.Context.TraceOptions.IsSampled); + Assert.False(childSpan.Context.TraceOptions.IsSampled); } [Fact] public void StartChildSpan_WithSpecifiedSampler() { - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.AlwaysSample) .StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.True(rootSpan.Context.TraceOptions.IsSampled); // Apply the given sampler for child spans. ISpan childSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(childSpan.Context.IsValid); @@ -232,15 +226,15 @@ public void StartChildSpan_WithSpecifiedSampler() [Fact] public void StartChildSpan_WithoutSpecifiedSampler() { - ISpan rootSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpan = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(rootSpan.Context.IsValid); Assert.False(rootSpan.Context.TraceOptions.IsSampled); // Don't apply the default sampler (always true) for child spans. ISpan childSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions).StartSpan(); + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions).StartSpan(); Assert.True(childSpan.Context.IsValid); Assert.Equal(rootSpan.Context.TraceId, childSpan.Context.TraceId); Assert.False(childSpan.Context.TraceOptions.IsSampled); @@ -249,19 +243,19 @@ public void StartChildSpan_WithoutSpecifiedSampler() [Fact] public void StartChildSpan_SampledLinkedParent() { - ISpan rootSpanUnsampled = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpanUnsampled = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.False(rootSpanUnsampled.Context.TraceOptions.IsSampled); - ISpan rootSpanSampled = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, null, spanBuilderOptions) + var rootSpanSampled = + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions) .SetSampler(Samplers.AlwaysSample) .StartSpan(); Assert.True(rootSpanSampled.Context.TraceOptions.IsSampled); // Sampled because the linked parent is sampled. ISpan childSpan = - SpanBuilder.CreateWithParent(SPAN_NAME, SpanKind.Internal, rootSpanUnsampled, spanBuilderOptions) + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpanUnsampled, spanBuilderOptions) .SetParentLinks(new List() { rootSpanSampled }) .StartSpan(); Assert.True(childSpan.Context.IsValid); @@ -300,7 +294,7 @@ public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() // If parent is sampled then the remote child must be sampled. ISpan childSpan = - SpanBuilder.CreateWithRemoteParent( + SpanBuilder.Create( SPAN_NAME, SpanKind.Internal, SpanContext.Create( @@ -318,7 +312,7 @@ public void StartRemoteChildSpan_WithProbabilitySamplerDefaultSampler() // If parent is not sampled then the remote child must be not sampled. childSpan = - SpanBuilder.CreateWithRemoteParent( + SpanBuilder.Create( SPAN_NAME, SpanKind.Internal, SpanContext.Create( diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs index 24c7fe27d09..db51815926d 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs @@ -69,7 +69,6 @@ public void ToSpanData_NoRecordEvents() noRecordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -92,7 +91,6 @@ public void NoEventsRecordedAfterEnd() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -124,7 +122,6 @@ public void ToSpanData_ActiveSpan() recordSpanOptions, SPAN_NAME, parentSpanId, - true, TraceParams.Default, startEndHandler, timestampConverter); @@ -145,7 +142,6 @@ public void ToSpanData_ActiveSpan() Assert.Equal(spanContext, spanData.Context); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(parentSpanId, spanData.ParentSpanId); - Assert.True(spanData.HasRemoteParent); Assert.Equal(0, spanData.Attributes.DroppedAttributesCount); Assert.Equal(expectedAttributes, spanData.Attributes.AttributeMap); Assert.Equal(0, spanData.Events.DroppedEventsCount); @@ -175,7 +171,6 @@ public void GoSpanData_EndedSpan() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -198,7 +193,6 @@ public void GoSpanData_EndedSpan() Assert.Equal(spanContext, spanData.Context); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(parentSpanId, spanData.ParentSpanId); - Assert.False(spanData.HasRemoteParent); Assert.Equal(0, spanData.Attributes.DroppedAttributesCount); Assert.Equal(expectedAttributes, spanData.Attributes.AttributeMap); Assert.Equal(0, spanData.Events.DroppedEventsCount); @@ -229,7 +223,6 @@ public void Status_ViaSetStatus() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -254,7 +247,6 @@ public void status_ViaEndSpanOptions() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -282,7 +274,6 @@ public void DroppingAttributes() recordSpanOptions, SPAN_NAME, parentSpanId, - false, traceParams, startEndHandler, timestampConverter); @@ -329,7 +320,6 @@ public void DroppingAndAddingAttributes() recordSpanOptions, SPAN_NAME, parentSpanId, - false, traceParams, startEndHandler, timestampConverter); @@ -387,7 +377,6 @@ public void DroppingEvents() recordSpanOptions, SPAN_NAME, parentSpanId, - false, traceParams, startEndHandler, timestampConverter); @@ -433,7 +422,6 @@ public void DroppingLinks() recordSpanOptions, SPAN_NAME, parentSpanId, - false, traceParams, startEndHandler, timestampConverter); @@ -468,7 +456,6 @@ public void SampleToLocalSpanStore() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -481,7 +468,6 @@ public void SampleToLocalSpanStore() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); @@ -505,7 +491,6 @@ public void SampleToLocalSpanStore_RunningSpan() recordSpanOptions, SPAN_NAME, parentSpanId, - false, TraceParams.Default, startEndHandler, timestampConverter); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TracerBaseTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/TracerBaseTest.cs index 8727c0cbd35..1960ea64ea3 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/TracerBaseTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TracerBaseTest.cs @@ -121,31 +121,31 @@ public void DefaultSpanBuilderWithName() [Fact] public void SpanBuilderWithParentAndName_NullName() { - Assert.Throws(() => noopTracer.SpanBuilderWithExplicitParent(spanName: null, parent: null)); + Assert.Throws(() => noopTracer.SpanBuilderWithParent(name: null, parent: null)); } [Fact] public void DefaultSpanBuilderWithParentAndName() { - Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithExplicitParent(SPAN_NAME, parent: null).StartSpan()); + Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithParent(SPAN_NAME, parent: null).StartSpan()); } [Fact] - public void spanBuilderWithRemoteParent_NullName() + public void DefaultSpanBuilderWithParentContext_NullName() { - Assert.Throws(() => noopTracer.SpanBuilderWithRemoteParent(null, remoteParentSpanContext: null)); + Assert.Throws(() => noopTracer.SpanBuilderWithParentContext(null, parentContext: null)); } [Fact] - public void DefaultSpanBuilderWithRemoteParent_NullParent() + public void DefaultSpanBuilderWithParentContext_NullParent() { - Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithRemoteParent(SPAN_NAME, remoteParentSpanContext: null).StartSpan()); + Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithParentContext(SPAN_NAME, parentContext: null).StartSpan()); } [Fact] - public void DefaultSpanBuilderWithRemoteParent() + public void DefaultSpanBuilderWithParentContext() { - Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithRemoteParent(SPAN_NAME, remoteParentSpanContext: SpanContext.Blank).StartSpan()); + Assert.Same(BlankSpan.Instance, noopTracer.SpanBuilderWithParentContext(SPAN_NAME, parentContext: SpanContext.Blank).StartSpan()); } [Fact] @@ -155,7 +155,7 @@ public void StartSpanWithParentFromContext() try { Assert.Same(span, tracer.CurrentSpan); - Mock.Get(tracer).Setup((tracer) => tracer.SpanBuilderWithExplicitParent(SPAN_NAME, SpanKind.Internal, span)).Returns(spanBuilder); + Mock.Get(tracer).Setup((tracer) => tracer.SpanBuilderWithParent(SPAN_NAME, SpanKind.Internal, span)).Returns(spanBuilder); Assert.Same(spanBuilder, tracer.SpanBuilder(SPAN_NAME)); } finally @@ -171,7 +171,7 @@ public void StartSpanWithInvalidParentFromContext() try { Assert.Same(BlankSpan.Instance, tracer.CurrentSpan); - Mock.Get(tracer).Setup((t) => t.SpanBuilderWithExplicitParent(SPAN_NAME, SpanKind.Internal, BlankSpan.Instance)).Returns(spanBuilder); + Mock.Get(tracer).Setup((t) => t.SpanBuilderWithParent(SPAN_NAME, SpanKind.Internal, BlankSpan.Instance)).Returns(spanBuilder); Assert.Same(spanBuilder, tracer.SpanBuilder(SPAN_NAME)); } finally diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs index 1a248dbe7af..0543f5a1a3a 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TracerTest.cs @@ -39,14 +39,14 @@ public TracerTest() [Fact] public void CreateSpanBuilder() { - ISpanBuilder spanBuilder = tracer.SpanBuilderWithExplicitParent(SPAN_NAME, parent: BlankSpan.Instance); + ISpanBuilder spanBuilder = tracer.SpanBuilderWithParent(SPAN_NAME, parent: BlankSpan.Instance); Assert.IsType(spanBuilder); } [Fact] public void CreateSpanBuilderWithRemoteParet() { - ISpanBuilder spanBuilder = tracer.SpanBuilderWithRemoteParent(SPAN_NAME, remoteParentSpanContext: SpanContext.Blank); + ISpanBuilder spanBuilder = tracer.SpanBuilderWithParentContext(SPAN_NAME, parentContext: SpanContext.Blank); Assert.IsType(spanBuilder); } } From 8fa2689ba98c058c5a7ea8a1440fe6af329ad003 Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 31 May 2019 22:26:53 -0700 Subject: [PATCH 4/7] aligned ISpan operaitons with the spec (#54) * aligned ISpan operaitons with the spec * noop never throws * rename noop span to test span to avoid confusions * fix tests * fixed unit test --- src/OpenTelemetry.Abstractions/Trace/ISpan.cs | 55 ++++++---- .../Trace/SpanExtensions.cs | 26 ++--- src/OpenTelemetry/Trace/Internal/BlankSpan.cs | 24 +++-- .../Trace/Internal/StartEndHandler.cs | 4 +- src/OpenTelemetry/Trace/Span.cs | 102 ++++++++++++------ src/OpenTelemetry/Trace/SpanBase.cs | 36 ++++--- src/OpenTelemetry/Trace/SpanBuilder.cs | 2 +- .../Impl/Trace/BlankSpanTest.cs | 12 ++- .../Impl/Trace/CurrentSpanUtilsTest.cs | 2 +- .../Export/InProcessRunningSpanStoreTest.cs | 1 + .../Export/InProcessSampledSpanStoreTest.cs | 2 + .../Impl/Trace/Export/SpanExporterTest.cs | 2 + .../Impl/Trace/Sampler/SamplersTest.cs | 2 +- .../Impl/Trace/SpanBaseTest.cs | 17 ++- .../Impl/Trace/SpanBuilderTest.cs | 12 +-- .../Impl/Trace/SpanTest.cs | 63 ++++++++--- .../Impl/Trace/{NoopSpan.cs => TestSpan.cs} | 27 +++-- 17 files changed, 264 insertions(+), 125 deletions(-) rename test/OpenTelemetry.Tests/Impl/Trace/{NoopSpan.cs => TestSpan.cs} (73%) diff --git a/src/OpenTelemetry.Abstractions/Trace/ISpan.cs b/src/OpenTelemetry.Abstractions/Trace/ISpan.cs index 52d4a0c8873..55e4dd257c0 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISpan.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISpan.cs @@ -27,44 +27,35 @@ namespace OpenTelemetry.Trace /// public interface ISpan { - /// - /// Gets the span name. Use UpdateSpan to explicitly set the span name. - /// - string Name { get; } - /// /// Gets the span context. /// ISpanContext Context { get; } /// - /// Gets the span options. + /// Gets a value indicating whether this span will be recorded. /// - SpanOptions Options { get; } + bool IsRecordingEvents { get; } /// - /// Gets or sets the status of the span execution. + /// Sets the status of the span execution. /// - Status Status { get; set; } - - /// - /// Gets or sets the kind of a span. - /// - SpanKind? Kind { get; set; } + Status Status { set; } /// /// Gets a value indicating whether this span was already stopped. /// + /// This method is not compliant with the specification. https://github.com/open-telemetry/opentelemetry-specification/issues/55 bool HasEnded { get; } /// - /// Updates the Span name. + /// Updates the name. /// - /// If used, this will override the name provided via SpanBuilder. - /// Upon this update, any sampling behavior based on Span name will depend on the + /// If used, this will override the name provided via . + /// Upon this update, any sampling behavior based on name will depend on the /// implementation. /// - /// name of the span. + /// Name of the span. void UpdateName(string name); /// @@ -75,10 +66,32 @@ public interface ISpan void SetAttribute(string key, IAttributeValue value); /// - /// Puts a list of attributes to the span. + /// Puts a new attribute to the span. + /// + /// Key of the attribute. + /// Attribute value. + void SetAttribute(string key, string value); + + /// + /// Puts a new attribute to the span. /// - /// Collection of attributes name/value pairs. - void SetAttributes(IDictionary attributes); + /// Key of the attribute. + /// Attribute value. + void SetAttribute(string key, long value); + + /// + /// Puts a new attribute to the span. + /// + /// Key of the attribute. + /// Attribute value. + void SetAttribute(string key, double value); + + /// + /// Puts a new attribute to the span. + /// + /// Key of the attribute. + /// Attribute value. + void SetAttribute(string key, bool value); /// /// Adds a single to the . diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs b/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs index eb8eddc7cb0..5a90702448d 100644 --- a/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs +++ b/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs @@ -171,52 +171,54 @@ public static ISpan PutHttpStatusCode(this ISpan span, int statusCode, string re { span.PutHttpStatusCodeAttribute(statusCode); + Status newStatus = Status.Ok; + if ((int)statusCode < 200) { - span.Status = Status.Unknown; + newStatus = Status.Unknown; } else if ((int)statusCode >= 200 && (int)statusCode <= 399) { - span.Status = Status.Ok; + newStatus = Status.Ok; } else if ((int)statusCode == 400) { - span.Status = Status.InvalidArgument; + newStatus = Status.InvalidArgument; } else if ((int)statusCode == 401) { - span.Status = Status.Unauthenticated; + newStatus = Status.Unauthenticated; } else if ((int)statusCode == 403) { - span.Status = Status.PermissionDenied; + newStatus = Status.PermissionDenied; } else if ((int)statusCode == 404) { - span.Status = Status.NotFound; + newStatus = Status.NotFound; } else if ((int)statusCode == 429) { - span.Status = Status.ResourceExhausted; + newStatus = Status.ResourceExhausted; } else if ((int)statusCode == 501) { - span.Status = Status.Unimplemented; + newStatus = Status.Unimplemented; } else if ((int)statusCode == 503) { - span.Status = Status.Unavailable; + newStatus = Status.Unavailable; } else if ((int)statusCode == 504) { - span.Status = Status.DeadlineExceeded; + newStatus = Status.DeadlineExceeded; } else { - span.Status = Status.Unknown; + newStatus = Status.Unknown; } - span.Status = span.Status.WithDescription(reasonPhrase); + span.Status = newStatus.WithDescription(reasonPhrase); return span; } diff --git a/src/OpenTelemetry/Trace/Internal/BlankSpan.cs b/src/OpenTelemetry/Trace/Internal/BlankSpan.cs index 70fc76f5b1d..ad2770a2336 100644 --- a/src/OpenTelemetry/Trace/Internal/BlankSpan.cs +++ b/src/OpenTelemetry/Trace/Internal/BlankSpan.cs @@ -33,8 +33,6 @@ private BlankSpan() public override Status Status { get; set; } - public override SpanKind? Kind { get; set; } - public override DateTimeOffset EndTime { get @@ -69,9 +67,7 @@ public override ISpanId ParentSpanId public override bool HasEnded => true; - public override void SetAttributes(IDictionary attributes) - { - } + public override bool IsRecordingEvents => false; public override void SetAttribute(string key, IAttributeValue value) { @@ -100,7 +96,23 @@ public override string ToString() public override ISpanData ToSpanData() { - throw new NotImplementedException(); + return null; + } + + public override void SetAttribute(string key, string value) + { + } + + public override void SetAttribute(string key, long value) + { + } + + public override void SetAttribute(string key, double value) + { + } + + public override void SetAttribute(string key, bool value) + { } } } diff --git a/src/OpenTelemetry/Trace/Internal/StartEndHandler.cs b/src/OpenTelemetry/Trace/Internal/StartEndHandler.cs index e2389464f7b..66027fb7b65 100644 --- a/src/OpenTelemetry/Trace/Internal/StartEndHandler.cs +++ b/src/OpenTelemetry/Trace/Internal/StartEndHandler.cs @@ -41,7 +41,7 @@ public StartEndHandler(ISpanExporter spanExporter, IRunningSpanStore runningSpan public void OnEnd(ISpan span) { - if ((span.Options.HasFlag(SpanOptions.RecordEvents) && this.enqueueEventForNonSampledSpans) + if ((span.IsRecordingEvents && this.enqueueEventForNonSampledSpans) || span.Context.TraceOptions.IsSampled) { this.eventQueue.Enqueue(new SpanEndEvent(span, this.spanExporter, this.runningSpanStore, this.sampledSpanStore)); @@ -50,7 +50,7 @@ public void OnEnd(ISpan span) public void OnStart(ISpan span) { - if (span.Options.HasFlag(SpanOptions.RecordEvents) && this.enqueueEventForNonSampledSpans) + if (span.IsRecordingEvents && this.enqueueEventForNonSampledSpans) { this.eventQueue.Enqueue(new SpanStartEvent(span, this.runningSpanStore)); } diff --git a/src/OpenTelemetry/Trace/Span.cs b/src/OpenTelemetry/Trace/Span.cs index 33a086a2e03..ffc38ea3665 100644 --- a/src/OpenTelemetry/Trace/Span.cs +++ b/src/OpenTelemetry/Trace/Span.cs @@ -44,6 +44,7 @@ private Span( ISpanContext context, SpanOptions options, string name, + SpanKind spanKind, ISpanId parentSpanId, ITraceParams traceParams, IStartEndHandler startEndHandler, @@ -56,7 +57,8 @@ private Span( this.startEndHandler = startEndHandler; this.hasBeenEnded = false; this.sampleToLocalSpanStore = false; - if (options.HasFlag(SpanOptions.RecordEvents)) + this.Kind = spanKind; + if (this.IsRecordingEvents) { if (timestampConverter == null) { @@ -79,6 +81,11 @@ private Span( /// public override string Name { get; protected set; } + /// + /// Gets or sets span kind. + /// + internal SpanKind? Kind { get; set; } + /// public override Status Status { @@ -92,7 +99,7 @@ public override Status Status set { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -110,14 +117,6 @@ public override Status Status } } - /// - public override SpanKind? Kind - { - get; - - set; // TODO: do we need to notify when attempt to set on already closed Span? - } - /// public override DateTimeOffset EndTime { @@ -209,30 +208,20 @@ private TraceEvents InitializedLinks private Status StatusWithDefault => this.status ?? Trace.Status.Ok; - /// - public override void SetAttribute(string key, IAttributeValue value) + public override bool IsRecordingEvents { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + get { - return; + return this.Options.HasFlag(SpanOptions.RecordEvents); } + } - lock (this.@lock) - { - if (this.hasBeenEnded) - { - // logger.log(Level.FINE, "Calling putAttributes() on an ended Span."); - return; - } - this.InitializedAttributes.PutAttribute(key, value); - } - } /// - public override void SetAttributes(IDictionary attributes) + public override void SetAttribute(string key, IAttributeValue value) { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -245,14 +234,14 @@ public override void SetAttributes(IDictionary attribut return; } - this.InitializedAttributes.PutAttributes(attributes); + this.InitializedAttributes.PutAttribute(key, value); } } /// public override void AddEvent(string name, IDictionary attributes) { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -272,7 +261,7 @@ public override void AddEvent(string name, IDictionary /// public override void AddEvent(IEvent addEvent) { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -297,7 +286,7 @@ public override void AddEvent(IEvent addEvent) /// public override void AddLink(ILink link) { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -322,7 +311,7 @@ public override void AddLink(ILink link) /// public override void End(EndSpanOptions options) { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { return; } @@ -351,7 +340,7 @@ public override void End(EndSpanOptions options) /// public override ISpanData ToSpanData() { - if (!this.Options.HasFlag(SpanOptions.RecordEvents)) + if (!this.IsRecordingEvents) { throw new InvalidOperationException("Getting SpanData for a Span without RECORD_EVENTS option."); } @@ -380,6 +369,7 @@ internal static ISpan StartSpan( ISpanContext context, SpanOptions options, string name, + SpanKind spanKind, ISpanId parentSpanId, ITraceParams traceParams, IStartEndHandler startEndHandler, @@ -389,6 +379,7 @@ internal static ISpan StartSpan( context, options, name, + spanKind, parentSpanId, traceParams, startEndHandler, @@ -396,7 +387,7 @@ internal static ISpan StartSpan( // Call onStart here instead of calling in the constructor to make sure the span is completely // initialized. - if (span.Options.HasFlag(SpanOptions.RecordEvents)) + if (span.IsRecordingEvents) { startEndHandler.OnStart(span); } @@ -420,5 +411,50 @@ private static ITimedEvents CreateTimedEvents(TraceEvents return TimedEvents.Create(eventsList, events.NumberOfDroppedEvents); } + + /// + + public override void SetAttribute(string key, string value) + { + if (!this.IsRecordingEvents) + { + return; + } + + this.SetAttribute(key, AttributeValue.StringAttributeValue(value)); + } + + /// + public override void SetAttribute(string key, long value) + { + if (!this.IsRecordingEvents) + { + return; + } + + this.SetAttribute(key, AttributeValue.LongAttributeValue(value)); + } + + /// + public override void SetAttribute(string key, double value) + { + if (!this.IsRecordingEvents) + { + return; + } + + this.SetAttribute(key, AttributeValue.DoubleAttributeValue(value)); + } + + /// + public override void SetAttribute(string key, bool value) + { + if (!this.IsRecordingEvents) + { + return; + } + + this.SetAttribute(key, AttributeValue.BooleanAttributeValue(value)); + } } } diff --git a/src/OpenTelemetry/Trace/SpanBase.cs b/src/OpenTelemetry/Trace/SpanBase.cs index 1aecaec1339..65137b1011a 100644 --- a/src/OpenTelemetry/Trace/SpanBase.cs +++ b/src/OpenTelemetry/Trace/SpanBase.cs @@ -53,21 +53,22 @@ protected SpanBase(ISpanContext context, SpanOptions options = SpanOptions.None) this.Options = options; } - /// + /// + /// Gets the span name. Use to explicitly set the span name. + /// public abstract string Name { get; protected set; } /// public virtual ISpanContext Context { get; } - /// + /// + /// Gets the span options. + /// public virtual SpanOptions Options { get; } /// public abstract Status Status { get; set; } - /// - public abstract SpanKind? Kind { get; set; } - /// public SpanBase Next { get; set; } @@ -98,21 +99,18 @@ protected SpanBase(ISpanContext context, SpanOptions options = SpanOptions.None) /// Gets a value indicating whether this span was already stopped. /// public abstract bool HasEnded { get; } - + /// - public void UpdateName(string name) - { - this.Name = name; - } + public abstract bool IsRecordingEvents { get; } /// - public virtual void SetAttribute(string key, IAttributeValue value) + public void UpdateName(string name) { - this.SetAttributes(new Dictionary() { { key, value } }); + this.Name = name; } /// - public abstract void SetAttributes(IDictionary attributes); + public abstract void SetAttribute(string key, IAttributeValue value); /// public void AddEvent(string name) @@ -151,5 +149,17 @@ public override string ToString() /// /// Span Data corresponding current span. public abstract ISpanData ToSpanData(); + + /// + public abstract void SetAttribute(string key, string value); + + /// + public abstract void SetAttribute(string key, long value); + + /// + public abstract void SetAttribute(string key, double value); + + /// + public abstract void SetAttribute(string key, bool value); } } diff --git a/src/OpenTelemetry/Trace/SpanBuilder.cs b/src/OpenTelemetry/Trace/SpanBuilder.cs index d4071f8c2d6..d9aa325479e 100644 --- a/src/OpenTelemetry/Trace/SpanBuilder.cs +++ b/src/OpenTelemetry/Trace/SpanBuilder.cs @@ -213,12 +213,12 @@ private ISpan StartSpanInternal( SpanContext.Create(traceId, spanId, traceOptions, parent?.Tracestate ?? Tracestate.Empty), spanOptions, name, + this.Kind, parentSpanId, activeTraceParams, this.Options.StartEndHandler, timestampConverter); LinkSpans(span, parentLinks); - span.Kind = this.Kind; return span; } } diff --git a/test/OpenTelemetry.Tests/Impl/Trace/BlankSpanTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/BlankSpanTest.cs index 49bb50cfed7..390dbd7267d 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/BlankSpanTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/BlankSpanTest.cs @@ -44,8 +44,16 @@ public void DoNotCrash() // Tests only that all the methods are not crashing/throwing errors. BlankSpan.Instance.SetAttribute( "MyStringAttributeKey2", AttributeValue.Create("MyStringAttributeValue2")); - BlankSpan.Instance.SetAttributes(attributes); - BlankSpan.Instance.SetAttributes(multipleAttributes); + foreach (var a in attributes) + { + BlankSpan.Instance.SetAttribute(a.Key, a.Value); + } + + foreach (var a in multipleAttributes) + { + BlankSpan.Instance.SetAttribute(a.Key, a.Value); + } + BlankSpan.Instance.AddEvent("MyEvent"); BlankSpan.Instance.AddEvent("MyEvent", attributes); BlankSpan.Instance.AddEvent("MyEvent", multipleAttributes); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs index 26222b136c0..77642f89376 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs @@ -39,7 +39,7 @@ public CurrentSpanUtilsTest() Tracestate.Empty); spanOptions = SpanOptions.RecordEvents; - var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; + var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; span = mockSpan.Object; } diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs index cf560cd16d8..5cb7249f363 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs @@ -49,6 +49,7 @@ private ISpan CreateSpan(string spanName) spanContext, recordSpanOptions, spanName, + SpanKind.Internal, SpanId.GenerateRandomId(random), TraceParams.Default, startEndHandler, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs index a61b6136632..e546ba10b73 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs @@ -315,6 +315,7 @@ private ISpan CreateSampledSpan(string spanName) sampledSpanContext, recordSpanOptions, spanName, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -327,6 +328,7 @@ private ISpan CreateNotSampledSpan(string spanName) notSampledSpanContext, recordSpanOptions, spanName, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs index 4d0fa8cc9f8..f0a99047f01 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs @@ -59,6 +59,7 @@ private Span CreateSampledEndedSpan(string spanName) sampledSpanContext, recordSpanOptions, spanName, + SpanKind.Internal, null, TraceParams.Default, startEndHandler, @@ -74,6 +75,7 @@ private Span CreateNotSampledEndedSpan(string spanName) notSampledSpanContext, recordSpanOptions, spanName, + SpanKind.Internal, null, TraceParams.Default, startEndHandler, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs index 4b81884bca9..b3404c8e397 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs @@ -42,7 +42,7 @@ public SamplersTest() spanId = SpanId.GenerateRandomId(random); sampledSpanContext = SpanContext.Create(traceId, parentSpanId, TraceOptions.Builder().SetIsSampled(true).Build(), Tracestate.Empty); notSampledSpanContext = SpanContext.Create(traceId, parentSpanId, TraceOptions.Default, Tracestate.Empty); - sampledSpan = new NoopSpan(sampledSpanContext, SpanOptions.RecordEvents); + sampledSpan = new TestSpan(sampledSpanContext, SpanOptions.RecordEvents); } [Fact] diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs index dbe6b350318..c90de7ca576 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs @@ -48,41 +48,40 @@ public SpanBaseTest() [Fact] public void NewSpan_WithNullContext() { - Assert.Throws(() => new NoopSpan(null, default(SpanOptions))); + Assert.Throws(() => new TestSpan(null, default(SpanOptions))); } [Fact] public void GetOptions_WhenNullOptions() { - ISpan span = new NoopSpan(notSampledSpanContext, default(SpanOptions)); + var span = new TestSpan(notSampledSpanContext, default(SpanOptions)); Assert.Equal(SpanOptions.None, span.Options); } [Fact] public void GetContextAndOptions() { - ISpan span = new NoopSpan(spanContext, spanOptions); + var span = new TestSpan(spanContext, spanOptions); Assert.Equal(spanContext, span.Context); Assert.Equal(spanOptions, span.Options); } [Fact] - public void PutAttributeCallsAddAttributesByDefault() + public void PutAttributeCallsAddAttributeByDefault() { - var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; - NoopSpan span = mockSpan.Object; + var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; + TestSpan span = mockSpan.Object; IAttributeValue val = AttributeValue.Create(true); span.SetAttribute("MyKey", val); span.End(); - mockSpan.Verify((s) => s.SetAttributes(It.Is>((d) => d.ContainsKey("MyKey")))); - + mockSpan.Verify((s) => s.SetAttribute(It.Is((arg) => arg == "MyKey"), It.Is((v) => v == val))); } [Fact] public void EndCallsEndWithDefaultOptions() { - var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; + var mockSpan = new Mock(spanContext, spanOptions) { CallBase = true }; var span = mockSpan.Object; span.End(); mockSpan.Verify((s) => s.End(EndSpanOptions.Default)); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs index 5545fdb9a4c..d09aa1ea4ed 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs @@ -50,7 +50,7 @@ public void StartSpanNullParent() var span = SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions).StartSpan(); Assert.True(span.Context.IsValid); - Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.True(span.IsRecordingEvents); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); @@ -67,7 +67,7 @@ public void StartSpanNullParentWithRecordEvents() .SetRecordEvents(true) .StartSpan(); Assert.True(span.Context.IsValid); - Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.True(span.IsRecordingEvents); Assert.False(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); @@ -81,7 +81,7 @@ public void StartSpanNullParentNoRecordOptions() .SetSampler(Samplers.NeverSample) .StartSpan(); Assert.True(span.Context.IsValid); - Assert.False(span.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.False(span.IsRecordingEvents); Assert.False(span.Context.TraceOptions.IsSampled); } @@ -91,7 +91,7 @@ public void StartChildSpan() var rootSpan = SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpan)null, spanBuilderOptions).StartSpan(); Assert.True(rootSpan.Context.IsValid); - Assert.True(rootSpan.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.True(rootSpan.IsRecordingEvents); Assert.True(rootSpan.Context.TraceOptions.IsSampled); ISpan childSpan = SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, rootSpan, spanBuilderOptions).StartSpan(); @@ -107,7 +107,7 @@ public void StartSpan_NullParent() var span = SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpanContext)null, spanBuilderOptions).StartSpan(); Assert.True(span.Context.IsValid); - Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.True(span.IsRecordingEvents); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); @@ -120,7 +120,7 @@ public void StartSpanInvalidParent() SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, SpanContext.Blank, spanBuilderOptions) .StartSpan(); Assert.True(span.Context.IsValid); - Assert.True(span.Options.HasFlag(SpanOptions.RecordEvents)); + Assert.True(span.IsRecordingEvents); Assert.True(span.Context.TraceOptions.IsSampled); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Null(spanData.ParentSpanId); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs index db51815926d..c72bf0c5528 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs @@ -63,17 +63,21 @@ public SpanTest() [Fact] public void ToSpanData_NoRecordEvents() { - ISpan span = + var span = Span.StartSpan( spanContext, noRecordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, timestampConverter); // Check that adding trace events after Span#End() does not throw any exception. - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } span.AddEvent(Event.Create(EVENT_DESCRIPTION)); span.AddEvent(EVENT_DESCRIPTION, attributes); span.AddLink(Link.FromSpanContext(spanContext, LinkType.ChildLinkedSpan)); @@ -90,6 +94,7 @@ public void NoEventsRecordedAfterEnd() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -97,7 +102,10 @@ public void NoEventsRecordedAfterEnd() span.End(); // Check that adding trace events after Span#End() does not throw any exception and are not // recorded. - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } span.SetAttribute( "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue")); @@ -121,6 +129,7 @@ public void ToSpanData_ActiveSpan() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -129,7 +138,11 @@ public void ToSpanData_ActiveSpan() span.SetAttribute( "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue")); - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } + interval = TimeSpan.FromMilliseconds(100); span.AddEvent(Event.Create(EVENT_DESCRIPTION)); interval = TimeSpan.FromMilliseconds(200); @@ -170,6 +183,7 @@ public void GoSpanData_EndedSpan() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -178,7 +192,11 @@ public void GoSpanData_EndedSpan() span.SetAttribute( "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue")); - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } + interval = TimeSpan.FromMilliseconds(100); span.AddEvent(Event.Create(EVENT_DESCRIPTION)); interval = TimeSpan.FromMilliseconds(200); @@ -217,11 +235,12 @@ public void GoSpanData_EndedSpan() [Fact] public void Status_ViaSetStatus() { - ISpan span = - Span.StartSpan( + var span = + (Span)Span.StartSpan( spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -241,11 +260,12 @@ public void Status_ViaSetStatus() [Fact] public void status_ViaEndSpanOptions() { - ISpan span = - Span.StartSpan( + var span = + (Span)Span.StartSpan( spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -273,6 +293,7 @@ public void DroppingAttributes() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, traceParams, startEndHandler, @@ -281,7 +302,11 @@ public void DroppingAttributes() { IDictionary attributes = new Dictionary(); attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i)); - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } + } ISpanData spanData = ((Span)span).ToSpanData(); Assert.Equal(maxNumberOfAttributes, spanData.Attributes.DroppedAttributesCount); @@ -319,6 +344,7 @@ public void DroppingAndAddingAttributes() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, traceParams, startEndHandler, @@ -327,7 +353,11 @@ public void DroppingAndAddingAttributes() { IDictionary attributes = new Dictionary(); attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i)); - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } + } ISpanData spanData = ((Span)span).ToSpanData(); Assert.Equal(maxNumberOfAttributes, spanData.Attributes.DroppedAttributesCount); @@ -344,7 +374,11 @@ public void DroppingAndAddingAttributes() { IDictionary attributes = new Dictionary(); attributes.Add("MyStringAttributeKey" + i, AttributeValue.LongAttributeValue(i)); - span.SetAttributes(attributes); + foreach (var attribute in attributes) + { + span.SetAttribute(attribute.Key, attribute.Value); + } + } spanData = ((Span)span).ToSpanData(); Assert.Equal(maxNumberOfAttributes * 3 / 2, spanData.Attributes.DroppedAttributesCount); @@ -376,6 +410,7 @@ public void DroppingEvents() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, traceParams, startEndHandler, @@ -421,6 +456,7 @@ public void DroppingLinks() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, traceParams, startEndHandler, @@ -455,6 +491,7 @@ public void SampleToLocalSpanStore() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -467,6 +504,7 @@ public void SampleToLocalSpanStore() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, @@ -490,6 +528,7 @@ public void SampleToLocalSpanStore_RunningSpan() spanContext, recordSpanOptions, SPAN_NAME, + SpanKind.Internal, parentSpanId, TraceParams.Default, startEndHandler, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/NoopSpan.cs b/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs similarity index 73% rename from test/OpenTelemetry.Tests/Impl/Trace/NoopSpan.cs rename to test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs index 7f48b37a2ab..d233390be48 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/NoopSpan.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs @@ -18,11 +18,10 @@ namespace OpenTelemetry.Trace.Test { using System; using System.Collections.Generic; - using OpenTelemetry.Trace.Export; - public class NoopSpan : SpanBase + public class TestSpan : SpanBase { - public NoopSpan(ISpanContext context, SpanOptions options) + public TestSpan(ISpanContext context, SpanOptions options) : base(context, options) { } @@ -35,14 +34,14 @@ public NoopSpan(ISpanContext context, SpanOptions options) public override Status Status { get; set; } - public override SpanKind? Kind { get; set; } - public override string Name { get; protected set; } public override ISpanId ParentSpanId { get; } public override bool HasEnded => true; + public override bool IsRecordingEvents => this.Options.HasFlag(SpanOptions.RecordEvents); + public override void AddEvent(string name, IDictionary attributes) { } @@ -59,7 +58,23 @@ public override void End(EndSpanOptions options) { } - public override void SetAttributes(IDictionary attributes) + public override void SetAttribute(string key, IAttributeValue value) + { + } + + public override void SetAttribute(string key, string value) + { + } + + public override void SetAttribute(string key, long value) + { + } + + public override void SetAttribute(string key, double value) + { + } + + public override void SetAttribute(string key, bool value) { } From 98a82fa023736f23427f46520e76d1f09f6e0d12 Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Sat, 1 Jun 2019 14:09:22 -0700 Subject: [PATCH 5/7] Update CONTRIBUTING.md (#52) --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e456765f7f..720726b4828 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,6 +40,8 @@ git merge upstream/master Remember to always work in a branch of your local copy, as you might otherwise have to contend with conflicts in master. +Please also see [GitHub workflow](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md#github-workflow) section of general project contributing guide. + ### Build You can use Visual Studio 2017+ or VS Code to contribute. Just open root folder @@ -69,4 +71,4 @@ Create a Pull Request with your changes. Please add any user-visible changes to `CHANGELOG.md`. The continuous integration build will run the tests and static analysis. It will also check that the pull request branch has no merge commits. When the changes are accepted, they will be merged or cherry-picked by an -OpenTelemetry repository maintainers. \ No newline at end of file +OpenTelemetry repository maintainers. From bca11b84189de0d92c6ea2206a16ff0d0312427c Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Mon, 3 Jun 2019 09:44:53 -0700 Subject: [PATCH 6/7] remove options from end and make SpanContext specific class (#57) --- .../Trace/ISampler.cs | 2 +- src/OpenTelemetry.Abstractions/Trace/ISpan.cs | 8 +-- .../Trace/ISpanContext.cs | 49 ------------------- .../Trace/ISpanData.cs | 4 +- .../Trace/ITracer.cs | 2 +- .../Trace/Propagation/IBinaryFormat.cs | 4 +- .../Trace/Propagation/ITextFormat.cs | 4 +- .../Trace/Sampler/AlwaysSampleSampler.cs | 2 +- .../Trace/Sampler/NeverSampleSampler.cs | 2 +- .../Trace/Sampler/ProbabilitySampler.cs | 2 +- .../Trace/SpanContext.cs | 28 +++++------ .../Trace/SpanData.cs | 6 +-- .../RedisProfilerEntryToSpanConverter.cs | 4 +- .../Implementation/TraceExporterHandler.cs | 2 +- .../Trace/EndSpanOptions.cs | 0 .../Trace/EndSpanOptionsBuilder.cs | 0 src/OpenTelemetry/Trace/Link.cs | 4 +- src/OpenTelemetry/Trace/NoopSpanBuilder.cs | 2 +- src/OpenTelemetry/Trace/NoopTracer.cs | 2 +- .../Trace/Propagation/B3Format.cs | 4 +- .../Trace/Propagation/BinaryFormatBase.cs | 4 +- .../Implementation/BinaryFormat.cs | 4 +- .../Implementation/NoopBinaryFormat.cs | 4 +- .../Implementation/NoopTextFormat.cs | 4 +- .../Trace/Propagation/TextFormatBase.cs | 4 +- .../Trace/Propagation/TraceContextFormat.cs | 4 +- src/OpenTelemetry/Trace/Span.cs | 4 +- src/OpenTelemetry/Trace/SpanBase.cs | 4 +- src/OpenTelemetry/Trace/SpanBuilder.cs | 12 ++--- .../Trace/SpanOptions.cs | 0 src/OpenTelemetry/Trace/Tracer.cs | 2 +- src/OpenTelemetry/Trace/TracerBase.cs | 2 +- src/OpenTelemetry/Utils/DefaultEventQueue.cs | 29 ----------- .../BasicTests.cs | 4 +- ...ofilerEntryToSpanConverterSamplingTests.cs | 12 ++--- .../RedisProfilerEntryToSpanConverterTests.cs | 2 +- .../TraceExporterHandlerTests.cs | 2 +- .../Impl/Trace/CurrentSpanUtilsTest.cs | 19 +------ .../Export/InProcessRunningSpanStoreTest.cs | 2 +- .../Export/InProcessSampledSpanStoreTest.cs | 16 +++--- .../Impl/Trace/Export/SpanDataTest.cs | 2 +- .../Impl/Trace/Export/SpanExporterTest.cs | 4 +- .../Impl/Trace/LinkTest.cs | 2 +- .../Impl/Trace/Propagation/B3FormatTest.cs | 2 +- .../Trace/Propagation/BinaryFormatTest.cs | 6 +-- .../Impl/Trace/Sampler/SamplersTest.cs | 6 +-- .../Impl/Trace/SpanBaseTest.cs | 4 +- .../Impl/Trace/SpanBuilderTest.cs | 4 +- .../Impl/Trace/SpanContextTest.cs | 4 +- .../Impl/Trace/SpanTest.cs | 10 ++-- .../Impl/Trace/TestSpan.cs | 2 +- 51 files changed, 105 insertions(+), 206 deletions(-) delete mode 100644 src/OpenTelemetry.Abstractions/Trace/ISpanContext.cs rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Trace/EndSpanOptions.cs (100%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Trace/EndSpanOptionsBuilder.cs (100%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Trace/SpanOptions.cs (100%) delete mode 100644 src/OpenTelemetry/Utils/DefaultEventQueue.cs diff --git a/src/OpenTelemetry.Abstractions/Trace/ISampler.cs b/src/OpenTelemetry.Abstractions/Trace/ISampler.cs index e57715d95db..97cd481976d 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISampler.cs @@ -41,6 +41,6 @@ public interface ISampler /// /// Links associated with the parent span. /// True of span needs to be created. False otherwise. - bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks); + bool ShouldSample(SpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks); } } diff --git a/src/OpenTelemetry.Abstractions/Trace/ISpan.cs b/src/OpenTelemetry.Abstractions/Trace/ISpan.cs index 55e4dd257c0..67b75cbb4e1 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISpan.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISpan.cs @@ -30,7 +30,7 @@ public interface ISpan /// /// Gets the span context. /// - ISpanContext Context { get; } + SpanContext Context { get; } /// /// Gets a value indicating whether this span will be recorded. @@ -118,12 +118,6 @@ public interface ISpan /// Link to add to the span. void AddLink(ILink link); - /// - /// Complete the span and set end span options. - /// - /// Span completion options. - void End(EndSpanOptions options); - /// /// End the span. /// diff --git a/src/OpenTelemetry.Abstractions/Trace/ISpanContext.cs b/src/OpenTelemetry.Abstractions/Trace/ISpanContext.cs deleted file mode 100644 index 2ed7a62a504..00000000000 --- a/src/OpenTelemetry.Abstractions/Trace/ISpanContext.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright 2018, OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace OpenTelemetry.Trace -{ - /// - /// Context associated with the span. - /// - public interface ISpanContext - { - /// - /// Gets tracestate collection that allows different vendors to participate in a trace. - /// - Tracestate Tracestate { get; } - - /// - /// Gets trace identifier. - /// - ITraceId TraceId { get; } - - /// - /// Gets stan identifier. - /// - ISpanId SpanId { get; } - - /// - /// Gets trace options. - /// - TraceOptions TraceOptions { get; } - - /// - /// Gets a value indicating whether the span is valid. - /// - bool IsValid { get; } - } -} diff --git a/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs b/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs index 537077012dd..59b71b5e982 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ISpanData.cs @@ -25,9 +25,9 @@ namespace OpenTelemetry.Trace public interface ISpanData { /// - /// Gets the . + /// Gets the . /// - ISpanContext Context { get; } + SpanContext Context { get; } /// /// Gets the parent . diff --git a/src/OpenTelemetry.Abstractions/Trace/ITracer.cs b/src/OpenTelemetry.Abstractions/Trace/ITracer.cs index 7fe44245841..9d54fb5ad0e 100644 --- a/src/OpenTelemetry.Abstractions/Trace/ITracer.cs +++ b/src/OpenTelemetry.Abstractions/Trace/ITracer.cs @@ -59,7 +59,7 @@ public interface ITracer /// Span kind. /// Remote parent context extracted from the wire. /// Span builder for the span with the given name and specified parent span context. - ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null); + ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, SpanContext parentContext = null); /// /// Records . This API allows to send a pre-populated span object to the diff --git a/src/OpenTelemetry.Abstractions/Trace/Propagation/IBinaryFormat.cs b/src/OpenTelemetry.Abstractions/Trace/Propagation/IBinaryFormat.cs index 1b48213b18f..ca2de681351 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Propagation/IBinaryFormat.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Propagation/IBinaryFormat.cs @@ -26,13 +26,13 @@ public interface IBinaryFormat /// /// Bytes array with the envoded span context in it. /// Span context deserialized from the byte array. - ISpanContext FromByteArray(byte[] bytes); + SpanContext FromByteArray(byte[] bytes); /// /// Serialize span context into the bytes array. /// /// Span context to serialize. /// Byte array with the encoded span context in it. - byte[] ToByteArray(ISpanContext spanContext); + byte[] ToByteArray(SpanContext spanContext); } } diff --git a/src/OpenTelemetry.Abstractions/Trace/Propagation/ITextFormat.cs b/src/OpenTelemetry.Abstractions/Trace/Propagation/ITextFormat.cs index 6f8572c2055..c1b6be2ce9f 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Propagation/ITextFormat.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Propagation/ITextFormat.cs @@ -39,7 +39,7 @@ public interface ITextFormat /// Span context to transmit over the wire. /// Object to set context on. Instance of this object will be passed to setter. /// Action that will set name and value pair on the object. - void Inject(ISpanContext spanContext, T carrier, Action setter); + void Inject(SpanContext spanContext, T carrier, Action setter); /// /// Extracts span context from textual representation. @@ -48,6 +48,6 @@ public interface ITextFormat /// Object to extract context from. Instance of this object will be passed to the getter. /// Function that will return string value of a key with the specified name. /// Span context from it's text representation. - ISpanContext Extract(T carrier, Func> getter); + SpanContext Extract(T carrier, Func> getter); } } diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs index 01632df5de4..958add66fc8 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs @@ -32,7 +32,7 @@ public string Description } } - public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(SpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { return true; } diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs index 3b915a1c905..7f8a787c9c4 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs @@ -32,7 +32,7 @@ public string Description } } - public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(SpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { return false; } diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs index c2e9a7887f2..7ea943a6a7d 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs @@ -40,7 +40,7 @@ public string Description public long IdUpperBound { get; } - public bool ShouldSample(ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) + public bool ShouldSample(SpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) { // If the parent is sampled keep the sampling decision. if (parentContext != null && parentContext.TraceOptions.IsSampled) diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanContext.cs b/src/OpenTelemetry.Abstractions/Trace/SpanContext.cs index 9cee61c223a..7f97830ccef 100644 --- a/src/OpenTelemetry.Abstractions/Trace/SpanContext.cs +++ b/src/OpenTelemetry.Abstractions/Trace/SpanContext.cs @@ -21,10 +21,10 @@ namespace OpenTelemetry.Trace /// child and across process boundaries. It contains the identifiers /// and associated with the and a set of . /// - public sealed class SpanContext : ISpanContext + public sealed class SpanContext { /// - /// A blank that can be used for no-op operations. + /// A blank that can be used for no-op operations. /// public static readonly SpanContext Blank = new SpanContext(Trace.TraceId.Invalid, Trace.SpanId.Invalid, TraceOptions.Default, Tracestate.Empty); @@ -37,39 +37,39 @@ private SpanContext(ITraceId traceId, ISpanId spanId, TraceOptions traceOptions, } /// - /// Gets the associated with this . + /// Gets the associated with this . /// public ITraceId TraceId { get; } /// - /// Gets the associated with this . + /// Gets the associated with this . /// public ISpanId SpanId { get; } /// - /// Gets the associated with this . + /// Gets the associated with this . /// public TraceOptions TraceOptions { get; } /// - /// Gets a value indicating whether this is valid. + /// Gets a value indicating whether this is valid. /// public bool IsValid => this.TraceId.IsValid && this.SpanId.IsValid; /// - /// Gets the associated with this . + /// Gets the associated with this . /// public Tracestate Tracestate { get; } /// - /// Creates a new with the given identifiers and options. + /// Creates a new with the given identifiers and options. /// - /// The to associate with the . - /// The to associate with the . - /// The to associate with the . - /// The to associate with the . - /// A new with the given identifiers and options. - public static ISpanContext Create(ITraceId traceId, ISpanId spanId, TraceOptions traceOptions, Tracestate tracestate) + /// The to associate with the . + /// The to associate with the . + /// The to associate with the . + /// The to associate with the . + /// A new with the given identifiers and options. + public static SpanContext Create(ITraceId traceId, ISpanId spanId, TraceOptions traceOptions, Tracestate tracestate) { return new SpanContext(traceId, spanId, traceOptions, tracestate); } diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanData.cs b/src/OpenTelemetry.Abstractions/Trace/SpanData.cs index 99e4f5f4098..857e14a2976 100644 --- a/src/OpenTelemetry.Abstractions/Trace/SpanData.cs +++ b/src/OpenTelemetry.Abstractions/Trace/SpanData.cs @@ -26,7 +26,7 @@ namespace OpenTelemetry.Trace public sealed class SpanData : ISpanData { internal SpanData( - ISpanContext context, + SpanContext context, ISpanId parentSpanId, string name, Timestamp startTimestamp, @@ -52,7 +52,7 @@ internal SpanData( } /// - public ISpanContext Context { get; } + public SpanContext Context { get; } /// public ISpanId ParentSpanId { get; } @@ -100,7 +100,7 @@ internal SpanData( /// The end of the . /// A new immutable . public static ISpanData Create( - ISpanContext context, + SpanContext context, ISpanId parentSpanId, string name, Timestamp startTimestamp, diff --git a/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs b/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs index 3dcac2c98f3..280306f6621 100644 --- a/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs +++ b/src/OpenTelemetry.Collector.StackExchangeRedis/Implementation/RedisProfilerEntryToSpanConverter.cs @@ -45,7 +45,7 @@ public static void DrainSession(ISpan parentSpan, IEnumerable } } - internal static bool ShouldSample(ISpanContext parentContext, string name, ISampler sampler, out ISpanContext context, out ISpanId parentSpanId) + internal static bool ShouldSample(SpanContext parentContext, string name, ISampler sampler, out SpanContext context, out ISpanId parentSpanId) { var traceId = TraceId.Invalid; var tracestate = Tracestate.Empty; @@ -80,7 +80,7 @@ internal static bool ShouldSample(ISpanContext parentContext, string name, ISamp return result; } - internal static ISpanData ProfiledCommandToSpanData(ISpanContext context, string name, ISpanId parentSpanId, IProfiledCommand command) + internal static ISpanData ProfiledCommandToSpanData(SpanContext context, string name, ISpanId parentSpanId, IProfiledCommand command) { // use https://github.com/opentracing/specification/blob/master/semantic_conventions.md for now diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs index 64ed4f95f92..16e019b1bdd 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs @@ -61,7 +61,7 @@ public async Task ExportAsync(IEnumerable spanDataList) internal ZipkinSpan GenerateSpan(ISpanData spanData, ZipkinEndpoint localEndpoint) { - ISpanContext context = spanData.Context; + SpanContext context = spanData.Context; long startTimestamp = this.ToEpochMicroseconds(spanData.StartTimestamp); long endTimestamp = this.ToEpochMicroseconds(spanData.EndTimestamp); diff --git a/src/OpenTelemetry.Abstractions/Trace/EndSpanOptions.cs b/src/OpenTelemetry/Trace/EndSpanOptions.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Trace/EndSpanOptions.cs rename to src/OpenTelemetry/Trace/EndSpanOptions.cs diff --git a/src/OpenTelemetry.Abstractions/Trace/EndSpanOptionsBuilder.cs b/src/OpenTelemetry/Trace/EndSpanOptionsBuilder.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Trace/EndSpanOptionsBuilder.cs rename to src/OpenTelemetry/Trace/EndSpanOptionsBuilder.cs diff --git a/src/OpenTelemetry/Trace/Link.cs b/src/OpenTelemetry/Trace/Link.cs index c2afbe93b9b..fbe525de941 100644 --- a/src/OpenTelemetry/Trace/Link.cs +++ b/src/OpenTelemetry/Trace/Link.cs @@ -42,12 +42,12 @@ private Link(ITraceId traceId, ISpanId spanId, LinkType type, IDictionary Attributes { get; } - public static ILink FromSpanContext(ISpanContext context, LinkType type) + public static ILink FromSpanContext(SpanContext context, LinkType type) { return new Link(context.TraceId, context.SpanId, type, EmptyAttributes); } - public static ILink FromSpanContext(ISpanContext context, LinkType type, IDictionary attributes) + public static ILink FromSpanContext(SpanContext context, LinkType type, IDictionary attributes) { IDictionary copy = new Dictionary(attributes); return new Link( diff --git a/src/OpenTelemetry/Trace/NoopSpanBuilder.cs b/src/OpenTelemetry/Trace/NoopSpanBuilder.cs index b491c755c1d..e8d4f583962 100644 --- a/src/OpenTelemetry/Trace/NoopSpanBuilder.cs +++ b/src/OpenTelemetry/Trace/NoopSpanBuilder.cs @@ -55,7 +55,7 @@ internal static ISpanBuilder SetParent(string name, SpanKind kind, ISpan parent return new NoopSpanBuilder(name, kind); } - internal static ISpanBuilder SetParent(string name, SpanKind kind, ISpanContext parentContext = null) + internal static ISpanBuilder SetParent(string name, SpanKind kind, SpanContext parentContext = null) { return new NoopSpanBuilder(name, kind); } diff --git a/src/OpenTelemetry/Trace/NoopTracer.cs b/src/OpenTelemetry/Trace/NoopTracer.cs index 17c680fe8f6..bb4fc721909 100644 --- a/src/OpenTelemetry/Trace/NoopTracer.cs +++ b/src/OpenTelemetry/Trace/NoopTracer.cs @@ -32,7 +32,7 @@ public override ISpanBuilder SpanBuilderWithParent(string name, SpanKind kind = } /// - public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null) + public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, SpanContext parentContext = null) { return NoopSpanBuilder.SetParent(name, kind, parentContext); } diff --git a/src/OpenTelemetry/Trace/Propagation/B3Format.cs b/src/OpenTelemetry/Trace/Propagation/B3Format.cs index 0a7f869db07..1cb7877ac04 100644 --- a/src/OpenTelemetry/Trace/Propagation/B3Format.cs +++ b/src/OpenTelemetry/Trace/Propagation/B3Format.cs @@ -53,7 +53,7 @@ public override ISet Fields } /// - public override ISpanContext Extract(T carrier, Func> getter) + public override SpanContext Extract(T carrier, Func> getter) { if (carrier == null) { @@ -111,7 +111,7 @@ public override ISpanContext Extract(T carrier, Func - public override void Inject(ISpanContext spanContext, T carrier, Action setter) + public override void Inject(SpanContext spanContext, T carrier, Action setter) { if (spanContext == null) { diff --git a/src/OpenTelemetry/Trace/Propagation/BinaryFormatBase.cs b/src/OpenTelemetry/Trace/Propagation/BinaryFormatBase.cs index 8d52736f0ae..ee50e4f4d33 100644 --- a/src/OpenTelemetry/Trace/Propagation/BinaryFormatBase.cs +++ b/src/OpenTelemetry/Trace/Propagation/BinaryFormatBase.cs @@ -30,8 +30,8 @@ internal static IBinaryFormat NoopBinaryFormat } } - public abstract ISpanContext FromByteArray(byte[] bytes); + public abstract SpanContext FromByteArray(byte[] bytes); - public abstract byte[] ToByteArray(ISpanContext spanContext); + public abstract byte[] ToByteArray(SpanContext spanContext); } } diff --git a/src/OpenTelemetry/Trace/Propagation/Implementation/BinaryFormat.cs b/src/OpenTelemetry/Trace/Propagation/Implementation/BinaryFormat.cs index 5f4b8f578f3..29d5a25f176 100644 --- a/src/OpenTelemetry/Trace/Propagation/Implementation/BinaryFormat.cs +++ b/src/OpenTelemetry/Trace/Propagation/Implementation/BinaryFormat.cs @@ -36,7 +36,7 @@ internal class BinaryFormat : BinaryFormatBase private const int TraceOptionOffset = TraceOptionFieldIdOffset + IdSize; private const int FormatLength = (4 * IdSize) + TraceId.Size + SpanId.Size + TraceOptions.Size; - public override ISpanContext FromByteArray(byte[] bytes) + public override SpanContext FromByteArray(byte[] bytes) { if (bytes == null) { @@ -80,7 +80,7 @@ public override ISpanContext FromByteArray(byte[] bytes) } } - public override byte[] ToByteArray(ISpanContext spanContext) + public override byte[] ToByteArray(SpanContext spanContext) { if (spanContext == null) { diff --git a/src/OpenTelemetry/Trace/Propagation/Implementation/NoopBinaryFormat.cs b/src/OpenTelemetry/Trace/Propagation/Implementation/NoopBinaryFormat.cs index 00aa1706038..dfa861633d4 100644 --- a/src/OpenTelemetry/Trace/Propagation/Implementation/NoopBinaryFormat.cs +++ b/src/OpenTelemetry/Trace/Propagation/Implementation/NoopBinaryFormat.cs @@ -20,7 +20,7 @@ namespace OpenTelemetry.Trace.Propagation.Implementation internal class NoopBinaryFormat : IBinaryFormat { - public ISpanContext FromByteArray(byte[] bytes) + public SpanContext FromByteArray(byte[] bytes) { if (bytes == null) { @@ -30,7 +30,7 @@ public ISpanContext FromByteArray(byte[] bytes) return SpanContext.Blank; } - public byte[] ToByteArray(ISpanContext spanContext) + public byte[] ToByteArray(SpanContext spanContext) { if (spanContext == null) { diff --git a/src/OpenTelemetry/Trace/Propagation/Implementation/NoopTextFormat.cs b/src/OpenTelemetry/Trace/Propagation/Implementation/NoopTextFormat.cs index 414ade16f6c..5b4d94ab0d9 100644 --- a/src/OpenTelemetry/Trace/Propagation/Implementation/NoopTextFormat.cs +++ b/src/OpenTelemetry/Trace/Propagation/Implementation/NoopTextFormat.cs @@ -27,7 +27,7 @@ internal NoopTextFormat() public override ISet Fields => new HashSet(); - public override void Inject(ISpanContext spanContext, T carrier, Action setter) + public override void Inject(SpanContext spanContext, T carrier, Action setter) { if (spanContext == null) { @@ -45,7 +45,7 @@ public override void Inject(ISpanContext spanContext, T carrier, Action(T carrier, Func> getter) + public override SpanContext Extract(T carrier, Func> getter) { if (carrier == null) { diff --git a/src/OpenTelemetry/Trace/Propagation/TextFormatBase.cs b/src/OpenTelemetry/Trace/Propagation/TextFormatBase.cs index 63ce95f2827..68becc0c5be 100644 --- a/src/OpenTelemetry/Trace/Propagation/TextFormatBase.cs +++ b/src/OpenTelemetry/Trace/Propagation/TextFormatBase.cs @@ -40,9 +40,9 @@ internal static ITextFormat NoopTextFormat } /// - public abstract ISpanContext Extract(T carrier, Func> getter); + public abstract SpanContext Extract(T carrier, Func> getter); /// - public abstract void Inject(ISpanContext spanContext, T carrier, Action setter); + public abstract void Inject(SpanContext spanContext, T carrier, Action setter); } } diff --git a/src/OpenTelemetry/Trace/Propagation/TraceContextFormat.cs b/src/OpenTelemetry/Trace/Propagation/TraceContextFormat.cs index 07d16335d10..d4f92d91519 100644 --- a/src/OpenTelemetry/Trace/Propagation/TraceContextFormat.cs +++ b/src/OpenTelemetry/Trace/Propagation/TraceContextFormat.cs @@ -39,7 +39,7 @@ public class TraceContextFormat : TextFormatBase public override ISet Fields => new HashSet { "tracestate", "traceparent" }; /// - public override ISpanContext Extract(T carrier, Func> getter) + public override SpanContext Extract(T carrier, Func> getter) { try { @@ -162,7 +162,7 @@ public override ISpanContext Extract(T carrier, Func - public override void Inject(ISpanContext spanContext, T carrier, Action setter) + public override void Inject(SpanContext spanContext, T carrier, Action setter) { var traceparent = string.Concat("00-", spanContext.TraceId.ToLowerBase16(), "-", spanContext.SpanId.ToLowerBase16()); traceparent = string.Concat(traceparent, spanContext.TraceOptions.IsSampled ? "-01" : "-00"); diff --git a/src/OpenTelemetry/Trace/Span.cs b/src/OpenTelemetry/Trace/Span.cs index ffc38ea3665..8fad84414e8 100644 --- a/src/OpenTelemetry/Trace/Span.cs +++ b/src/OpenTelemetry/Trace/Span.cs @@ -41,7 +41,7 @@ public sealed class Span : SpanBase private bool sampleToLocalSpanStore; private Span( - ISpanContext context, + SpanContext context, SpanOptions options, string name, SpanKind spanKind, @@ -366,7 +366,7 @@ public override ISpanData ToSpanData() } internal static ISpan StartSpan( - ISpanContext context, + SpanContext context, SpanOptions options, string name, SpanKind spanKind, diff --git a/src/OpenTelemetry/Trace/SpanBase.cs b/src/OpenTelemetry/Trace/SpanBase.cs index 65137b1011a..8e2c3f92eb5 100644 --- a/src/OpenTelemetry/Trace/SpanBase.cs +++ b/src/OpenTelemetry/Trace/SpanBase.cs @@ -37,7 +37,7 @@ internal SpanBase() /// /// Span context. /// Span creation options. - protected SpanBase(ISpanContext context, SpanOptions options = SpanOptions.None) + protected SpanBase(SpanContext context, SpanOptions options = SpanOptions.None) { if (context == null) { @@ -59,7 +59,7 @@ protected SpanBase(ISpanContext context, SpanOptions options = SpanOptions.None) public abstract string Name { get; protected set; } /// - public virtual ISpanContext Context { get; } + public virtual SpanContext Context { get; } /// /// Gets the span options. diff --git a/src/OpenTelemetry/Trace/SpanBuilder.cs b/src/OpenTelemetry/Trace/SpanBuilder.cs index d9aa325479e..9c166b05d80 100644 --- a/src/OpenTelemetry/Trace/SpanBuilder.cs +++ b/src/OpenTelemetry/Trace/SpanBuilder.cs @@ -25,7 +25,7 @@ namespace OpenTelemetry.Trace /// public class SpanBuilder : SpanBuilderBase { - private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpanContext parentContext = null, ISpan parent = null) : base(kind) + private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, SpanContext parentContext = null, ISpan parent = null) : base(kind) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.Parent = parent; @@ -39,7 +39,7 @@ private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpa private ISpan Parent { get; set; } - private ISpanContext ParentSpanContext { get; set; } + private SpanContext ParentSpanContext { get; set; } private ISampler Sampler { get; set; } @@ -50,7 +50,7 @@ private SpanBuilder(string name, SpanKind kind, SpanBuilderOptions options, ISpa /// public override ISpan StartSpan() { - ISpanContext parentContext = this.ParentSpanContext; + SpanContext parentContext = this.ParentSpanContext; Timer timestampConverter = null; if (this.ParentSpanContext == null) { @@ -105,7 +105,7 @@ internal static ISpanBuilder Create(string name, SpanKind kind, ISpan parent, Sp return new SpanBuilder(name, kind, options, null, parent); } - internal static ISpanBuilder Create(string name, SpanKind kind, ISpanContext parentContext, SpanBuilderOptions options) + internal static ISpanBuilder Create(string name, SpanKind kind, SpanContext parentContext, SpanBuilderOptions options) { return new SpanBuilder(name, kind, options, parentContext, null); } @@ -137,7 +137,7 @@ private static void LinkSpans(ISpan span, IEnumerable parentLinks) } private static bool MakeSamplingDecision( - ISpanContext parent, + SpanContext parent, string name, ISampler sampler, IEnumerable parentLinks, @@ -165,7 +165,7 @@ private static bool MakeSamplingDecision( } private ISpan StartSpanInternal( - ISpanContext parent, + SpanContext parent, string name, ISampler sampler, IEnumerable parentLinks, diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanOptions.cs b/src/OpenTelemetry/Trace/SpanOptions.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Trace/SpanOptions.cs rename to src/OpenTelemetry/Trace/SpanOptions.cs diff --git a/src/OpenTelemetry/Trace/Tracer.cs b/src/OpenTelemetry/Trace/Tracer.cs index f9d569cb5a8..ddbef194d6f 100644 --- a/src/OpenTelemetry/Trace/Tracer.cs +++ b/src/OpenTelemetry/Trace/Tracer.cs @@ -44,7 +44,7 @@ public override ISpanBuilder SpanBuilderWithParent(string name, SpanKind kind = } /// - public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, ISpanContext parentContext = null) + public override ISpanBuilder SpanBuilderWithParentContext(string name, SpanKind kind = SpanKind.Internal, SpanContext parentContext = null) { return Trace.SpanBuilder.Create(name, kind, parentContext, this.spanBuilderOptions); } diff --git a/src/OpenTelemetry/Trace/TracerBase.cs b/src/OpenTelemetry/Trace/TracerBase.cs index 3b4b03aa02b..4b01ab224e2 100644 --- a/src/OpenTelemetry/Trace/TracerBase.cs +++ b/src/OpenTelemetry/Trace/TracerBase.cs @@ -62,7 +62,7 @@ public ISpanBuilder SpanBuilder(string spanName, SpanKind spanKind = SpanKind.In public abstract ISpanBuilder SpanBuilderWithParent(string spanName, SpanKind spanKind = SpanKind.Internal, ISpan parent = null); /// - public abstract ISpanBuilder SpanBuilderWithParentContext(string spanName, SpanKind spanKind = SpanKind.Internal, ISpanContext remoteParentSpanContext = null); + public abstract ISpanBuilder SpanBuilderWithParentContext(string spanName, SpanKind spanKind = SpanKind.Internal, SpanContext remoteParentSpanContext = null); /// public abstract void RecordSpanData(ISpanData span); diff --git a/src/OpenTelemetry/Utils/DefaultEventQueue.cs b/src/OpenTelemetry/Utils/DefaultEventQueue.cs deleted file mode 100644 index d79ee9ef845..00000000000 --- a/src/OpenTelemetry/Utils/DefaultEventQueue.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright 2018, OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -namespace OpenTelemetry.Utils -{ - using System; - using OpenTelemetry.Internal; - - internal class DefaultEventQueue : IEventQueue - { - public void Enqueue(IEventQueueEntry entry) - { - throw new NotImplementedException(); - } - } -} diff --git a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs index dc26afd0bed..501be9a1e72 100644 --- a/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Collector.Dependencies.Tests/BasicTests.cs @@ -55,8 +55,8 @@ public async Task HttpDepenenciesCollectorInjectsHeadersAsync() var tf = new Mock(); tf - .Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) - .Callback((ISpanContext sc, HttpRequestMessage obj, Action setter) => + .Setup(m => m.Inject(It.IsAny(), It.IsAny(), It.IsAny>())) + .Callback((SpanContext sc, HttpRequestMessage obj, Action setter) => { expectedTraceId = sc.TraceId; expectedSpanId = sc.SpanId; diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs index 58a08dbbe32..a9b2e4f188d 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterSamplingTests.cs @@ -31,7 +31,7 @@ public void ShouldSampleRespectsSamplerChoice() { var m = new Mock(); m.Setup(x => x.ShouldSample( - It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), @@ -41,7 +41,7 @@ public void ShouldSampleRespectsSamplerChoice() m = new Mock(); m.Setup(x => x.ShouldSample( - It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), @@ -66,7 +66,7 @@ public void ShouldSamplePassesArgumentsToSamplerAndReturnsInContext() RedisProfilerEntryToSpanConverter.ShouldSample(parentContext, "SET", m.Object, out var context, out var parentId); m.Verify(x => x.ShouldSample( - It.Is(y => y == parentContext), + It.Is(y => y == parentContext), It.Is(y => y == traceId && y == context.TraceId), It.Is(y => y.IsValid && y == context.SpanId), It.Is(y => y == "SET"), @@ -78,16 +78,16 @@ public void ShouldSampleGeneratesNewTraceIdForInvalidContext() { var m = new Mock(); m.Setup(x => x.ShouldSample( - It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), - It.IsAny>())).Returns((ISpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) => parentContext.TraceOptions.IsSampled); + It.IsAny>())).Returns((SpanContext parentContext, ITraceId traceId, ISpanId spanId, string name, IEnumerable parentLinks) => parentContext.TraceOptions.IsSampled); RedisProfilerEntryToSpanConverter.ShouldSample(SpanContext.Blank, "SET", m.Object, out var context, out var parentId); m.Verify(x => x.ShouldSample( - It.Is(y => y == SpanContext.Blank), + It.Is(y => y == SpanContext.Blank), It.Is(y => y.IsValid && y == context.TraceId), It.Is(y => y.IsValid && y == context.SpanId), It.Is(y => y == "SET"), diff --git a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs index f5835797cb2..fe35dd86f36 100644 --- a/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs +++ b/test/OpenTelemetry.Collector.StackExchangeRedis.Tests/Implementation/RedisProfilerEntryToSpanConverterTests.cs @@ -34,7 +34,7 @@ public void DrainSessionUsesCommandAsName() var parentSpan = BlankSpan.Instance; var profiledCommand = new Mock(); var sampler = new Mock(); - sampler.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); + sampler.Setup(x => x.ShouldSample(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny>())).Returns(true); profiledCommand.Setup(m => m.Command).Returns("SET"); var result = new List(); RedisProfilerEntryToSpanConverter.DrainSession(parentSpan, new IProfiledCommand[] { profiledCommand.Object }, sampler.Object, result); diff --git a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs index 617f6706d0c..8c69f517a6a 100644 --- a/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs +++ b/test/OpenTelemetry.Exporter.ApplicationInsights.Tests/Implementation/TraceExporterHandlerTests.cs @@ -1883,7 +1883,7 @@ internal static string GetAssemblyVersionString() */ private void GetDefaults( - out ISpanContext context, + out SpanContext context, out ISpanId parentSpanId, out string name, out Timestamp startTimestamp, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs index 77642f89376..cafabcfa68f 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/CurrentSpanUtilsTest.cs @@ -25,7 +25,7 @@ public class CurrentSpanUtilsTest { private ISpan span; private RandomGenerator random; - private ISpanContext spanContext; + private SpanContext spanContext; private SpanOptions spanOptions; public CurrentSpanUtilsTest() @@ -64,22 +64,5 @@ public void WithSpan_CloseDetaches() } Assert.Null(CurrentSpanUtils.CurrentSpan); } - - [Fact] - public void WithSpan_CloseDetachesAndEndsSpan() - { - Assert.Null(CurrentSpanUtils.CurrentSpan); - IScope ss = CurrentSpanUtils.WithSpan(span, true); - try - { - Assert.Same(span, CurrentSpanUtils.CurrentSpan); - } - finally - { - ss.Dispose(); - } - Assert.Null(CurrentSpanUtils.CurrentSpan); - Mock.Get(span).Verify((s) => s.End(EndSpanOptions.Default)); - } } } diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs index 5cb7249f363..d4ca0c9e92d 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessRunningSpanStoreTest.cs @@ -40,7 +40,7 @@ public InProcessRunningSpanStoreTest() private ISpan CreateSpan(string spanName) { - ISpanContext spanContext = + SpanContext spanContext = SpanContext.Create( TraceId.GenerateRandomId(random), SpanId.GenerateRandomId(random), diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs index e546ba10b73..8d037809d8f 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/InProcessSampledSpanStoreTest.cs @@ -31,9 +31,9 @@ public class InProcessSampledSpanStoreTest private static readonly String REGISTERED_SPAN_NAME = "MySpanName/1"; private static readonly String NOT_REGISTERED_SPAN_NAME = "MySpanName/2"; private readonly RandomGenerator random = new RandomGenerator(1234); - private readonly ISpanContext sampledSpanContext; + private readonly SpanContext sampledSpanContext; - private readonly ISpanContext notSampledSpanContext; + private readonly SpanContext notSampledSpanContext; private readonly ISpanId parentSpanId; private readonly SpanOptions recordSpanOptions = SpanOptions.RecordEvents; @@ -309,9 +309,9 @@ public void IgnoreNegativeSpanLatency() Assert.Empty(samples); } - private ISpan CreateSampledSpan(string spanName) + private Span CreateSampledSpan(string spanName) { - return Span.StartSpan( + return (Span)Span.StartSpan( sampledSpanContext, recordSpanOptions, spanName, @@ -322,9 +322,9 @@ private ISpan CreateSampledSpan(string spanName) timestampConverter); } - private ISpan CreateNotSampledSpan(string spanName) + private Span CreateNotSampledSpan(string spanName) { - return Span.StartSpan( + return (Span)Span.StartSpan( notSampledSpanContext, recordSpanOptions, spanName, @@ -353,8 +353,8 @@ private void AddSpanNameToAllErrorBuckets(String spanName) { if (code != CanonicalCode.Ok) { - ISpan sampledSpan = CreateSampledSpan(spanName); - ISpan notSampledSpan = CreateNotSampledSpan(spanName); + var sampledSpan = CreateSampledSpan(spanName); + var notSampledSpan = CreateNotSampledSpan(spanName); interval += TimeSpan.FromTicks(10); sampledSpan.End(EndSpanOptions.Builder().SetStatus(code.ToStatus()).Build()); notSampledSpan.End(EndSpanOptions.Builder().SetStatus(code.ToStatus()).Build()); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs index 6e4d4b9c085..e26acf07c31 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanDataTest.cs @@ -35,7 +35,7 @@ public class SpanDataTest private static readonly SpanKind kind = SpanKind.Client; private static readonly int CHILD_SPAN_COUNT = 13; private readonly IRandomGenerator random = new RandomGenerator(1234); - private readonly ISpanContext spanContext; + private readonly SpanContext spanContext; private readonly ISpanId parentSpanId; private readonly IDictionary attributesMap = new Dictionary(); private readonly List> eventList = new List>(); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs index f0a99047f01..b3e0fb13b3a 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Export/SpanExporterTest.cs @@ -34,8 +34,8 @@ public class SpanExporterTest private static readonly String SPAN_NAME_1 = "MySpanName/1"; private static readonly String SPAN_NAME_2 = "MySpanName/2"; private readonly RandomGenerator random = new RandomGenerator(1234); - private readonly ISpanContext sampledSpanContext; - private readonly ISpanContext notSampledSpanContext; + private readonly SpanContext sampledSpanContext; + private readonly SpanContext notSampledSpanContext; private readonly ISpanExporter spanExporter = SpanExporter.Create(4, Duration.Create(1, 0)); private readonly IRunningSpanStore runningSpanStore = new InProcessRunningSpanStore(); private readonly IStartEndHandler startEndHandler; diff --git a/test/OpenTelemetry.Tests/Impl/Trace/LinkTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/LinkTest.cs index a3785eee801..1247134adf0 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/LinkTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/LinkTest.cs @@ -25,7 +25,7 @@ public class LinkTest { private readonly IDictionary attributesMap = new Dictionary(); private readonly IRandomGenerator random = new RandomGenerator(1234); - private readonly ISpanContext spanContext; + private readonly SpanContext spanContext; public LinkTest() diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Propagation/B3FormatTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Propagation/B3FormatTest.cs index 43980c83cdf..cec923ce016 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Propagation/B3FormatTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Propagation/B3FormatTest.cs @@ -68,7 +68,7 @@ public void ParseMissingSampledAndMissingFlag() IDictionary headersNotSampled = new Dictionary(); headersNotSampled.Add(B3Format.XB3TraceId, TRACE_ID_BASE16); headersNotSampled.Add(B3Format.XB3SpanId, SPAN_ID_BASE16); - ISpanContext spanContext = SpanContext.Create(TRACE_ID, SPAN_ID, TraceOptions.Default, Tracestate.Empty); + SpanContext spanContext = SpanContext.Create(TRACE_ID, SPAN_ID, TraceOptions.Default, Tracestate.Empty); Assert.Equal(spanContext, b3Format.Extract(headersNotSampled, getter)); } diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Propagation/BinaryFormatTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Propagation/BinaryFormatTest.cs index f77517e0a7b..8d84cecfdb6 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Propagation/BinaryFormatTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Propagation/BinaryFormatTest.cs @@ -31,13 +31,13 @@ public class BinaryFormatTest private static readonly byte[] EXAMPLE_BYTES = new byte[] {0, 0, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 1, 97, 98, 99, 100,101, 102, 103, 104, 2, 1}; - private static readonly ISpanContext EXAMPLE_SPAN_CONTEXT = SpanContext.Create(TRACE_ID, SPAN_ID, TRACE_OPTIONS, Tracestate.Empty); + private static readonly SpanContext EXAMPLE_SPAN_CONTEXT = SpanContext.Create(TRACE_ID, SPAN_ID, TRACE_OPTIONS, Tracestate.Empty); private readonly BinaryFormat binaryFormat = new BinaryFormat(); - private void TestSpanContextConversion(ISpanContext spanContext) + private void TestSpanContextConversion(SpanContext spanContext) { - ISpanContext propagatedBinarySpanContext = binaryFormat.FromByteArray(binaryFormat.ToByteArray(spanContext)); + SpanContext propagatedBinarySpanContext = binaryFormat.FromByteArray(binaryFormat.ToByteArray(spanContext)); Assert.Equal(spanContext, propagatedBinarySpanContext); } diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs index b3404c8e397..e2b5e0b44e0 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs @@ -31,8 +31,8 @@ public class SamplersTest private readonly ITraceId traceId; private readonly ISpanId parentSpanId; private readonly ISpanId spanId; - private readonly ISpanContext sampledSpanContext; - private readonly ISpanContext notSampledSpanContext; + private readonly SpanContext sampledSpanContext; + private readonly SpanContext notSampledSpanContext; private readonly ISpan sampledSpan; public SamplersTest() @@ -259,7 +259,7 @@ public void ProbabilitySampler_ToString() // Applies the given sampler to NUM_SAMPLE_TRIES random traceId/spanId pairs. private static void AssertSamplerSamplesWithProbability( - ISampler sampler, ISpanContext parent, IEnumerable parentLinks, double probability) + ISampler sampler, SpanContext parent, IEnumerable parentLinks, double probability) { RandomGenerator random = new RandomGenerator(1234); int count = 0; // Count of spans with sampling enabled diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs index c90de7ca576..425ff3cbc53 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBaseTest.cs @@ -25,8 +25,8 @@ namespace OpenTelemetry.Trace.Test public class SpanBaseTest { private RandomGenerator random; - private ISpanContext spanContext; - private ISpanContext notSampledSpanContext; + private SpanContext spanContext; + private SpanContext notSampledSpanContext; private SpanOptions spanOptions; public SpanBaseTest() diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs index d09aa1ea4ed..e3181355a56 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanBuilderTest.cs @@ -105,7 +105,7 @@ public void StartChildSpan() public void StartSpan_NullParent() { var span = - SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (ISpanContext)null, spanBuilderOptions).StartSpan(); + SpanBuilder.Create(SPAN_NAME, SpanKind.Internal, (SpanContext)null, spanBuilderOptions).StartSpan(); Assert.True(span.Context.IsValid); Assert.True(span.IsRecordingEvents); Assert.True(span.Context.TraceOptions.IsSampled); @@ -129,7 +129,7 @@ public void StartSpanInvalidParent() [Fact] public void StartRemoteSpan() { - ISpanContext spanContext = + SpanContext spanContext = SpanContext.Create( TraceId.GenerateRandomId(randomHandler), SpanId.GenerateRandomId(randomHandler), diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanContextTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanContextTest.cs index 8b1f4af6da4..3eaa4ef7349 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanContextTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanContextTest.cs @@ -28,13 +28,13 @@ public class SpanContextTest private static readonly byte[] firstSpanIdBytes = new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte)'a' }; private static readonly byte[] secondSpanIdBytes = new byte[] { (byte)'0', 0, 0, 0, 0, 0, 0, 0 }; - private static readonly ISpanContext first = + private static readonly SpanContext first = SpanContext.Create( TraceId.FromBytes(firstTraceIdBytes), SpanId.FromBytes(firstSpanIdBytes), TraceOptions.Default, Tracestate.Empty); - private static readonly ISpanContext second = + private static readonly SpanContext second = SpanContext.Create( TraceId.FromBytes(secondTraceIdBytes), SpanId.FromBytes(secondSpanIdBytes), diff --git a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs index c72bf0c5528..53a7bd984df 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/SpanTest.cs @@ -32,7 +32,7 @@ public class SpanTest private static readonly String SPAN_NAME = "MySpanName"; private static readonly String EVENT_DESCRIPTION = "MyEvent"; private readonly RandomGenerator random = new RandomGenerator(1234); - private readonly ISpanContext spanContext; + private readonly SpanContext spanContext; private readonly ISpanId parentSpanId; private TimeSpan interval = TimeSpan.FromMilliseconds(0); private readonly DateTimeOffset startTime = DateTimeOffset.Now; @@ -178,8 +178,8 @@ public void ToSpanData_ActiveSpan() [Fact] public void GoSpanData_EndedSpan() { - ISpan span = - Span.StartSpan( + var span = + (Span)Span.StartSpan( spanContext, recordSpanOptions, SPAN_NAME, @@ -486,8 +486,8 @@ public void DroppingLinks() [Fact] public void SampleToLocalSpanStore() { - ISpan span = - Span.StartSpan( + var span = + (Span)Span.StartSpan( spanContext, recordSpanOptions, SPAN_NAME, diff --git a/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs b/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs index d233390be48..43a4b8f8bc9 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/TestSpan.cs @@ -21,7 +21,7 @@ namespace OpenTelemetry.Trace.Test public class TestSpan : SpanBase { - public TestSpan(ISpanContext context, SpanOptions options) + public TestSpan(SpanContext context, SpanOptions options) : base(context, options) { } From cee79061447c8efe1d51d9ebf4005d437905b13a Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Tue, 4 Jun 2019 02:56:51 -0700 Subject: [PATCH 7/7] a few un=important class moves (#87) --- .../Trace/Config/TraceParams.cs | 3 +- .../{ => Internal}/AlwaysSampleSampler.cs | 4 +- .../{ => Internal}/NeverSampleSampler.cs | 2 +- .../Trace/Sampler/Samplers.cs | 14 +------ .../Trace/SpanExtensions.cs | 20 +++++----- .../ListenerHandler.cs | 2 +- .../ListenerHandler.cs | 2 +- .../Internal/IEventQueue.cs | 0 .../Internal/IEventQueueEntry.cs | 0 src/OpenTelemetry/OpenTelemetry.csproj | 1 - .../Trace/Sampler/ProbabilitySampler.cs | 6 +-- .../Utils/IElement.cs | 0 .../Impl/Trace/Config/TraceParamsTest.cs | 2 +- .../Impl/Trace/Sampler/SamplersTest.cs | 40 +++++++++---------- .../Impl}/Utils/CanonicalCodeExtensions.cs | 0 15 files changed, 42 insertions(+), 54 deletions(-) rename src/OpenTelemetry.Abstractions/Trace/Sampler/{ => Internal}/AlwaysSampleSampler.cs (92%) rename src/OpenTelemetry.Abstractions/Trace/Sampler/{ => Internal}/NeverSampleSampler.cs (96%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Internal/IEventQueue.cs (100%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Internal/IEventQueueEntry.cs (100%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Trace/Sampler/ProbabilitySampler.cs (95%) rename src/{OpenTelemetry.Abstractions => OpenTelemetry}/Utils/IElement.cs (100%) rename {src/OpenTelemetry.Abstractions => test/OpenTelemetry.Tests/Impl}/Utils/CanonicalCodeExtensions.cs (100%) diff --git a/src/OpenTelemetry.Abstractions/Trace/Config/TraceParams.cs b/src/OpenTelemetry.Abstractions/Trace/Config/TraceParams.cs index c6749b1f33b..010714977fe 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Config/TraceParams.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Config/TraceParams.cs @@ -26,9 +26,8 @@ public sealed class TraceParams : ITraceParams /// Default trace parameters. /// public static readonly ITraceParams Default = - new TraceParams(Samplers.GetProbabilitySampler(DefaultProbability), DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumMessageEvents, DefaultSpanMaxNumLinks); + new TraceParams(Samplers.AlwaysSample, DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumMessageEvents, DefaultSpanMaxNumLinks); - private const double DefaultProbability = 1e-4; private const int DefaultSpanMaxNumAttributes = 32; private const int DefaultSpanMaxNumEvents = 32; private const int DefaultSpanMaxNumMessageEvents = 128; diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/AlwaysSampleSampler.cs similarity index 92% rename from src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs rename to src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/AlwaysSampleSampler.cs index 958add66fc8..a5e7e923196 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/AlwaysSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/AlwaysSampleSampler.cs @@ -14,11 +14,11 @@ // limitations under the License. // -namespace OpenTelemetry.Trace.Sampler +namespace OpenTelemetry.Trace.Sampler.Internal { using System.Collections.Generic; - internal class AlwaysSampleSampler : ISampler + internal sealed class AlwaysSampleSampler : ISampler { internal AlwaysSampleSampler() { diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/NeverSampleSampler.cs similarity index 96% rename from src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs rename to src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/NeverSampleSampler.cs index 7f8a787c9c4..01c3988a52f 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/NeverSampleSampler.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/Internal/NeverSampleSampler.cs @@ -14,7 +14,7 @@ // limitations under the License. // -namespace OpenTelemetry.Trace.Sampler +namespace OpenTelemetry.Trace.Sampler.Internal { using System.Collections.Generic; diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs b/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs index 423bfff6deb..ea1275b407b 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Sampler/Samplers.cs @@ -24,21 +24,11 @@ public sealed class Samplers /// /// Gets the sampler that always sample. /// - public static ISampler AlwaysSample { get; } = new AlwaysSampleSampler(); + public static ISampler AlwaysSample { get; } = new Internal.AlwaysSampleSampler(); /// /// Gets the sampler than never samples. /// - public static ISampler NeverSample { get; } = new NeverSampleSampler(); - - /// - /// Gets the probability sampler. - /// - /// Probability to use. - /// Sampler that samples with the given probability. - public static ISampler GetProbabilitySampler(double probability) - { - return ProbabilitySampler.Create(probability); - } + public static ISampler NeverSample { get; } = new Internal.NeverSampleSampler(); } } diff --git a/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs b/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs index 5a90702448d..9982929099e 100644 --- a/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs +++ b/src/OpenTelemetry.Abstractions/Trace/SpanExtensions.cs @@ -30,7 +30,7 @@ public static class SpanExtensions /// Span with populated http method properties. public static ISpan PutHttpMethodAttribute(this ISpan span, string method) { - span.SetAttribute(SpanAttributeConstants.HttpMethodKey, AttributeValue.StringAttributeValue(method)); + span.SetAttribute(SpanAttributeConstants.HttpMethodKey, method); return span; } @@ -43,7 +43,7 @@ public static ISpan PutHttpMethodAttribute(this ISpan span, string method) /// Span with populated status code properties. public static ISpan PutHttpStatusCodeAttribute(this ISpan span, int statusCode) { - span.SetAttribute(SpanAttributeConstants.HttpStatusCodeKey, AttributeValue.LongAttributeValue(statusCode)); + span.SetAttribute(SpanAttributeConstants.HttpStatusCodeKey, statusCode); return span; } @@ -58,7 +58,7 @@ public static ISpan PutHttpUserAgentAttribute(this ISpan span, string userAgent) { if (!string.IsNullOrWhiteSpace(userAgent)) { - span.SetAttribute(SpanAttributeConstants.HttpUserAgentKey, AttributeValue.StringAttributeValue(userAgent)); + span.SetAttribute(SpanAttributeConstants.HttpUserAgentKey, userAgent); } return span; @@ -76,11 +76,11 @@ public static ISpan PutHttpHostAttribute(this ISpan span, string hostName, int p { if (port == 80 || port == 443) { - span.SetAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName)); + span.SetAttribute(SpanAttributeConstants.HttpHostKey, hostName); } else { - span.SetAttribute(SpanAttributeConstants.HttpHostKey, AttributeValue.StringAttributeValue(hostName + ":" + port)); + span.SetAttribute(SpanAttributeConstants.HttpHostKey, hostName + ":" + port); } return span; @@ -97,7 +97,7 @@ public static ISpan PutHttpRouteAttribute(this ISpan span, string route) { if (!string.IsNullOrEmpty(route)) { - span.SetAttribute(SpanAttributeConstants.HttpRouteKey, AttributeValue.StringAttributeValue(route)); + span.SetAttribute(SpanAttributeConstants.HttpRouteKey, route); } return span; @@ -114,7 +114,7 @@ public static ISpan PutHttpRawUrlAttribute(this ISpan span, string rawUrl) { if (!string.IsNullOrEmpty(rawUrl)) { - span.SetAttribute(SpanAttributeConstants.HttpUrlKey, AttributeValue.StringAttributeValue(rawUrl)); + span.SetAttribute(SpanAttributeConstants.HttpUrlKey, rawUrl); } return span; @@ -129,7 +129,7 @@ public static ISpan PutHttpRawUrlAttribute(this ISpan span, string rawUrl) /// Span with populated path properties. public static ISpan PutHttpPathAttribute(this ISpan span, string path) { - span.SetAttribute(SpanAttributeConstants.HttpPathKey, AttributeValue.StringAttributeValue(path)); + span.SetAttribute(SpanAttributeConstants.HttpPathKey, path); return span; } @@ -142,7 +142,7 @@ public static ISpan PutHttpPathAttribute(this ISpan span, string path) /// Span with populated response size properties. public static ISpan PutHttpResponseSizeAttribute(this ISpan span, long size) { - span.SetAttribute(SpanAttributeConstants.HttpResponseSizeKey, AttributeValue.LongAttributeValue(size)); + span.SetAttribute(SpanAttributeConstants.HttpResponseSizeKey, size); return span; } @@ -155,7 +155,7 @@ public static ISpan PutHttpResponseSizeAttribute(this ISpan span, long size) /// Span with populated request size properties. public static ISpan PutHttpRequestSizeAttribute(this ISpan span, long size) { - span.SetAttribute(SpanAttributeConstants.HttpRequestSizeKey, AttributeValue.LongAttributeValue(size)); + span.SetAttribute(SpanAttributeConstants.HttpRequestSizeKey, size); return span; } diff --git a/src/OpenTelemetry.Collector.AspNetCore/Implementation/OpenTelemetry.Collector.AspNetCore.Common/ListenerHandler.cs b/src/OpenTelemetry.Collector.AspNetCore/Implementation/OpenTelemetry.Collector.AspNetCore.Common/ListenerHandler.cs index 52d1b585fc7..43dba02c38b 100644 --- a/src/OpenTelemetry.Collector.AspNetCore/Implementation/OpenTelemetry.Collector.AspNetCore.Common/ListenerHandler.cs +++ b/src/OpenTelemetry.Collector.AspNetCore/Implementation/OpenTelemetry.Collector.AspNetCore.Common/ListenerHandler.cs @@ -50,7 +50,7 @@ public virtual void OnStopActivity(Activity activity, object payload) foreach (var tag in activity.Tags) { - span.SetAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value)); + span.SetAttribute(tag.Key, tag.Value); } } diff --git a/src/OpenTelemetry.Collector.Dependencies/Implementation/OpenTelemetry.Collector.Dependencies.Common/ListenerHandler.cs b/src/OpenTelemetry.Collector.Dependencies/Implementation/OpenTelemetry.Collector.Dependencies.Common/ListenerHandler.cs index 1122a816655..d05ec8a681a 100644 --- a/src/OpenTelemetry.Collector.Dependencies/Implementation/OpenTelemetry.Collector.Dependencies.Common/ListenerHandler.cs +++ b/src/OpenTelemetry.Collector.Dependencies/Implementation/OpenTelemetry.Collector.Dependencies.Common/ListenerHandler.cs @@ -50,7 +50,7 @@ public virtual void OnStopActivity(Activity activity, object payload) foreach (var tag in activity.Tags) { - span.SetAttribute(tag.Key, AttributeValue.StringAttributeValue(tag.Value)); + span.SetAttribute(tag.Key, tag.Value); } } diff --git a/src/OpenTelemetry.Abstractions/Internal/IEventQueue.cs b/src/OpenTelemetry/Internal/IEventQueue.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Internal/IEventQueue.cs rename to src/OpenTelemetry/Internal/IEventQueue.cs diff --git a/src/OpenTelemetry.Abstractions/Internal/IEventQueueEntry.cs b/src/OpenTelemetry/Internal/IEventQueueEntry.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Internal/IEventQueueEntry.cs rename to src/OpenTelemetry/Internal/IEventQueueEntry.cs diff --git a/src/OpenTelemetry/OpenTelemetry.csproj b/src/OpenTelemetry/OpenTelemetry.csproj index 018856be6b8..a094547a751 100644 --- a/src/OpenTelemetry/OpenTelemetry.csproj +++ b/src/OpenTelemetry/OpenTelemetry.csproj @@ -32,7 +32,6 @@ - diff --git a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs b/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs similarity index 95% rename from src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs rename to src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs index 7ea943a6a7d..57d852df0d1 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Sampler/ProbabilitySampler.cs +++ b/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs @@ -20,9 +20,9 @@ namespace OpenTelemetry.Trace.Sampler using System.Collections.Generic; using OpenTelemetry.Utils; - internal sealed class ProbabilitySampler : ISampler + public sealed class ProbabilitySampler : ISampler { - internal ProbabilitySampler(double probability, long idUpperBound) + private ProbabilitySampler(double probability, long idUpperBound) { this.Probability = probability; this.IdUpperBound = idUpperBound; @@ -107,7 +107,7 @@ public override int GetHashCode() return (int)h; } - internal static ProbabilitySampler Create(double probability) + public static ProbabilitySampler Create(double probability) { if (probability < 0.0 || probability > 1.0) { diff --git a/src/OpenTelemetry.Abstractions/Utils/IElement.cs b/src/OpenTelemetry/Utils/IElement.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Utils/IElement.cs rename to src/OpenTelemetry/Utils/IElement.cs diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs index d1243d4a346..19d0a88f916 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Config/TraceParamsTest.cs @@ -26,7 +26,7 @@ public class TraceParamsTest [Fact] public void DefaultTraceParams() { - Assert.Equal(Samplers.GetProbabilitySampler(1e-4), TraceParams.Default.Sampler); + Assert.Equal(Samplers.AlwaysSample, TraceParams.Default.Sampler); Assert.Equal(32, TraceParams.Default.MaxNumberOfAttributes); Assert.Equal(32, TraceParams.Default.MaxNumberOfEvents); Assert.Equal(128, TraceParams.Default.MaxNumberOfMessageEvents); diff --git a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs index e2b5e0b44e0..7286c4936b9 100644 --- a/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs +++ b/test/OpenTelemetry.Tests/Impl/Trace/Sampler/SamplersTest.cs @@ -108,32 +108,32 @@ public void NeverSampleSampler_ToString() [Fact] public void ProbabilitySampler_OutOfRangeHighProbability() { - Assert.Throws(() => Samplers.GetProbabilitySampler(1.01)); + Assert.Throws(() => ProbabilitySampler.Create(1.01)); } [Fact] public void ProbabilitySampler_OutOfRangeLowProbability() { - Assert.Throws(() => Samplers.GetProbabilitySampler(-0.00001)); + Assert.Throws(() => ProbabilitySampler.Create(-0.00001)); } [Fact] public void ProbabilitySampler_DifferentProbabilities_NotSampledParent() { - ISampler neverSample = Samplers.GetProbabilitySampler(0.0); + ISampler neverSample = ProbabilitySampler.Create(0.0); AssertSamplerSamplesWithProbability( neverSample, notSampledSpanContext, new List(), 0.0); - ISampler alwaysSample = Samplers.GetProbabilitySampler(1.0); + ISampler alwaysSample = ProbabilitySampler.Create(1.0); AssertSamplerSamplesWithProbability( alwaysSample, notSampledSpanContext, new List(), 1.0); - ISampler fiftyPercentSample = Samplers.GetProbabilitySampler(0.5); + ISampler fiftyPercentSample = ProbabilitySampler.Create(0.5); AssertSamplerSamplesWithProbability( fiftyPercentSample, notSampledSpanContext, new List(), 0.5); - ISampler twentyPercentSample = Samplers.GetProbabilitySampler(0.2); + ISampler twentyPercentSample = ProbabilitySampler.Create(0.2); AssertSamplerSamplesWithProbability( twentyPercentSample, notSampledSpanContext, new List(), 0.2); - ISampler twoThirdsSample = Samplers.GetProbabilitySampler(2.0 / 3.0); + ISampler twoThirdsSample = ProbabilitySampler.Create(2.0 / 3.0); AssertSamplerSamplesWithProbability( twoThirdsSample, notSampledSpanContext, new List(), 2.0 / 3.0); } @@ -141,19 +141,19 @@ public void ProbabilitySampler_DifferentProbabilities_NotSampledParent() [Fact] public void ProbabilitySampler_DifferentProbabilities_SampledParent() { - ISampler neverSample = Samplers.GetProbabilitySampler(0.0); + ISampler neverSample = ProbabilitySampler.Create(0.0); AssertSamplerSamplesWithProbability( neverSample, sampledSpanContext, new List(), 1.0); - ISampler alwaysSample = Samplers.GetProbabilitySampler(1.0); + ISampler alwaysSample = ProbabilitySampler.Create(1.0); AssertSamplerSamplesWithProbability( alwaysSample, sampledSpanContext, new List(), 1.0); - ISampler fiftyPercentSample = Samplers.GetProbabilitySampler(0.5); + ISampler fiftyPercentSample = ProbabilitySampler.Create(0.5); AssertSamplerSamplesWithProbability( fiftyPercentSample, sampledSpanContext, new List(), 1.0); - ISampler twentyPercentSample = Samplers.GetProbabilitySampler(0.2); + ISampler twentyPercentSample = ProbabilitySampler.Create(0.2); AssertSamplerSamplesWithProbability( twentyPercentSample, sampledSpanContext, new List(), 1.0); - ISampler twoThirdsSample = Samplers.GetProbabilitySampler(2.0 / 3.0); + ISampler twoThirdsSample = ProbabilitySampler.Create(2.0 / 3.0); AssertSamplerSamplesWithProbability( twoThirdsSample, sampledSpanContext, new List(), 1.0); } @@ -161,19 +161,19 @@ public void ProbabilitySampler_DifferentProbabilities_SampledParent() [Fact] public void ProbabilitySampler_DifferentProbabilities_SampledParentLink() { - ISampler neverSample = Samplers.GetProbabilitySampler(0.0); + ISampler neverSample = ProbabilitySampler.Create(0.0); AssertSamplerSamplesWithProbability( neverSample, notSampledSpanContext, new List() { sampledSpan }, 1.0); - ISampler alwaysSample = Samplers.GetProbabilitySampler(1.0); + ISampler alwaysSample = ProbabilitySampler.Create(1.0); AssertSamplerSamplesWithProbability( alwaysSample, notSampledSpanContext, new List() { sampledSpan }, 1.0); - ISampler fiftyPercentSample = Samplers.GetProbabilitySampler(0.5); + ISampler fiftyPercentSample = ProbabilitySampler.Create(0.5); AssertSamplerSamplesWithProbability( fiftyPercentSample, notSampledSpanContext, new List() { sampledSpan }, 1.0); - ISampler twentyPercentSample = Samplers.GetProbabilitySampler(0.2); + ISampler twentyPercentSample = ProbabilitySampler.Create(0.2); AssertSamplerSamplesWithProbability( twentyPercentSample, notSampledSpanContext, new List() { sampledSpan }, 1.0); - ISampler twoThirdsSample = Samplers.GetProbabilitySampler(2.0 / 3.0); + ISampler twoThirdsSample = ProbabilitySampler.Create(2.0 / 3.0); AssertSamplerSamplesWithProbability( twoThirdsSample, notSampledSpanContext, new List() { sampledSpan }, 1.0); } @@ -181,7 +181,7 @@ public void ProbabilitySampler_DifferentProbabilities_SampledParentLink() [Fact] public void ProbabilitySampler_SampleBasedOnTraceId() { - ISampler defaultProbability = Samplers.GetProbabilitySampler(0.0001); + ISampler defaultProbability = ProbabilitySampler.Create(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 = @@ -247,13 +247,13 @@ public void ProbabilitySampler_SampleBasedOnTraceId() [Fact] public void ProbabilitySampler_getDescription() { - Assert.Equal(String.Format("ProbabilitySampler({0:F6})", 0.5), Samplers.GetProbabilitySampler(0.5).Description); + Assert.Equal(String.Format("ProbabilitySampler({0:F6})", 0.5), ProbabilitySampler.Create(0.5).Description); } [Fact] public void ProbabilitySampler_ToString() { - var result = Samplers.GetProbabilitySampler(0.5).ToString(); + var result = ProbabilitySampler.Create(0.5).ToString(); Assert.Contains($"0{CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator}5", result); } diff --git a/src/OpenTelemetry.Abstractions/Utils/CanonicalCodeExtensions.cs b/test/OpenTelemetry.Tests/Impl/Utils/CanonicalCodeExtensions.cs similarity index 100% rename from src/OpenTelemetry.Abstractions/Utils/CanonicalCodeExtensions.cs rename to test/OpenTelemetry.Tests/Impl/Utils/CanonicalCodeExtensions.cs