-
Notifications
You must be signed in to change notification settings - Fork 853
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
feat: implement metrics sdk #415
Conversation
distContext?: types.DistributedContext, | ||
spanContext?: types.SpanContext | ||
): void { | ||
throw new Error('not implemented yet'); |
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 just be a no-op since we are saying we don't through errors? (Or maybe log instead?)
name: string, | ||
options?: types.MetricOptions | ||
): Metric<GaugeHandle> { | ||
throw new Error('not implemented yet'); |
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.
Log?
b67f3d0
to
3dcf180
Compare
Codecov Report
@@ Coverage Diff @@
## master #415 +/- ##
==========================================
+ Coverage 95.33% 95.89% +0.55%
==========================================
Files 118 114 -4
Lines 5852 5599 -253
Branches 502 440 -62
==========================================
- Hits 5579 5369 -210
+ Misses 273 230 -43
|
name: string, | ||
options?: types.MetricOptions | ||
): Metric<CounterHandle> { | ||
const opt = Object.assign({ monotonic: false, disabled: false }, options); |
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 { monotonic: false, disabled: false }
meant to be the default options? Would it make sense to move it to a DEFAULT_COUNTER_OPTIONS
const?
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.
Unidirectional needs to be renamed, but monotonic can come from the MetricsOptions: https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-types/src/metrics/Metric.ts#L60
980f29a
to
c1bc52c
Compare
import * as types from '@opentelemetry/types'; | ||
|
||
/** | ||
* CounterHandle is an implementation of the {@link CounterHandle} interface. |
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 comment in itself doesn't seem too useful. I'm OK with removing it if needed. (Same applies for comment below)
I guess I was thinking this would instead talk a bit about what a counter is and what a handle is, but maybe the expectation doesn't make sense - perhaps people should just be reading the READMEs anyway.
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.
Hmm, tried to update JSDoc comment in e0dcecd. Let me know if this makes sense.
@mayurkale22 fwiw when you force push amendments the PR loses history and I have a hard time seeing what is changed from the previous version. Can you try to keep a history during the PR process and just flatten it before merge? Unless there is some other reason to keep it a single commit. |
I didn't squash the previous comments, commits history is still intact. I had to do force push after rebasing with the master. Anyway, in general I agree with your suggestion. |
import { MetricOptions } from './types'; | ||
|
||
/** This is a SDK implementation of {@link Metric} interface. */ | ||
export abstract class Metric<T> implements types.Metric<T> { |
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.
LGTM
* calling this method for each operation. | ||
* @param labelValues the list of label values. | ||
*/ | ||
getHandle(labelValues: string[]): T { |
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.
I think getHandle isn't meant to take labelValues
, but an instance of a LabelSet
and just be a wrapper around a specific metric.
const labelSet1: LabelSet = meter.defineLabels(labels1)
const labelSet2: LabelSet = meter.defineLabels(labels2)
const counter = meter.createCounter("name");
counter.add(labelSet1, 1); // counter now has 1 for labelSet1
const handle = counter.getHandle(labelSet2);
handle.add(1) // counter has 1 for labelSet2
There were some discussions related to metrics today in the spec and I think it might be in flux. It's hard to tell how they're intending Metric/Handle/Meter to play together. It may be worth taking a look. |
const hash = hashLabelValues(labelValues); | ||
if (this._handles.has(hash)) return this._handles.get(hash)!; | ||
|
||
const handle = this._makeHandle(); |
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.
makeHandle, and the handles, should accept the label set/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.
Hmm, correct. Done in 7d53d02. Also, added a method to generate TimeSeries
from the handle's data + label 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.
@bg451 I have made the required changes, please take a look again when you get a time.
71db9b0
to
2ed9b68
Compare
171d790
to
5dd40b9
Compare
5dd40b9
to
6b3ee5f
Compare
Per the SIG, we agreed to merge this one and revise later based on Prometheus exporter and end-to-end workflow. |
…ry#415) * fix: empty spans when encode failed in HTTPSender Signed-off-by: himstone.yang <[email protected]> * Apply fixes Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
Co-authored-by: Bartlomiej Obecny <[email protected]>
Which problem is this PR solving?
Updates Implement Metrics SDK #402
First take on metrics SDK. In order to keep short PR, only
Counter
metric support is added.The monotonic concept is based on https://github.com/open-telemetry/opentelemetry-specification/pull/250/files.
i.e.
Counter
s are defined as monotonic by default, meaning that positive values are expected andGauge
s are defined as non-monotonic by default, meaning that any value (positive or negative) is allowed.Record call is still missing, will do it in the follow-up PR.
Update 1: Added support for
Gauge
Metric.Update 2: Added
MeterConfig
withLogger
option.