-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove workaround for stable service.instance.id across signals (#108)
- Loading branch information
1 parent
f48c449
commit f25b01f
Showing
5 changed files
with
63 additions
and
19 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
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
53 changes: 53 additions & 0 deletions
53
tests/Grafana.OpenTelemetry.Tests/ResourceBuilderExtensionTest.cs
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,53 @@ | ||
// | ||
// Copyright Grafana Labs | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
using System.Linq; | ||
using OpenTelemetry.Resources; | ||
using Xunit; | ||
|
||
namespace Grafana.OpenTelemetry.Tests | ||
{ | ||
public class ResourceBuilderExtensionTest | ||
{ | ||
[Fact] | ||
public void StableServiceInstanceId() | ||
{ | ||
var resource1 = ResourceBuilder | ||
.CreateEmpty() | ||
.AddGrafanaResource(new GrafanaOpenTelemetrySettings()) | ||
.Build() | ||
.Attributes | ||
.ToDictionary(x => x.Key, x => x.Value); | ||
var resource2 = ResourceBuilder | ||
.CreateEmpty() | ||
.AddGrafanaResource(new GrafanaOpenTelemetrySettings()) | ||
.Build() | ||
.Attributes | ||
.ToDictionary(x => x.Key, x => x.Value); | ||
|
||
Assert.NotNull(resource1["service.instance.id"]); | ||
Assert.NotNull(resource2["service.instance.id"]); | ||
Assert.Equal(resource1["service.instance.id"], resource2["service.instance.id"]); | ||
} | ||
|
||
[Fact] | ||
public void OverrideServiceInstanceId() | ||
{ | ||
var settings = new GrafanaOpenTelemetrySettings | ||
{ | ||
ServiceInstanceId = "test-id" | ||
}; | ||
var resource1 = ResourceBuilder | ||
.CreateEmpty() | ||
.AddGrafanaResource(settings) | ||
.Build() | ||
.Attributes | ||
.ToDictionary(x => x.Key, x => x.Value); | ||
|
||
Assert.NotNull(resource1["service.instance.id"]); | ||
Assert.Equal(resource1["service.instance.id"], "test-id"); | ||
} | ||
} | ||
} |