EnvoyContext is where all information related to the current envoy environment.

### Hierarchy

- EnvoyContext

## Index

### Constructors

- constructor

### Properties

- clientTraceId
- directMode
- envoyEgressAddr
- envoyEgressPort
- envoyManagedHosts
- expectedRequestTimeout
- flags
- otSpanContext
- parentSpanId
- requestId
- sampled
- spanId
- traceId

### Methods

- assembleTracingHeader
- shouldCallWithoutEnvoy

## Constructors

### constructor

- new EnvoyContext(options: Metadata | HttpHeader | EnvoyContextInit): EnvoyContext

- - Defined in envoy-context.ts:321

  initialize an EnvoyContext

  #### Parameters

  - ##### options: Metadata | HttpHeader | EnvoyContextInit

    options for init envoy context

  #### Returns EnvoyContext

## Properties

### Optional clientTraceId

clientTraceId: undefined | string

- Defined in envoy-context.ts:287

If an external client sets this header, Envoy will join the provided trace ID with the internally generated x-request-id.

### Private directMode

directMode: boolean

- Defined in envoy-context.ts:302

For dev or test environment, we usually don't have Envoy running. By setting directMode = true will make all the traffic being sent directly. If you set directMode to true, envoyManagedHosts will be ignored and set to an empty set.

### envoyEgressAddr

envoyEgressAddr: string

- Defined in envoy-context.ts:206

the bind address of envoy egress

### envoyEgressPort

envoyEgressPort: number

- Defined in envoy-context.ts:212

The port local Envoy listening on for egress traffic. (So all the egress will be sent to that port)

### Private Optional envoyManagedHosts

envoyManagedHosts: Set<string>

- Defined in envoy-context.ts:321

For easier migrate service to envoy step by step, we can route traffic to envoy for those service migrated. Fill this set for the migrated service. This field is default to `undefined` which means all traffic will be route to envoy. If this field is set to `undefined`, this library will also try to read it from `x-tubi-envoy-managed-host`. You can set in envoy config, like this:

    request_headers_to_add:
    - key: x-tubi-envoy-managed-host
      value: hostname:12345
    - key: x-tubi-envoy-managed-host
      value: foo.bar:8080

If you set this to be an empty set, then no traffic will be route to envoy.

### Optional expectedRequestTimeout

expectedRequestTimeout: undefined | number

- Defined in envoy-context.ts:295

This is the time in milliseconds the router expects the request to be completed. Envoy sets this header so that the upstream host receiving the request can make decisions based on the request timeout, e.g., early exit. This is set on internal requests and is either taken from the x-envoy-upstream-rq-timeout-ms header or the route timeout, in that order.

### Optional flags

flags: undefined | string

- Defined in envoy-context.ts:253

The x-b3-flags HTTP header is used by the Zipkin tracer in Envoy. The encode one or more options. For example, Debug is encoded as X-B3-Flags: 1. See more on zipkin tracing here https://github.com/openzipkin/b3-propagation.

### Optional otSpanContext

otSpanContext: undefined | string

- Defined in envoy-context.ts:264

The x-ot-span-context HTTP header is used by Envoy to establish proper parent-child relationships between tracing spans. This header can be used with both LightStep and Zipkin tracers. For example, an egress span is a child of an ingress span (if the ingress span was present). Envoy injects the x-ot-span-context header on ingress requests and forwards it to the local service. Envoy relies on the application to propagate x-ot-span-context on the egress call to an upstream. See more on tracing here https://www.envoyproxy.io/docs/envoy/v1.5.0/intro/arch_overview/tracing.html#arch-overview-tracing.

### Optional parentSpanId

parentSpanId: undefined | string

- Defined in envoy-context.ts:238

The x-b3-parentspanid HTTP header is used by the Zipkin tracer in Envoy. The ParentSpanId is 64-bit in length and indicates the position of the parent operation in the trace tree. When the span is the root of the trace tree, the ParentSpanId is absent. See more on zipkin tracing here https://github.com/openzipkin/b3-propagation.

### Optional requestId

requestId: undefined | string

- Defined in envoy-context.ts:281

The x-request-id header is used by Envoy to uniquely identify a request as well as perform stable access logging and tracing. Envoy will generate an x-request-id header for all external origin requests (the header is sanitized). It will also generate an x-request-id header for internal requests that do not already have one. This means that x-request-id can and should be propagated between client applications in order to have stable IDs across the entire mesh. Due to the out of process architecture of Envoy, the header can not be automatically forwarded by Envoy itself. This is one of the few areas where a thin client library is needed to perform this duty. How that is done is out of scope for this documentation. If x-request-id is propagated across all hosts, the following features are available:

- Stable access logging via the v1 API runtime filter or the v2 API runtime filter.
- Stable tracing when performing random sampling via the tracing.random_sampling runtime setting or via forced tracing using the x-envoy-force-trace and x-client-trace-id headers.

### Optional sampled

sampled: undefined | string

- Defined in envoy-context.ts:246

The x-b3-sampled HTTP header is used by the Zipkin tracer in Envoy. When the Sampled flag is 1, the soan will be reported to the tracing system. Once Sampled is set to 0 or 1, the same value should be consistently sent downstream. See more on zipkin tracing here https://github.com/openzipkin/b3-propagation.

### Optional spanId

spanId: undefined | string

- Defined in envoy-context.ts:229

The x-b3-spanid HTTP header is used by the Zipkin tracer in Envoy. The SpanId is 64-bit in length and indicates the position of the current operation in the trace tree. The value should not be interpreted: it may or may not be derived from the value of the TraceId. See more on zipkin tracing here https://github.com/openzipkin/b3-propagation.

### Optional traceId

traceId: undefined | string

- Defined in envoy-context.ts:220

The x-b3-traceid HTTP header is used by the Zipkin tracer in Envoy. The TraceId is 64-bit in length and indicates the overall ID of the trace. Every span in a trace shares this ID. See more on zipkin tracing here https://github.com/openzipkin/b3-propagation.

## Methods

### assembleTracingHeader

- assembleTracingHeader(): HttpHeader

- - Defined in envoy-context.ts:416

  Assemble the required tracing headers that required for propagation. See more here https://www.envoyproxy.io/docs/envoy/v1.5.0/intro/arch_overview/tracing.html#trace-context-propagation

  #### Returns HttpHeader

### shouldCallWithoutEnvoy

- shouldCallWithoutEnvoy(host: string): boolean

- - Defined in envoy-context.ts:429

  #### Parameters

  - ##### host: string

  #### Returns boolean

Generated using TypeDoc