-
Notifications
You must be signed in to change notification settings - Fork 344
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
Instrument instances types #1484
Conversation
fc24db9
to
36fdb62
Compare
// Bootstrap prepares a new tracer to be used by the operator | ||
func Bootstrap(ctx context.Context, namespace string, client client.Client) { | ||
tracer := otel.GetTracerProvider().Tracer(v1.CustomMetricsTracer) | ||
ctx, span := tracer.Start(ctx, "bootstrap") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this span recording events/ reported?
If the bootstrap creates tracer than the span might be noop/default if it is created before initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tracer is already created when this bootstraping is called, this bootstraps the metrics for Open Telemetry,
pkg/metrics/bootstrap.go
Outdated
const meterName = "jaegertracing.io/jaeger" | ||
|
||
// Bootstrap prepares a new tracer to be used by the operator | ||
func Bootstrap(ctx context.Context, namespace string, client client.Client) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this return some kind of closer interface to flush the spans on termination event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this method called? Periodically or just once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called just once.
pkg/metrics/instances.go
Outdated
func (i *instancesMetric) strategy(jaeger v1.Jaeger) string { | ||
strategy := string(jaeger.Spec.Strategy) | ||
if strategy == "" { | ||
return "allinone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is the convention if strategy is empty then we should define a method on the Spec
object to return a strategy and set the allinone as default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same for memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and agent sidecar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are set via Defaulters, but might be empty when running locally (make run
) and/or in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we using Defaulters
in this version of the operator? I started to do it on v2 but IIRC we don't use it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. We have a normalizer in this operator.
pkg/metrics/instances.go
Outdated
func (i *instancesMetric) strategy(jaeger v1.Jaeger) string { | ||
strategy := string(jaeger.Spec.Strategy) | ||
if strategy == "" { | ||
return "allinone" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are set via Defaulters, but might be empty when running locally (make run
) and/or in tests.
pkg/metrics/instances.go
Outdated
ctx, span := tracer.Start(ctx, "setup-jaeger-instances") | ||
defer span.End() | ||
meter := global.Meter(meterName) | ||
_, err := meter.NewInt64ValueObserver("operator_jaeger_instances", i.callback, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With which frequency is the callback called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC this is called per collection interval.
Codecov Report
@@ Coverage Diff @@
## master #1484 +/- ##
==========================================
- Coverage 88.28% 87.91% -0.38%
==========================================
Files 90 92 +2
Lines 5660 5766 +106
==========================================
+ Hits 4997 5069 +72
- Misses 503 532 +29
- Partials 160 165 +5
Continue to review full report at Codecov.
|
083af9a
to
a5c078a
Compare
Address all comments, added an screen-shot with the visualization of the metrics. |
If the metrics are exposed in p8s nedpoint. It might be better to paste the metrics here in the text form. At least for me it is the best way to understand what is being exposed. |
|
b4de1eb
to
6a5cec6
Compare
The metrics look good. I would rename Are the following labels needed? What do they provide us?
|
I don't think we need it, we can get rid of it WDYT? @jpkrohling |
If we keep the name/namespace labels, we will have high cardinality here. In fact, I would even split the metrics into this:
I'm not familiar with the OpenTelemetry Metrics API, but OpenCensus had a separation between counters and views: you'd have only one counter here, reporting how the instance looks like (agent mode, storage, strategy, version), and four different views, one for each metric I listed above. With that, we only have a limited number of time series, the last one being the only one that can potentially grow "indefinitely". Note that my proposal also changes the prefix, to be inline with the other Jaeger components ("jaeger_collector_...", "jaeger_agent_...") |
I changed the metrics using the suggested way:
|
b69969e
to
8000b2c
Compare
68c4a90
to
eec4c90
Compare
Signed-off-by: Ruben Vargas <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]> Signed-off-by: Ruben Vargas <[email protected]>
- Fixed import orders - Better error logging and handling - Some code linting fixes Signed-off-by: Ruben Vargas <[email protected]>
…ce attributes Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
eec4c90
to
f96b438
Compare
@jpkrohling @pavolloffay Please give it another review, I added tests and a flag to enable/disable this feature. |
Signed-off-by: Ruben Vargas <[email protected]>
Signed-off-by: Ruben Vargas <[email protected]>
…r into instrument-op
Signed-off-by: Ruben Vargas <[email protected]>
I address all comments, removed the flag, I think this is ready for another review and hopefully a merge =) |
c := controller.New( | ||
processor.New( | ||
selector.NewWithHistogramDistribution( | ||
histogram.WithExplicitBoundaries(config.DefaultHistogramBoundaries), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the boundaries defined here? Do they make sense for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of that is applicable to us. for now. That is why I just set default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the default values? If we don't have histograms, why do we configure them? Can't we just leave this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the default values? If we don't have histograms, why do we configure them? Can't we just leave this out?
I don't know, we are not using it. I can't I need to pass and aggregation selector to the New
method. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// NewWithHistogramDistribution returns a simple aggregator selector
// that uses histogram aggregators for `ValueRecorder` instruments.
// This selector is a good default choice for most metric exporters.
From this comment I'm assuming this is the best "default" configuration.
Signed-off-by: Ruben Vargas [email protected]
Which problem is this PR solving?
stratgegy
,storage
andagentMode
Short description of the changes
valueObserver
and query for instances manages by the operator in every callback. The reason of using avalueObserver
is because I cannot relies on reconciliation process and usingUpDownCounter
instrument because the reconciliation process can be execute multiple times for creation/update/delete and I can't distinguish when is an update or creation.