-
Notifications
You must be signed in to change notification settings - Fork 89
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
refactor(backend): telemetry service interface #2807
Conversation
✅ Deploy Preview for brilliant-pasca-3e80ec canceled.
|
opentelemetry deprecation message: "This method will be removed in SDK 2.0. Please use MeterProviderOptions.readers via the MeterProvider constructor instead"
I'm also thinking about the wording |
Other than that LGTM, I'll just need to make a few tweaks with the introduction of my PR here as well. But now that I've seen all the changes that shouldn't be too big of a job :) So let's get this in first. Then we have a clear plan on how to manage the conflicts. |
Co-authored-by: Sarah Jones <[email protected]>
I somewhat agree but I'm struggling to come up with something better because "amount" is what we call objects like this across our code, which is what interface Amount {
value: string
assetCode: string
assetScale: number
} So I think part of the problem is we just use a generic name for our specific concept of the above This is why I don't really like But still I don't love it as-is. And in this case the amount in I'm warming up to something more like this which changes the type of export interface TelemetryService {
incrementCounter(
name: string,
value: number,
attributes?: Record<string, unknown>
): void
incrementCounterWithAmount(
name: string,
// value could be string or number instead, depending on what ends up making the most sense
amount: { value: bigint, assetCode: string, assetScale, number },
attributes?: Record<string, unknown>
): Promise<void>
} Or does it still seem unclear because we're always incrementing an amount in the generic sense? I could see that, but I would argue we need a better name for our amount like |
const metricReader = new PeriodicExportingMetricReader({ | ||
exporter: metricExporter, | ||
exportIntervalMillis: deps.exportIntervalMillis ?? 15000 | ||
this.meterProvider = new MeterProvider({ |
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.
we can delete the setting of this.meterProvider
on L74 now
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.
whoops, yes. good catch
|
||
incrementCounter(): void {} | ||
async incrementCounterWithAmount(): Promise<void> {} | ||
recordHistogram(): void {} |
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.
we can also get rid of the getBaseAssetCode
& getBaseAssetCode
here as well?
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.
yup, removed
I think Likewise, we can also have the Not too big of a deal though. |
I was also leaning toward |
@JoblersTune @mkurapov updated to We can leave it there if we like, although I still wonder if this is making the function name more opinionated (that the amount is a transaction amount) than the actual function body does (and should). I mean shouldn't this same method be used for other amounts, such as fees (which might actually be right around the corner)? In which case the call would be something like: incrementCounterWithTransactionAmount('fees_amount', feeAmount) I think the function should signify this is our concept of amount and avoid signify its for a specific use-case. The
Didn't do this one... our |
@BlairCurrey wouldn't we use a different exposed function for fees? Since I assume we don't need to do privacy stuff on fees, only asset conversions. In which case |
Makes sense, I think that's fine. @BlairCurrey @JoblersTune for privacy preserving amounts, we can have |
That's a fair point... I feel like an new arg (like @mkurapov suggested) might work well since everything else in the function would be the same (doesnt really add any complicated logic and will re-use the conversion stuff). But I could also see a new explicit method if the difference ends up being more than that... I guess we can roll with this for now and cross that bridge when we come to it. |
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.
Looks good, just a single comment
deps.telemetry.incrementCounter('transactions_total', 1, { | ||
description: 'Count of funded transactions' | ||
}) | ||
|
||
const payDuration = payEndTime - payStartTime | ||
deps.telemetry | ||
.getOrCreateHistogramMetric('ilp_pay_time_ms', { | ||
description: 'Time to complete an ILP payment' | ||
}) | ||
.record(payDuration, { | ||
source: deps.telemetry.getInstanceName() | ||
}) | ||
deps.telemetry.recordHistogram('ilp_pay_time_ms', payDuration, { | ||
description: 'Time to complete an ILP payment' | ||
}) | ||
} |
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 we should actually move these promises into a Promise.all
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 arent promises 😄. the underlying add/record sdk methods are synchronous.
incrementCounterWithTransactionAmount
returns a promise due to the amount conversion.
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.
Ah, that's right. LGTM now
Changes proposed in this pull request
incrementCounter
,incrementCounterWithAmount
,recordHistogram
..add
method,incrementCounterWithAmount
handles the amount conversion and privacy obfuscationshutdown
,incrementCounter
,incrementCounterWithAmount
, andrecordHistogram
methodsContext
Fixes: #2799
Checklist
fixes #number