Skip to content

Commit

Permalink
Telemetry attributes for Splunk distro (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Oct 26, 2023
1 parent ce43007 commit 2eb0498
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .cspell/other.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Bson
buildtasks
Configurator
coreutils
distro
dylib
Expector
mktemp
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h

### Changed

- Updated value for following attributes:
- `telemetry.distro.name` to `splunk-otel-dotnet`
- `telemetry.distro.version` to current release version.

### Deprecated

- Deprecate `splunk.otel.version` attribute.

### Removed

### Fixed
Expand Down
1 change: 0 additions & 1 deletion docs/bump-upstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- [`build/Build.cs`](../build/Build.cs)
- [`docs/advanced-config.md`](./advanced-config.md)
- [`src/Splunk.OpenTelemetry.AutoInstrumentation/Splunk.OpenTelemetry.AutoInstrumentation.csproj`](../src/Splunk.OpenTelemetry.AutoInstrumentation/Splunk.OpenTelemetry.AutoInstrumentation.csproj)
- [`test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs`](../test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs)

1. Update the `test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/BuildTests.DistributionStructure_*.verified.txt`
files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ namespace Splunk.OpenTelemetry.AutoInstrumentation;

internal static class ResourceConfigurator
{
/// <summary>
/// splunk.otel.version is deprecated
/// </summary>
private const string SplunkDistroVersionName = "splunk.distro.version";
private const string TelemetryDistroNameName = "telemetry.distro.name";
private const string TelemetryDistroNameValue = "splunk-otel-dotnet";
private const string TelemetryDistroVersionName = "telemetry.distro.version";

private static readonly string Version;

Expand All @@ -45,7 +51,9 @@ public static void Configure(ResourceBuilder resourceBuilder, PluginSettings set
{
var attributes = new List<KeyValuePair<string, object>>
{
new(SplunkDistroVersionName, Version)
new(SplunkDistroVersionName, Version),
new(TelemetryDistroNameName, TelemetryDistroNameValue),
new(TelemetryDistroVersionName, Version)
};

resourceBuilder.AddAttributes(attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public static void ExpectDistributionResources(this OtlpResourceExpector resourc
resourceExpector.Expect("telemetry.sdk.name", "opentelemetry");
resourceExpector.Expect("telemetry.sdk.language", "dotnet");
resourceExpector.Expect("telemetry.sdk.version", ExpectedSdkVersion);
resourceExpector.Expect("telemetry.distro.name", "opentelemetry-dotnet-instrumentation");
resourceExpector.Expect("telemetry.distro.version", "1.1.0");
resourceExpector.Expect("telemetry.distro.name", "splunk-otel-dotnet");
resourceExpector.Expect("telemetry.distro.version", ExpectedDistributionVersion);
resourceExpector.Expect("splunk.distro.version", ExpectedDistributionVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ public void ConfigureSplunkDistributionVersion()
ResourceConfigurator.Configure(resourceBuilder, settings);

var resource = resourceBuilder.Build();

var version = typeof(Plugin).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion.Split('+')[0];
using (new AssertionScope())
{
resource.Attributes.Count().Should().Be(1);

var attribute = resource.Attributes.First();
attribute.Key.Should().Be("splunk.distro.version");
(attribute.Value as string).Should().Be(typeof(Plugin).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion.Split('+')[0]);
resource.Attributes.Should().BeEquivalentTo(new Dictionary<string, object>
{
{ "splunk.distro.version", version },
{ "telemetry.distro.name", "splunk-otel-dotnet" },
{ "telemetry.distro.version", version }
});
}
}
}

0 comments on commit 2eb0498

Please sign in to comment.