# Interface IExternalTraceProvider (4.4.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.4.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.IExternalTraceProvider)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.IExternalTraceProvider)

    [Obsolete("Inject a Google.Cloud.Diagnostics.Common.ITraceContext instead.")]
    public interface IExternalTraceProvider

Provides external trace information to include in a log entry
if there's no Google Trace available.
Implement this interface when traces are being generated by your environment
and sent to Google Cloud Tracing not via the Google.Cloud.Diagnostics library.

## Namespace

[Google.Cloud.Diagnostics.AspNetCore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)

## Assembly

Google.Cloud.Diagnostics.AspNetCore.dll

## Methods

### GetCurrentTraceContext(IServiceProvider)

    TraceContextForLogEntry GetCurrentTraceContext(IServiceProvider serviceProvider)

Returns the [TraceContextForLogEntry](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.TraceContextForLogEntry) that can be associated to a log entry or
null if there's currently no trace context.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `serviceProvider` | `https://learn.microsoft.com/dotnet/api/system.iserviceprovider` The service provider to resolve services from. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.TraceContextForLogEntry` | A [TraceContextForLogEntry](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.TraceContextForLogEntry) or null if there's no current trace. |