Refactor docs/demo (#1211)
* refactor docs/demo * normalize EOL * add blank line before EOF * fix hyperlinks
This commit is contained in:
parent
7e80321fe6
commit
3c4ed50bb9
|
|
@ -154,11 +154,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{2C
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "trace", "trace", "{5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docs\trace\building-your-own-instrumentation-library.md = docs\trace\building-your-own-instrumentation-library.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "building-your-own-processor", "docs\trace\building-your-own-processor\building-your-own-processor.csproj", "{B1891B31-B021-4074-8E42-B4AC170CD208}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started", "docs\trace\getting-started\getting-started.csproj", "{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}"
|
||||
EndProject
|
||||
|
|
@ -195,9 +190,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{CB401DF1-F
|
|||
docs\toc.yml = docs\toc.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "building-your-own-exporter", "docs\trace\building-your-own-exporter\building-your-own-exporter.csproj", "{9574368D-1230-4334-AA5D-EC2C2F47AA43}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "building-your-own-sampler", "docs\trace\building-your-own-sampler\building-your-own-sampler.csproj", "{D6318071-BE9F-43AF-9F28-A38894238627}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\trace\extending-the-sdk\extending-the-sdk.csproj", "{FCDCF532-A163-40DA-80B7-7530AA1182C4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -349,10 +342,6 @@ Global
|
|||
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0246BFC4-8AAF-45E1-A127-DB43D6E345BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B1891B31-B021-4074-8E42-B4AC170CD208}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B1891B31-B021-4074-8E42-B4AC170CD208}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -369,14 +358,10 @@ Global
|
|||
{5435517C-AEC5-4182-87AE-14E13D31525F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5435517C-AEC5-4182-87AE-14E13D31525F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5435517C-AEC5-4182-87AE-14E13D31525F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9574368D-1230-4334-AA5D-EC2C2F47AA43}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6318071-BE9F-43AF-9F28-A38894238627}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6318071-BE9F-43AF-9F28-A38894238627}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6318071-BE9F-43AF-9F28-A38894238627}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D6318071-BE9F-43AF-9F28-A38894238627}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FCDCF532-A163-40DA-80B7-7530AA1182C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FCDCF532-A163-40DA-80B7-7530AA1182C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FCDCF532-A163-40DA-80B7-7530AA1182C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FCDCF532-A163-40DA-80B7-7530AA1182C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -394,7 +379,6 @@ Global
|
|||
{DE9130A4-F30A-49D7-8834-41DE3021218B} = {0169B149-FB8B-46F4-9EF7-8A0E69F8FAAF}
|
||||
{2C7DD1DA-C229-4D9E-9AF0-BCD5CD3E4948} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
|
||||
{5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
|
||||
{B1891B31-B021-4074-8E42-B4AC170CD208} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
|
||||
{BE60E3D5-DE30-4BAB-8E7A-63B21D0E80D7} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
|
||||
{3277B1C0-BDFE-4460-9B0D-D9A661FB48DB} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
|
||||
{3862190B-E2C5-418E-AFDC-DB281FB5C705} = {7C87CAF9-79D7-4C26-9FFB-F3F1FB6911F1}
|
||||
|
|
@ -403,8 +387,7 @@ Global
|
|||
{FA7A6F67-1F2F-4855-890D-51B5829578A9} = {4D492D62-5150-45F9-817F-C99562E364E2}
|
||||
{5435517C-AEC5-4182-87AE-14E13D31525F} = {4D492D62-5150-45F9-817F-C99562E364E2}
|
||||
{CB401DF1-FF5C-4055-886E-1183E832B2D6} = {7CB2F02E-03FA-4FFF-89A5-C51F107623FD}
|
||||
{9574368D-1230-4334-AA5D-EC2C2F47AA43} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
|
||||
{D6318071-BE9F-43AF-9F28-A38894238627} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
|
||||
{FCDCF532-A163-40DA-80B7-7530AA1182C4} = {5B7FB835-3FFF-4BC2-99C5-A5B5FAE3C818}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {55639B5C-0770-4A22-AB56-859604650521}
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
// <copyright file="Program.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry;
|
||||
|
||||
public class Program
|
||||
{
|
||||
private static readonly ActivitySource MyActivitySource = new ActivitySource(
|
||||
"MyCompany.MyProduct.MyLibrary");
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddSource("MyCompany.MyProduct.MyLibrary")
|
||||
.AddMyExporter()
|
||||
.Build();
|
||||
|
||||
using (var activity = MyActivitySource.StartActivity("SayHello"))
|
||||
{
|
||||
activity?.SetTag("foo", 1);
|
||||
activity?.SetTag("bar", "Hello, World!");
|
||||
activity?.SetTag("baz", new int[] { 1, 2, 3 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
# Building your own Exporter
|
||||
|
||||
Custom exporters can be implemented to send telemetry data to places which are
|
||||
not covered by the built-in exporters.
|
||||
|
||||
Here is the guidance for writing a custom exporter:
|
||||
|
||||
* Exporters should derive from `ActivityExporter` (which belongs to the
|
||||
[OpenTelemetry](https://www.nuget.org/packages/opentelemetry) package) and
|
||||
implement `Export` method.
|
||||
* Exporters can optionally implement `OnShutdown`.
|
||||
* Depending on user's choice and load on the application, `Export` may get
|
||||
called with one or more activities.
|
||||
* Exporters will only receive sampled-in and ended activities.
|
||||
* Exporters should not throw exceptions.
|
||||
* Exporters should not modify activities they receive (the same activity may be
|
||||
exported again by different exporter).
|
||||
* Exporters are responsible for any retry logic needed by the scenario. The SDK
|
||||
does not implement any retry logic.
|
||||
|
||||
## Example
|
||||
|
||||
A demo exporter which simply writes activity name to the console is shown
|
||||
[here](./MyExporter.cs).
|
||||
|
||||
Apart from the exporter itself, you should also provide extension methods as
|
||||
shown [here](./MyExporterHelperExtensions.cs). This allows users to add the
|
||||
Exporter to the `TracerProvider` as shown in the sample code
|
||||
[here](./Program.cs).
|
||||
|
||||
To run the full example code demonstrating the exporter, run the following
|
||||
command from this folder.
|
||||
|
||||
```sh
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
* [Exporter specification](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#span-exporter)
|
||||
* Exporters provided by this repository.
|
||||
* [Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
|
||||
* [Jaeger](../../../src/OpenTelemetry.Exporter.Jaeger/README.md)
|
||||
* [OpenTelemetryProtocol](../../../src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md)
|
||||
* [Zipkin](../../../src/OpenTelemetry.Exporter.Zipkin/README.md)
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Building your own Instrumentation Library
|
||||
|
||||
Under construction.
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// <copyright file="Program.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The 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.
|
||||
// </copyright>
|
||||
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry;
|
||||
|
||||
public class Program
|
||||
{
|
||||
private static readonly ActivitySource MyActivitySource = new ActivitySource(
|
||||
"MyCompany.MyProduct.MyLibrary");
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddSource("MyCompany.MyProduct.MyLibrary")
|
||||
.AddProcessor(new MyActivityProcessor("A"))
|
||||
.AddProcessor(new MyActivityProcessor("B"))
|
||||
.Build();
|
||||
|
||||
using (var activity = MyActivitySource.StartActivity("Foo"))
|
||||
{
|
||||
activity?.SetTag("foo", 1);
|
||||
activity?.SetTag("bar", "Hello, World!");
|
||||
activity?.SetTag("baz", new int[] { 1, 2, 3 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Building your own Processor
|
||||
|
||||
Under construction.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<!--
|
||||
<PackageReference Include="OpenTelemetry" Version="$(OpenTelemetryPkgVer)" />
|
||||
-->
|
||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# Building your own Sampler
|
||||
|
||||
* Samplers should inherit from `Sampler`, and implement `ShouldSample`
|
||||
method.
|
||||
* `ShouldSample` should not block or take long time, since it will be called on
|
||||
critical code path.
|
||||
|
||||
```csharp
|
||||
internal class MySampler : Sampler
|
||||
{
|
||||
public override SamplingResult ShouldSample(in SamplingParameters samplingParameters)
|
||||
{
|
||||
return new SamplingResult(SamplingDecision.RecordAndSampled);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<!---
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="$(OpenTelemetryExporterConsolePkgVer)" />
|
||||
-->
|
||||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -16,29 +16,47 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
internal class MyExporter : ActivityExporter
|
||||
{
|
||||
private readonly string name;
|
||||
|
||||
public MyExporter(string name = "MyExporter")
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public override ExportResult Export(in Batch<Activity> batch)
|
||||
{
|
||||
// Exporter code which can generate further
|
||||
// telemetry should do so inside SuppressInstrumentation
|
||||
// scope. This suppresses telemetry from
|
||||
// exporter's own code to avoid live-loop situation.
|
||||
// SuppressInstrumentationScope should be used to prevent exporter
|
||||
// code from generating telemetry and causing live-loop.
|
||||
using var scope = SuppressInstrumentationScope.Begin();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach (var activity in batch)
|
||||
{
|
||||
Console.WriteLine($"{activity.DisplayName}");
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
|
||||
sb.Append(activity.DisplayName);
|
||||
}
|
||||
|
||||
Console.WriteLine($"{this.name}.Export([{sb.ToString()}])");
|
||||
return ExportResult.Success;
|
||||
}
|
||||
|
||||
protected override void OnShutdown(int timeoutMilliseconds)
|
||||
{
|
||||
Console.WriteLine($"MyExporter.OnShutdown(timeoutMilliseconds={timeoutMilliseconds})");
|
||||
Console.WriteLine($"{this.name}.OnShutdown(timeoutMilliseconds={timeoutMilliseconds})");
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
Console.WriteLine($"{this.name}.Dispose({disposing})");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// <copyright file="MyActivityProcessor.cs" company="OpenTelemetry Authors">
|
||||
// <copyright file="MyProcessor.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
@ -16,35 +16,41 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
internal class MyActivityProcessor : ActivityProcessor
|
||||
internal class MyProcessor : ActivityProcessor
|
||||
{
|
||||
private readonly string name;
|
||||
|
||||
public MyActivityProcessor(string name)
|
||||
public MyProcessor(string name = "MyProcessor")
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
public override void OnStart(Activity activity)
|
||||
{
|
||||
return $"{this.GetType()}({this.name})";
|
||||
Console.WriteLine($"{this.name}.OnStart({activity.DisplayName})");
|
||||
}
|
||||
|
||||
public override void OnEnd(Activity activity)
|
||||
{
|
||||
Console.WriteLine($"{this}.OnEnd");
|
||||
Console.WriteLine($"{this.name}.OnEnd({activity.DisplayName})");
|
||||
}
|
||||
|
||||
protected override bool OnForceFlush(int timeoutMilliseconds)
|
||||
{
|
||||
Console.WriteLine($"{this}.OnForceFlush");
|
||||
Console.WriteLine($"{this.name}.OnForceFlush({timeoutMilliseconds})");
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnShutdown(int timeoutMilliseconds)
|
||||
{
|
||||
Console.WriteLine($"{this}.OnShutdown");
|
||||
Console.WriteLine($"{this.name}.OnShutdown({timeoutMilliseconds})");
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
Console.WriteLine($"{this.name}.Dispose({disposing})");
|
||||
}
|
||||
}
|
||||
|
|
@ -14,12 +14,16 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Trace;
|
||||
|
||||
internal class MySampler : Sampler
|
||||
{
|
||||
public override SamplingResult ShouldSample(in SamplingParameters samplingParameters)
|
||||
public override SamplingResult ShouldSample(in SamplingParameters param)
|
||||
{
|
||||
Console.WriteLine($"MySampler.ShouldSample({param.Name})");
|
||||
return new SamplingResult(SamplingDecision.RecordAndSampled);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,22 +20,27 @@ using OpenTelemetry.Trace;
|
|||
|
||||
public class Program
|
||||
{
|
||||
private static readonly ActivitySource MyActivitySource = new ActivitySource(
|
||||
"MyCompany.MyProduct.MyLibrary");
|
||||
private static readonly ActivitySource DemoSource = new ActivitySource("OTel.Demo");
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
||||
.AddSource("MyCompany.MyProduct.MyLibrary")
|
||||
.SetSampler(new MySampler())
|
||||
.AddConsoleExporter()
|
||||
.AddSource("OTel.Demo")
|
||||
.AddProcessor(new MyProcessor("ProcessorA"))
|
||||
.AddProcessor(new MyProcessor("ProcessorB"))
|
||||
.AddProcessor(new SimpleExportActivityProcessor(new MyExporter("ExporterX")))
|
||||
.AddMyExporter()
|
||||
.Build();
|
||||
|
||||
using (var activity = MyActivitySource.StartActivity("SayHello"))
|
||||
using (var foo = DemoSource.StartActivity("Foo"))
|
||||
{
|
||||
activity?.SetTag("foo", 1);
|
||||
activity?.SetTag("bar", "Hello, World!");
|
||||
activity?.SetTag("baz", new int[] { 1, 2, 3 });
|
||||
using (var bar = DemoSource.StartActivity("Bar"))
|
||||
{
|
||||
using (var baz = DemoSource.StartActivity("Baz"))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
# Extending the OpenTelemetry .NET SDK
|
||||
|
||||
* [Building your own exporter](#exporter)
|
||||
* [Building your own instrumentation library](#instrumentation-library)
|
||||
* [Building your own processor](#processor)
|
||||
* [Building your own sampler](#sampler)
|
||||
* [References](#references)
|
||||
|
||||
## Exporter
|
||||
|
||||
OpenTelemetry .NET SDK has provided the following built-in exporters:
|
||||
|
||||
* [Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
|
||||
* [Jaeger](../../../src/OpenTelemetry.Exporter.Jaeger/README.md)
|
||||
* [OpenTelemetryProtocol](../../../src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md)
|
||||
* [Zipkin](../../../src/OpenTelemetry.Exporter.Zipkin/README.md)
|
||||
|
||||
Custom exporters can be implemented to send telemetry data to places which are
|
||||
not covered by the built-in exporters.
|
||||
|
||||
Here is the guidance for writing a custom exporter:
|
||||
|
||||
* Exporters should derive from `ActivityExporter` (which belongs to the
|
||||
[OpenTelemetry](https://www.nuget.org/packages/opentelemetry) package) and
|
||||
implement `Export` method.
|
||||
* Exporters can optionally implement `OnShutdown`.
|
||||
* Depending on user's choice and load on the application, `Export` may get
|
||||
called with one or more activities.
|
||||
* Exporters will only receive sampled-in and ended activities.
|
||||
* Exporters should not throw exceptions.
|
||||
* Exporters should not modify activities they receive (the same activity may be
|
||||
exported again by different exporter).
|
||||
* Exporters are responsible for any retry logic needed by the scenario. The SDK
|
||||
does not implement any retry logic.
|
||||
|
||||
A demo exporter which simply writes activity name to the console is shown
|
||||
[here](./MyExporter.cs).
|
||||
|
||||
Apart from the exporter itself, you should also provide extension methods as
|
||||
shown [here](./MyExporterHelperExtensions.cs). This allows users to add the
|
||||
Exporter to the `TracerProvider` as shown in the sample code
|
||||
[here](./Program.cs).
|
||||
|
||||
To run the full example code demonstrating the exporter, run the following
|
||||
command from this folder.
|
||||
|
||||
```sh
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Instrumentation Library
|
||||
|
||||
TBD
|
||||
|
||||
## Processor
|
||||
|
||||
OpenTelemetry .NET SDK has provided the following built-in processors:
|
||||
|
||||
* [BatchExportActivityProcessor](../../../src/OpenTelemetry/Trace/BatchExportActivityProcessor.cs)
|
||||
* [CompositeActivityProcessor](../../../src/OpenTelemetry/Trace/CompositeActivityProcessor.cs)
|
||||
* [ReentrantExportActivityProcessor](../../../src/OpenTelemetry/Trace/ReentrantExportActivityProcessor.cs)
|
||||
* [SimpleExportActivityProcessor](../../../src/OpenTelemetry/Trace/SimpleExportActivityProcessor.cs)
|
||||
|
||||
## Sampler
|
||||
|
||||
OpenTelemetry .NET SDK has provided the following built-in samplers:
|
||||
|
||||
* [AlwaysOffSampler](../../../src/OpenTelemetry/Trace/AlwaysOffSampler.cs)
|
||||
* [AlwaysOnSampler](../../../src/OpenTelemetry/Trace/AlwaysOnSampler.cs)
|
||||
* [ParentBasedSampler](../../../src/OpenTelemetry/Trace/ParentBasedSampler.cs)
|
||||
* [TraceIdRatioBasedSampler](../../../src/OpenTelemetry/Trace/TraceIdRatioBasedSampler.cs)
|
||||
|
||||
Custom samplers can be implemented to cover more scenarios:
|
||||
|
||||
* Samplers should inherit from `Sampler`, and implement `ShouldSample` method.
|
||||
* `ShouldSample` should not block or take long time, since it will be called on
|
||||
critical code path.
|
||||
|
||||
```csharp
|
||||
internal class MySampler : Sampler
|
||||
{
|
||||
public override SamplingResult ShouldSample(in SamplingParameters samplingParameters)
|
||||
{
|
||||
return new SamplingResult(SamplingDecision.RecordAndSampled);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
* [Exporter
|
||||
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#span-exporter)
|
||||
|
|
@ -79,10 +79,11 @@ using var otel = Sdk.CreateTracerProvider(b => b
|
|||
* Metrics
|
||||
* [Building your own Exporter](../../docs/metrics/building-your-own-exporter.md)
|
||||
* Trace
|
||||
* [Building your own Exporter](../../docs/trace/building-your-own-exporter/README.md)
|
||||
* [Building your own Exporter](../../docs/trace/extending-the-sdk/README.md#exporter)
|
||||
* [Building your own Instrumentation
|
||||
Library](../../docs/trace/building-your-own-instrumentation-library.md)
|
||||
* [Building your own Sampler](../../docs/trace/building-your-own-sampler/README.md)
|
||||
Library](../../docs/trace/extending-the-sdk/README.md#instrumentation-library)
|
||||
* [Building your own Processor](../../docs/trace/extending-the-sdk/README.md#processor)
|
||||
* [Building your own Sampler](../../docs/trace/extending-the-sdk/README.md#sampler)
|
||||
|
||||
## References
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue