Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AzureMonitor] refactor event id in demo and tests #44797

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private static async Task GenerateTelemetry()

_logger?.Log(
logLevel: LogLevel.Information,
eventId: 0,
eventId: 1,
exception: null,
message: "Hello {name}.",
args: new object[] { "World" });
Expand All @@ -162,7 +162,7 @@ private static async Task GenerateTelemetry()
{
_logger?.Log(
logLevel: LogLevel.Error,
eventId: 0,
eventId: 2,
exception: ex,
message: "Hello {name}.",
args: new object[] { "World" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public static void AssertLog_As_ExceptionTelemetry(
string expectedSeverityLevel,
string expectedMessage,
string expectedTypeName,
IDictionary<string, string> expectedProperties,
string expectedCloudRole = "[testNamespace]/testName",
string expectedCloudInstance = "testInstance",
string expectedApplicationVersion = "testVersion")
Expand All @@ -93,6 +94,11 @@ public static void AssertLog_As_ExceptionTelemetry(
Assert.Equal(expectedTypeName, telemetryExceptionDetails.TypeName);
Assert.True(telemetryExceptionDetails.ParsedStack.Any());
Assert.Null(telemetryExceptionDetails.Stack);

foreach (var prop in expectedProperties)
{
Assert.Equal(prop.Value, telemetryExceptionData.Properties[prop.Key]);
}
}

public static void AssertActivity_As_DependencyTelemetry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void VerifyLog(LogLevel logLevel, string expectedSeverityLevel)
var logger = loggerFactory.CreateLogger(logCategoryName);
logger.Log(
logLevel: logLevel,
eventId: 0,
eventId: 1,
exception: null,
message: "Hello {name}.",
args: new object[] { "World" });
Expand All @@ -83,7 +83,7 @@ public void VerifyLog(LogLevel logLevel, string expectedSeverityLevel)
telemetryItem: telemetryItem!,
expectedSeverityLevel: expectedSeverityLevel,
expectedMessage: "Hello {name}.",
expectedMessageProperties: new Dictionary<string, string> { { "name", "World" }},
expectedMessageProperties: new Dictionary<string, string> { { "EventId", "1" }, { "name", "World" }},
expectedSpanId: null,
expectedTraceId: null);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public void VerifyException(LogLevel logLevel, string expectedSeverityLevel)
{
logger.Log(
logLevel: logLevel,
eventId: 0,
eventId: 1,
exception: ex,
message: "Hello {name}.",
args: new object[] { "World" });
Expand All @@ -144,7 +144,8 @@ public void VerifyException(LogLevel logLevel, string expectedSeverityLevel)
telemetryItem: telemetryItem!,
expectedSeverityLevel: expectedSeverityLevel,
expectedMessage: "Test Exception",
expectedTypeName: "System.Exception");
expectedTypeName: "System.Exception",
expectedProperties: new Dictionary<string, string> { { "EventId", "1" } });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void VerifyLogWithinActivity(LogLevel logLevel, string expectedSeverityLe

logger.Log(
logLevel: logLevel,
eventId: 0,
eventId: 1,
exception: null,
message: "Hello {name}.",
args: new object[] { "World" });
Expand Down Expand Up @@ -295,7 +295,7 @@ public void VerifyLogWithinActivity(LogLevel logLevel, string expectedSeverityLe
telemetryItem: logTelemetryItem!,
expectedSeverityLevel: expectedSeverityLevel,
expectedMessage: "Hello {name}.",
expectedMessageProperties: new Dictionary<string, string> { { "name", "World" } },
expectedMessageProperties: new Dictionary<string, string> { {"EventId", "1" }, { "name", "World" } },
expectedSpanId: spanId,
expectedTraceId: traceId);
}
Expand Down
Loading