5.3.0 (latest) 5.2.0 5.1.0 5.0.0 4.4.0 4.3.1

    public static class ServiceContextUtils

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

Helpers for working with a ServiceContext Struct.

## Inheritance

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

## 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.md.txt)

## Assembly

Google.Cloud.Diagnostics.Common.dll

## Fields

### ServiceContextServiceKey

    public const string ServiceContextServiceKey = "service"

The name of the service name field in a ServiceContext [Struct](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Struct.md.txt).

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### ServiceContextVersionKey

    public const string ServiceContextVersionKey = "version"

The name of the version field in a ServiceContext [Struct](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Struct.md.txt).

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

## Methods

### CreateServiceContext(string, string)

    public static Struct CreateServiceContext(string serviceName, string version)

Creates a ServiceContext [Struct](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Struct.md.txt) from a given service name and version.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `string` The service name. |
| `version` | `string` The service version. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Struct` | A ServiceContext [Struct](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Struct.md.txt). |

**Remarks** See <https://cloud.google.com/error-reporting/reference/rest/v1beta1/ServiceContext>