envoyproxy / envoyproxy/envoy

OpenCensus ConstantSampler::ALWAYS_PARENT makes the sample value always 1 if no parent

Open
#17,358 1 comment 1 reaction 0 assignees View on GitHub
bug help wanted
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
437

Description

*Title*: *OpenCensus ConstantSampler::ALWAYS_PARENT makes the sample value always 1 if no parent*

*Description*:
According to [opencensus proto](https://github.com/census-instrumentation/opencensus-proto/blob/master/src/opencensus/proto/trace/v1/trace_config.proto#L62), the sample value will be **off** when setting `ConstantSampler::ALWAYS_PARENT` and there is no parent.

But [here](https://github.com/envoyproxy/envoy/blob/v1.19.0/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc#L358) `ConstantSampler::ALWAYS_PARENT` and `ConstantSampler::ALWAYS_ON` have the same treatment.

https://github.com/envoyproxy/envoy/blob/v1.19.0/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc#L358

*Repro steps*:

Enable envoy's tracing `envoy.config.trace.v3.OpenCensusConfig` and observe the `TRACEPARENT` in the log.

*Admin and Stats Output*:

No need.

*Config*:

config in `lds.yaml`:
```yaml
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /var/log/access.log
log_format:
text_format: "[%START_TIME%] balabala... \"%REQ(TRACEPARENT)%\"\n"
...
tracing:
provider:
name: envoy.tracers.opencensus
typed_config:
"@type": type.googleapis.com/envoy.config.trace.v3.OpenCensusConfig
trace_config:
constant_sampler:
decision: ALWAYS_PARENT
stdout_exporter_enabled: false
stackdriver_exporter_enabled: false
zipkin_exporter_enabled: false
ocagent_exporter_enabled: false
incoming_trace_context: ["TRACE_CONTEXT"]
outgoing_trace_context: ["TRACE_CONTEXT"]

```

*Logs*:

```
[2021-07-15T05:41:32.635Z] balabala... "00-22c7440c663b46660a15d376b2771b3b-fac98c165e9c09ea-01"
```

The last two letters in envoy's newly added `TRACEPARENT` are always `01`.

https://www.w3.org/TR/trace-context/#examples-of-http-traceparent-headers

*Call Stack*:

No need.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.