Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ZipkinRemoveResourceTags
Browse files Browse the repository at this point in the history
cijothomas authored Jan 27, 2021
2 parents f462632 + 842daff commit a8a5fb8
Showing 81 changed files with 1,459 additions and 437 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [netcoreapp2.1,netcoreapp3.1]
version: [netcoreapp2.1,netcoreapp3.1,net5.0]
steps:
- uses: actions/checkout@v2
- name: Run redis docker-compose.integration
@@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [netcoreapp2.1,netcoreapp3.1]
version: [netcoreapp2.1,netcoreapp3.1,net5.0]
steps:
- uses: actions/checkout@v2
- name: Run sql docker-compose.integration
@@ -38,8 +38,19 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [netcoreapp2.1,netcoreapp3.1]
version: [netcoreapp2.1,netcoreapp3.1,net5.0]
steps:
- uses: actions/checkout@v2
- name: Run W3C Trace Context docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

otlp-exporter-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: [netcoreapp2.1,netcoreapp3.1]
steps:
- uses: actions/checkout@v2
- name: Run OTLP Exporter docker-compose.integration
run: docker-compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bb
for specific dates.

Meetings take place via [Zoom video conference](https://zoom.us/j/8287234601).
The passcode is `77777`.

Meeting notes are available as a public [Google
doc](https://docs.google.com/document/d/1yjjD6aBcLxlRazYrawukDgrhZMObwHARJbB9glWdHj8/edit?usp=sharing).
@@ -93,7 +94,6 @@ For edit access, get in touch on
Approvers
([@open-telemetry/dotnet-approvers](https://github.com/orgs/open-telemetry/teams/dotnet-approvers)):

* [Alan West](https://github.com/alanwest), NewRelic
* [Bruno Garcia](https://github.com/bruno-garcia), Sentry
* [Eddy Nakamura](https://github.com/eddynaka), Microsoft
* [Paulo Janotti](https://github.com/pjanotti), Splunk
@@ -105,6 +105,7 @@ repository](https://github.com/open-telemetry/community/blob/master/community-me
Maintainers
([@open-telemetry/dotnet-maintainers](https://github.com/orgs/open-telemetry/teams/dotnet-maintainers)):

* [Alan West](https://github.com/alanwest), New Relic
* [Cijo Thomas](https://github.com/cijothomas), Microsoft
* [Mike Goldsmith](https://github.com/MikeGoldsmith), Honeycomb
* [Mikel Blanchard](https://github.com/CodeBlanch), CoStar Group
1 change: 0 additions & 1 deletion build/Common.prod.props
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@
<PropertyGroup>
<RevisionNumber>0</RevisionNumber>
<RevisionNumber Condition="$(MinVerVersion.Split(`.`).Length) == 4">$(MinVerVersion.Split(`.`)[3])</RevisionNumber>
<AssemblyVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(RevisionNumber)</AssemblyVersion>
<Version>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(RevisionNumber)</Version>
<FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(RevisionNumber)</FileVersion>
</PropertyGroup>
8 changes: 8 additions & 0 deletions build/docker-compose.net5.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.7'

services:
tests:
build:
args:
PUBLISH_FRAMEWORK: net5.0
SDK_VERSION: 5.0
2 changes: 1 addition & 1 deletion docs/logs/extending-the-sdk/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -27,6 +27,6 @@ public static OpenTelemetryLoggerOptions AddMyExporter(this OpenTelemetryLoggerO
throw new ArgumentNullException(nameof(options));
}

return options.AddProcessor(new BatchExportProcessor<LogRecord>(new MyExporter()));
return options.AddProcessor(new BatchLogRecordExportProcessor(new MyExporter()));
}
}
2 changes: 1 addition & 1 deletion docs/logs/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public static void Main()
builder.AddOpenTelemetry(options => options
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleExportProcessor<LogRecord>(new MyExporter("ExporterX")))
.AddProcessor(new SimpleLogRecordExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter());
});

2 changes: 1 addition & 1 deletion docs/trace/extending-the-sdk/MyExporterHelperExtensions.cs
Original file line number Diff line number Diff line change
@@ -28,6 +28,6 @@ public static TracerProviderBuilder AddMyExporter(this TracerProviderBuilder bui
throw new ArgumentNullException(nameof(builder));
}

return builder.AddProcessor(new BatchExportProcessor<Activity>(new MyExporter()));
return builder.AddProcessor(new BatchActivityExportProcessor(new MyExporter()));
}
}
2 changes: 1 addition & 1 deletion docs/trace/extending-the-sdk/Program.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public static void Main()
.AddSource("OTel.Demo")
.AddProcessor(new MyProcessor("ProcessorA"))
.AddProcessor(new MyProcessor("ProcessorB"))
.AddProcessor(new SimpleExportProcessor<Activity>(new MyExporter("ExporterX")))
.AddProcessor(new SimpleActivityExportProcessor(new MyExporter("ExporterX")))
.AddMyExporter()
.Build();

2 changes: 1 addition & 1 deletion docs/trace/extending-the-sdk/README.md
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ register the exporter, they must be registered manually as shown below:
.SetSampler(new MySampler())
.AddSource("OTel.Demo")
.AddProcessor(new MyFilteringProcessor(
new SimpleExportProcessor<Activity>(new MyExporter("ExporterX")),
new SimpleActivityExportProcessor(new MyExporter("ExporterX")),
(act) => true))
.Build();
```
16 changes: 16 additions & 0 deletions examples/Console/TestJaegerExporter.cs
Original file line number Diff line number Diff line change
@@ -23,6 +23,22 @@ internal class TestJaegerExporter
{
internal static object Run(string host, int port)
{
// Prerequisite for running this example.
// Setup Jaegar inside local docker using following command (Source: https://www.jaegertracing.io/docs/1.21/getting-started/#all-in-one):
/*
$ docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one:1.21
*/

// To run this example, run the following command from
// the reporoot\examples\Console\.
// (eg: C:\repos\opentelemetry-dotnet\examples\Console\)
203 changes: 191 additions & 12 deletions src/OpenTelemetry.Api/Context/Propagation/TraceContextPropagator.cs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using OpenTelemetry.Internal;

@@ -39,6 +40,12 @@ public class TraceContextPropagator : TextMapPropagator
private static readonly int OptionsLength = "00".Length;
private static readonly int TraceparentLengthV0 = "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-00".Length;

// The following length limits are from Trace Context v1 https://www.w3.org/TR/trace-context-1/#key
private static readonly int TraceStateKeyMaxLength = 256;
private static readonly int TraceStateKeyTenantMaxLength = 241;
private static readonly int TraceStateKeyVendorMaxLength = 14;
private static readonly int TraceStateValueMaxLength = 256;

/// <inheritdoc/>
public override ISet<string> Fields => new HashSet<string> { TraceState, TraceParent };

@@ -230,18 +237,79 @@ internal static bool TryExtractTracestate(string[] tracestateCollection, out str

if (tracestateCollection != null)
{
var keySet = new HashSet<string>();
var result = new StringBuilder();

// Iterate in reverse order because when call builder set the elements is added in the
// front of the list.
for (int i = tracestateCollection.Length - 1; i >= 0; i--)
for (int i = 0; i < tracestateCollection.Length; ++i)
{
if (string.IsNullOrEmpty(tracestateCollection[i]))
var tracestate = tracestateCollection[i].AsSpan();
int begin = 0;
while (begin < tracestate.Length)
{
return false;
int length = tracestate.Slice(begin).IndexOf(',');
ReadOnlySpan<char> listMember;
if (length != -1)
{
listMember = tracestate.Slice(begin, length).Trim();
begin += length + 1;
}
else
{
listMember = tracestate.Slice(begin).Trim();
begin = tracestate.Length;
}

// https://github.com/w3c/trace-context/blob/master/spec/20-http_request_header_format.md#tracestate-header-field-values
if (listMember.IsEmpty)
{
// Empty and whitespace - only list members are allowed.
// Vendors MUST accept empty tracestate headers but SHOULD avoid sending them.
continue;
}

if (keySet.Count >= 32)
{
// https://github.com/w3c/trace-context/blob/master/spec/20-http_request_header_format.md#list
// test_tracestate_member_count_limit
return false;
}

int keyLength = listMember.IndexOf('=');
if (keyLength == listMember.Length || keyLength == -1)
{
// Missing key or value in tracestate
return false;
}

var key = listMember.Slice(0, keyLength);
if (!ValidateKey(key))
{
// test_tracestate_key_illegal_characters in https://github.com/w3c/trace-context/blob/master/test/test.py
// test_tracestate_key_length_limit
// test_tracestate_key_illegal_vendor_format
return false;
}

var value = listMember.Slice(keyLength + 1);
if (!ValidateValue(value))
{
// test_tracestate_value_illegal_characters
return false;
}

// ValidateKey() call above has ensured the key does not contain upper case letters.
if (!keySet.Add(key.ToString()))
{
// test_tracestate_duplicated_keys
return false;
}

if (result.Length > 0)
{
result.Append(',');
}

result.Append(listMember.ToString());
}

result.Append(tracestateCollection[i]);
}

tracestateResult = result.ToString();
@@ -252,14 +320,125 @@ internal static bool TryExtractTracestate(string[] tracestateCollection, out str

private static byte HexCharToByte(char c)
{
if (((c >= '0') && (c <= '9'))
|| ((c >= 'a') && (c <= 'f'))
|| ((c >= 'A') && (c <= 'F')))
if ((c >= '0') && (c <= '9'))
{
return (byte)(c - '0');
}

if ((c >= 'a') && (c <= 'f'))
{
return Convert.ToByte(c);
return (byte)(c - 'a' + 10);
}

throw new ArgumentOutOfRangeException(nameof(c), c, $"Invalid character: {c}.");
}

private static bool ValidateKey(ReadOnlySpan<char> key)
{
// This implementation follows Trace Context v1 which has W3C Recommendation.
// https://www.w3.org/TR/trace-context-1/#key
// It will be slightly differently from the next version of specification in GitHub repository.

// There are two format for the key. The length rule applies to both.
if (key.Length <= 0 || key.Length > TraceStateKeyMaxLength)
{
return false;
}

// The first format:
// key = lcalpha 0*255( lcalpha / DIGIT / "_" / "-"/ "*" / "/" )
// lcalpha = % x61 - 7A; a - z
// (There is an inconsistency in the expression above and the description in note.
// Here is following the description in note:
// "Identifiers MUST begin with a lowercase letter or a digit.")
if (!IsLowerAlphaDigit(key[0]))
{
return false;
}

int tenantLength = -1;
for (int i = 1; i < key.Length; ++i)
{
char ch = key[i];
if (ch == '@')
{
tenantLength = i;
break;
}

if (!(IsLowerAlphaDigit(ch)
|| ch == '_'
|| ch == '-'
|| ch == '*'
|| ch == '/'))
{
return false;
}
}

if (tenantLength == -1)
{
// There is no "@" sign. The key follow the first format.
return true;
}

// The second format:
// key = (lcalpha / DIGIT) 0 * 240(lcalpha / DIGIT / "_" / "-" / "*" / "/") "@" lcalpha 0 * 13(lcalpha / DIGIT / "_" / "-" / "*" / "/")
if (tenantLength == 0 || tenantLength > TraceStateKeyTenantMaxLength)
{
return false;
}

int vendorLength = key.Length - tenantLength - 1;
if (vendorLength == 0 || vendorLength > TraceStateKeyVendorMaxLength)
{
return false;
}

for (int i = tenantLength + 1; i < key.Length; ++i)
{
char ch = key[i];
if (!(IsLowerAlphaDigit(ch)
|| ch == '_'
|| ch == '-'
|| ch == '*'
|| ch == '/'))
{
return false;
}
}

return true;
}

private static bool ValidateValue(ReadOnlySpan<char> value)
{
// https://github.com/w3c/trace-context/blob/master/spec/20-http_request_header_format.md#value
// value = 0*255(chr) nblk-chr
// nblk - chr = % x21 - 2B / % x2D - 3C / % x3E - 7E
// chr = % x20 / nblk - chr
if (value.Length <= 0 || value.Length > TraceStateValueMaxLength)
{
return false;
}

for (int i = 0; i < value.Length - 1; ++i)
{
char c = value[i];
if (!(c >= 0x20 && c <= 0x7E && c != 0x2C && c != 0x3D))
{
return false;
}
}

char last = value[value.Length - 1];
return last >= 0x21 && last <= 0x7E && last != 0x2C && last != 0x3D;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsLowerAlphaDigit(char c)
{
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z');
}
}
}
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@
`ConsoleExporter` to get rid of type specific check in the class
([#1593](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1593))

* Replaced Debug.WriteLine with Trace.WriteLine to display the logs to the Debug
window with Release configuration
([#1719](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1719))

## 1.0.0-rc1.1

Released 2020-Nov-17
Loading

0 comments on commit a8a5fb8

Please sign in to comment.