-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from elastic/initial-tests
Add initial tests project
- Loading branch information
Showing
8 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cloudfront | ||
stacktrace | ||
otel | ||
otel | ||
otlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Elastic.OpenTelemetry.Tests; | ||
|
||
public class TransactionIdProcessorTests | ||
{ | ||
[Fact] | ||
public void TransactionId_IsAddedToTags() | ||
{ | ||
const string activitySourceName = "TestSource"; | ||
|
||
var activitySource = new ActivitySource(activitySourceName, "1.0.0"); | ||
|
||
var exportedItems = new List<Activity>(); | ||
|
||
using var agent = new AgentBuilder() | ||
.ConfigureTracer(tpb => tpb | ||
.ConfigureResource(rb => rb.AddService("Test", "1.0.0")) | ||
.AddSource(activitySourceName) | ||
.AddInMemoryExporter(exportedItems)) | ||
.Build(); | ||
|
||
using (var activity = activitySource.StartActivity("DoingStuff", ActivityKind.Internal)) | ||
{ | ||
activity?.SetStatus(ActivityStatusCode.Ok); | ||
} | ||
|
||
exportedItems.Should().HaveCount(1); | ||
|
||
var exportedActivity = exportedItems[0]; | ||
|
||
var transactionId = exportedActivity.GetTagItem(TransactionIdProcessor.TransactionIdTagName); | ||
|
||
transactionId.Should().NotBeNull().And.BeAssignableTo<string>().Which.Should().NotBeEmpty(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/Elastic.OpenTelemetry.Tests/Elastic.OpenTelemetry.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
<RunSettingsFilePath>$(MSBuildProjectDirectory)\test.runsettings</RunSettingsFilePath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.6.4" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="OpenTelemetry.Exporter.InMemory" Version="1.7.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Elastic.OpenTelemetry\Elastic.OpenTelemetry.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global using Xunit; | ||
global using System.Diagnostics; | ||
global using Elastic.OpenTelemetry.Processors; | ||
global using FluentAssertions; | ||
global using OpenTelemetry.Resources; | ||
global using OpenTelemetry.Trace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<RunSettings> | ||
<RunConfiguration> | ||
<EnvironmentVariables> | ||
<OTEL_EXPORTER_OTLP_ENDPOINT>http://localhost:4318</OTEL_EXPORTER_OTLP_ENDPOINT> | ||
<OTEL_EXPORTER_OTLP_TRACES_PROTOCOL>http/protobuf</OTEL_EXPORTER_OTLP_TRACES_PROTOCOL> | ||
<OTEL_BSP_SCHEDULE_DELAY>10</OTEL_BSP_SCHEDULE_DELAY> | ||
</EnvironmentVariables> | ||
</RunConfiguration> | ||
</RunSettings> |