-
Notifications
You must be signed in to change notification settings - Fork 1
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 #26 from purview-dev/metrics-naming-issue
fix: fixed invalid prefix modes for instruments
- Loading branch information
Showing
179 changed files
with
9,968 additions
and
133 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
152 changes: 152 additions & 0 deletions
152
...rceGenerator.IntegrationTests/Metrics/TelemetrySourceGeneratorMetricsTests.MeterNaming.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,152 @@ | ||
namespace Purview.Telemetry.SourceGenerator.Metrics; | ||
|
||
partial class TelemetrySourceGeneratorMetricsTests | ||
{ | ||
[Fact] | ||
public async Task Generate_GivenNameWithInterfacePrefix_GeneratesMetricsWithPrefix() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
namespace Testing; | ||
[Meter(""testing-meter"", InstrumentPrefix = ""This.Is.A.Prefix"")] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
|
||
[Fact] | ||
public async Task Generate_GivenNameWithAssemblyPrefix_GeneratesMetricsWithPrefix() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
[assembly: MeterGeneration(InstrumentPrefix = ""This.Is.An.Assembly.Prefix"")] | ||
namespace Testing; | ||
[Meter(""testing-meter"")] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
|
||
[Fact] | ||
public async Task Generate_GivenNameWithAssemblyAndInterfacePrefix_GeneratesMetricsWithPrefix() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
[assembly: MeterGeneration(InstrumentPrefix = ""This.Is.An.Assembly.Prefix"")] | ||
namespace Testing; | ||
[Meter(""testing-meter"", InstrumentPrefix = ""This.Is.A.Prefix"")] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
|
||
[Fact] | ||
public async Task Generate_GivenNameShouldBeLowerCase_GeneratesMetricsWithLowercaseName() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
namespace Testing; | ||
[Meter(""testing-meter"")] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
|
||
[Fact] | ||
public async Task Generate_GivenNameShouldBeDefaultLowerCase_GeneratesMetricsWithLowercaseName() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
namespace Testing; | ||
[Meter(""testing-meter"")] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
|
||
[Fact] | ||
public async Task Generate_GivenNameShouldBeDefinedCase_GeneratesMetricsWithLowercaseName() | ||
{ | ||
// Arrange | ||
var basicMetric = @$" | ||
using Purview.Telemetry.Metrics; | ||
namespace Testing; | ||
[Meter(""testing-meter"", LowercaseInstrumentName = false)] | ||
interface ITestMetrics | ||
{{ | ||
[AutoCounter] | ||
void AutoCounterMetric(); | ||
}} | ||
"; | ||
|
||
// Act | ||
var generationResult = await GenerateAsync(basicMetric); | ||
|
||
// Assert | ||
await TestHelpers.Verify(generationResult); | ||
} | ||
} |
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
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
Oops, something went wrong.