Skip to content

Commit

Permalink
Docs - provide section on tracking dependency failures in preview & p…
Browse files Browse the repository at this point in the history
…ublished docs (#129)

* Docs - provide section on tracking dependency failures in preview & published docs

* pr-sug: update with 'https' dependency url

* pr-sug: use 'dependencyName' in docs

* Update docs/features/writing-different-telemetry-types.md

Co-authored-by: Tom Kerkhove <[email protected]>

* Update docs/preview/features/writing-different-telemetry-types.md

Co-authored-by: Tom Kerkhove <[email protected]>

Co-authored-by: Tom Kerkhove <[email protected]>
  • Loading branch information
stijnmoreels and tomkerkhove authored Jun 30, 2020
1 parent 4a4c2eb commit dd80577
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
28 changes: 24 additions & 4 deletions docs/features/writing-different-telemetry-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ durationMeasurement.Start();
/// Track dependency
string dependencyName = "SendGrid";
object dependencyData = "http://my.sendgrid.uri/"
_logger.LogDependency("SendGrid", dependencyData, isSuccessful: true, startTime: startTime, duration: durationMeasurement.Elapsed, context: telemetryContext);
object dependencyData = "https://my.sendgrid.uri/"
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: true, startTime: startTime, duration: durationMeasurement.Elapsed, context: telemetryContext);
```

However, by using `DependencyMeasurement.Start()` we take care of the measuring aspect:
Expand All @@ -257,8 +257,28 @@ using (var measurement = DependencyMeasurement.Start())
// Track dependency
string dependencyName = "SendGrid";
object dependencyData = "http://my.sendgrid.uri/"
_logger.LogDependency("SendGrid", dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
object dependencyData = "https://my.sendgrid.uri/"
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
}
```

Failures during the interaction with the tracked dependency can be controlled by passing `isSuccessful`:

```csharp
string dependencyName = "SendGrid";
object dependencyData = "https://my.sendgrid.uri";

try
{
// Interact with SendGrid...
// Done!
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
}
catch (Exception exception)
{
_logger.LogError(exception, "Failed to interact with SendGrid");
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: false, startTime: measurement, context: telemetryContext);
}
```

Expand Down
26 changes: 23 additions & 3 deletions docs/preview/features/writing-different-telemetry-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ durationMeasurement.Start();
/// Track dependency
string dependencyName = "SendGrid";
object dependencyData = "http://my.sendgrid.uri/"
object dependencyData = "https://my.sendgrid.uri/";
_logger.LogDependency("SendGrid", dependencyData, isSuccessful: true, startTime: startTime, duration: durationMeasurement.Elapsed, context: telemetryContext);
```

Expand All @@ -257,8 +257,28 @@ using (var measurement = DependencyMeasurement.Start())
// Track dependency
string dependencyName = "SendGrid";
object dependencyData = "http://my.sendgrid.uri/"
_logger.LogDependency("SendGrid", dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
object dependencyData = "https://my.sendgrid.uri/";
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
}
```

Failures during the interaction with the tracked dependency can be controlled by passing `isSuccessful`:

```csharp
string dependencyName = "SendGrid";
object dependencyData = "https://my.sendgrid.uri";

try
{
// Interact with SendGrid...
// Done!
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: true, startTime: measurement, context: telemetryContext);
}
catch (Exception exception)
{
_logger.LogError(exception, "Failed to interact with SendGrid");
_logger.LogDependency(dependencyName, dependencyData, isSuccessful: false, startTime: measurement, context: telemetryContext);
}
```

Expand Down

0 comments on commit dd80577

Please sign in to comment.