Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OTEL_SAMPLING_PROBABILITY env variable definition #1117

Conversation

tigrannajaryan
Copy link
Member

Fixes #1105

@tigrannajaryan tigrannajaryan requested review from a team October 20, 2020 15:17
@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/sampling-prob-env-var branch from 7ee9068 to e1c3ef4 Compare October 20, 2020 15:18
@tigrannajaryan tigrannajaryan requested a review from trask October 20, 2020 15:18
Copy link
Member

@arminru arminru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that was quick, @tigrannajaryan 🙂

specification/sdk-environment-variables.md Outdated Show resolved Hide resolved
@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/sampling-prob-env-var branch from da29e94 to 863b4b4 Compare October 20, 2020 20:12
@@ -9,6 +9,7 @@ The goal of this specification is to unify the environment variable names betwee
| OTEL_RESOURCE_ATTRIBUTES | Key-value pairs to be used as resource attributes | | See [Resource SDK](./resource/sdk.md#specifying-resource-information-via-an-environment-variable) for more details. |
| OTEL_LOG_LEVEL | Log level used by the SDK logger | "info" | |
| OTEL_PROPAGATORS | Propagators to be used as a comma separated list | "tracecontext,baggage" | Values MUST be deduplicated in order to register a `Propagator` only once. Unrecognized values MUST generate a warning and be gracefully ignored. |
| OTEL_SAMPLING_PROBABILITY| Sampling probability, a number in the [0..1] range, e.g. 0.25| 1 | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does setting this env var imply setting a ParentOrElse sampler with an underlying TraceIdRatioBased sampler? Or something else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let language maintainers tell what is needed here, I don't know how sampling in SDKs works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should do what I suggested, but I'd love other opinions. And, we should definitely document what's expected. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkwatson can you please suggest the exact edit to use on this line? I think it will fit best in the Notes column.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTEL_TRACEID_RATIO_(BASED_)SAMPLER_PROBABILITY is quite a bulky term but would probably be the most expressive one.
In the notes column, we could link to /~https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/sdk.md#traceidratiobased.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arminru would you still expect that the TraceIdRatioBased sampler would be wrapped with a ParentOrElse with that name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkwatson I would not expect that variable to affect which samplers are set up in which arrangement but if a TraceIdRatioBased was set up automatically based on other configuration, this would be the probability it would use. Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that, it seems strange to have an env-var to control one facet of a sampler, but no environment variable to actual specify a sampler!

I think we should hold off on this addition until we have a way to specify a sampler via env vars, so that this env var makes sense in that context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add metrics and logs sampling later, should we name this OTEL_TRACE_SAMPLING_PROBABILITY?

@carlosalberto
Copy link
Contributor

I think we should hold off on this addition until we have a way to specify a sampler via env vars, so that this env var makes sense in that context.

@jkwatson Makes sense. I think we ought to add an OTEL_SAMPLER env var with a few pre cooked values (to keep it simple for now), i.e. always_on, always_off, traceidratio, parentbased_traceidratio.

Opinions?

@jkwatson
Copy link
Contributor

I think we should hold off on this addition until we have a way to specify a sampler via env vars, so that this env var makes sense in that context.

@jkwatson Makes sense. I think we ought to add an OTEL_SAMPLER env var with a few pre cooked values (to keep it simple for now), i.e. always_on, always_off, traceidratio, parentbased_traceidratio.

Opinions?

that makes sense to me, yes.

@arminru
Copy link
Member

arminru commented Oct 23, 2020

@carlosalberto opened #1136 for adding OTEL_TRACE_SAMPLER, please take a look at that one as well.

@carlosalberto
Copy link
Contributor

#1136 has been merged. @tigrannajaryan please rebase we can try to wrap this up 😉

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/sampling-prob-env-var branch from 863b4b4 to d8f89fa Compare October 28, 2020 22:18
@tigrannajaryan
Copy link
Member Author

#1136 has been merged. @tigrannajaryan please rebase we can try to wrap this up 😉

Done.

@carlosalberto
Copy link
Contributor

It looks we should go with @jmacd's suggestion and rename this to OTEL_TRACE_SAMPLING_PROBABILITY? @tigrannajaryan

@carlosalberto
Copy link
Contributor

@open-telemetry/specs-approvers Please review.

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/sampling-prob-env-var branch from d8f89fa to d779518 Compare October 29, 2020 17:54
@tigrannajaryan
Copy link
Member Author

Renamed to OTEL_TRACE_SAMPLING_PROBABILITY.
I am still looking for a recommendation on what to put in the Notes (if anything).

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/sampling-prob-env-var branch from d779518 to 30769ff Compare October 29, 2020 17:56
@carlosalberto
Copy link
Contributor

@Oberon00 @jkwatson as you seem to be more familiar with Sampling needs, maybe want to drop your opinion on what should be stated here?

@carlosalberto carlosalberto self-requested a review October 30, 2020 14:56
@@ -9,7 +9,8 @@ The goal of this specification is to unify the environment variable names betwee
| OTEL_RESOURCE_ATTRIBUTES | Key-value pairs to be used as resource attributes | | See [Resource SDK](./resource/sdk.md#specifying-resource-information-via-an-environment-variable) for more details. |
| OTEL_LOG_LEVEL | Log level used by the SDK logger | "info" | |
| OTEL_PROPAGATORS | Propagators to be used as a comma separated list | "tracecontext,baggage" | Values MUST be deduplicated in order to register a `Propagator` only once. Unrecognized values MUST generate a warning and be gracefully ignored. |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLING_PROBABILITY| Sampling probability, a number in the [0..1] range, e.g. 0.25| 1 | |
Copy link
Member

@Oberon00 Oberon00 Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what the default value means here, as discussed in #985. Is this the default to be used if sampler is traceidratio?

@@ -9,7 +9,8 @@ The goal of this specification is to unify the environment variable names betwee
| OTEL_RESOURCE_ATTRIBUTES | Key-value pairs to be used as resource attributes | | See [Resource SDK](./resource/sdk.md#specifying-resource-information-via-an-environment-variable) for more details. |
| OTEL_LOG_LEVEL | Log level used by the SDK logger | "info" | |
| OTEL_PROPAGATORS | Propagators to be used as a comma separated list | "tracecontext,baggage" | Values MUST be deduplicated in order to register a `Propagator` only once. Unrecognized values MUST generate a warning and be gracefully ignored. |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLING_PROBABILITY| Sampling probability, a number in the [0..1] range, e.g. 0.25| 1 | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have two variables we need to document what happens when e.g. OTEL_TRACE_SAMPLING_PROBABILITY is set but OTEL_TRACE_SAMPLER is not set (should the documented default parentbased_always_on be used or should it "smartly" use traceidratio? Or if it is explicitly set to something else than traceidratio or parentbased_traceidratio.

Alternatively, we might consider having only one variable with a bit more complex values like OTEL_TRACE_SAMPLER=traceidratio?ratio=0.25 (I imagine using querystring syntax would be useful here since many languages support parsing that out of the box).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say OTEL_TRACE_SAMPLING_PROBABILITY is evaluated only if OTEL_TRACE_SAMPLER is set to traceidratio?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or parentbased_traceidratio.

What if the tracer is configured in code? Should it somehow pick up the value? I guess not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 If I understood correctly, this is a value used mostly for auto-instrumentation, at least for now (similar to OTEL_PROPAGATORS).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the intention, it should be documented. I would not be surprised if some SDKs respond to these environment variables out of the box.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 If I understood correctly, this is a value used mostly for auto-instrumentation, at least for now (similar to OTEL_PROPAGATORS).

This was not mentioned anywhere that this is only for auto-instrumentation. I was planning to make SDK (.NET), respond to these env variables by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understood correctly, this is a value used mostly for auto-instrumentation, at least for now (similar to OTEL_PROPAGATORS).

This is functionality that auto-instrumentation can use, I agree, but it's functionality that I want for manual instrumentation too. I think of making every SDK implement these variables for configuring manual instrumentation is a post-GA item, something covered by the so-called "distros" or "launchers" that give you an easy way to install the SDK configured by the environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the tracer is configured in code? Should it somehow pick up the value? I guess not.

The convention in the Jaeger SDKs is:

  • there is a Configuration struct
  • it is used to construct the tracer
  • it can be populated programmatically (default values result in default behavior), in some cases from config files
  • it does not take env vars into account by default. To enable configuration via env vars, one must invoke cfg = cfg.FromEnv() explicitly on an existing config object, e.g. after setting the default parameters programmatically.

One downside of this configuration mechanism is that it must accounts for a number of optional features and, as a result, forces all dependencies to be included. E.g. in Java we have several modules (core, thrift, zipkin, etc.), and a top-level client module that implements the configuration and depends on all of the other modules (whether you end up using them or not).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think of making every SDK implement these variables for configuring manual instrumentation is a post-GA item,

Sounds good to me. For now the only components required to support this would be auto-instrumentation components.

@@ -9,7 +9,8 @@ The goal of this specification is to unify the environment variable names betwee
| OTEL_RESOURCE_ATTRIBUTES | Key-value pairs to be used as resource attributes | | See [Resource SDK](./resource/sdk.md#specifying-resource-information-via-an-environment-variable) for more details. |
| OTEL_LOG_LEVEL | Log level used by the SDK logger | "info" | |
| OTEL_PROPAGATORS | Propagators to be used as a comma separated list | "tracecontext,baggage" | Values MUST be deduplicated in order to register a `Propagator` only once. Unrecognized values MUST generate a warning and be gracefully ignored. |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLER | Sampler to be used for traces | "parentbased_always_on" | See [Sampling](./trace/sdk.md#sampling) |
| OTEL_TRACE_SAMPLING_PROBABILITY| Sampling probability, a number in the [0..1] range, e.g. 0.25| 1 | |
Copy link
Member

@Oberon00 Oberon00 Oct 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be

Suggested change
| OTEL_TRACE_SAMPLING_PROBABILITY| Sampling probability, a number in the [0..1] range, e.g. 0.25| 1 | |
| OTEL_TRACE_SAMPLER_TRACEIDRATIO_RATIO| Sampling ratio (probability), a number in the [0..1] range, e.g. 0.25| 1 | |

to match the name traceidratio that is used below for OTEL_TRACE_SAMPLER and to have some logical hierarchy that is easy to understand and extensible if we add configuration for other samplers.

The current name has no obvious connection to traceidratio, which I would find very confusing as a new user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support this renaming. The intention for this environment variable is to configure only the traceidratio sampler, as I see it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@jkwatson
Copy link
Contributor

@Oberon00 @jkwatson as you seem to be more familiar with Sampling needs, maybe want to drop your opinion on what should be stated here?

I'm more concerned with having clear instructions for implementors in this case.

@carlosalberto
Copy link
Contributor

Closed in favor of #1190

@tigrannajaryan tigrannajaryan deleted the feature/tigran/sampling-prob-env-var branch November 10, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OTEL_SAMPLING_PROBABILITY (or similar named) to sdk environment variable spec
10 participants