# Google.Cloud.Diagnostics.Common - Class ManagedTracer (5.3.0)

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

- [5.3.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ManagedTracer)
- [5.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.2.0/Google.Cloud.Diagnostics.Common.ManagedTracer)
- [5.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.1.0/Google.Cloud.Diagnostics.Common.ManagedTracer)
- [5.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.0.0/Google.Cloud.Diagnostics.Common.ManagedTracer)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.4.0/Google.Cloud.Diagnostics.Common.ManagedTracer)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.3.1/Google.Cloud.Diagnostics.Common.ManagedTracer)

    public static class ManagedTracer

Reference documentation and code samples for the Google.Cloud.Diagnostics.Common class ManagedTracer.

Functions to create [IManagedTracer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer)s.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ManagedTracer

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

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

## Assembly

Google.Cloud.Diagnostics.Common.dll

## Methods

### CreateConsumer(TraceServiceClient, TraceOptions)

    public static IConsumer<Trace> CreateConsumer(TraceServiceClient client, TraceOptions options)

Creates a trace consumer for a [TraceServiceClient](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceServiceClient.html) and options.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `client` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.TraceServiceClient.html` The trace client. Must not be null. |
| `options` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.TraceOptions` Trace options. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IConsumer-1https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.Trace.html` |   |

### CreateDelegatingTracer(Func\<IManagedTracer\>)

    public static IManagedTracer CreateDelegatingTracer(Func<IManagedTracer> tracerFactory)

Creates an [IManagedTracer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer) that delegates all calls to another [IManagedTracer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer)
that is retrieved from the given function on each method call.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tracerFactory` | `https://learn.microsoft.com/dotnet/api/system.func-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer` |   |

### CreateFactory(string, IConsumer\<Trace\>, TraceOptions)

    public static Func<ITraceContext, IManagedTracer> CreateFactory(string projectId, IConsumer<Trace> consumer, TraceOptions options)

Create a factory to generate an [IManagedTracer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer) from an [ITraceContext](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ITraceContext).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `projectId` | `https://learn.microsoft.com/dotnet/api/system.string` The Google Cloud Platform project ID. Must not be null |
| `consumer` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IConsumer-1https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V1/latest/Google.Cloud.Trace.V1.Trace.html` The trace consumer. Must not be null. |
| `options` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.TraceOptions` Trace options. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.func-2https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ITraceContexthttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.IManagedTracer` |   |