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

More Transaction Metrics #4781

Merged
merged 2 commits into from
Aug 2, 2018

Conversation

jason-bragg
Copy link
Contributor

Added more transaction metrics, and benchmark tests for transaction throttling.

Added more transaction metrics, and benchmark tests for transaction throttling.
@jason-bragg jason-bragg requested a review from ReubenBond July 18, 2018 23:08
@jason-bragg jason-bragg added this to the 2.1.0 milestone Jul 18, 2018
private readonly TransactionRateLoadSheddingOptions options;
private readonly PeriodicAction monitor;
private long transactionStartedAtLastCheck;
private TransactionAgentStatistics lastStatistics;
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be ITransactionAgentStatistic too?

Interlocked.Increment(ref this.transactionsThrottled);
}

public static TransactionAgentStatistics Create(ITransactionAgentStatistics initialStatistics)
Copy link
Contributor

Choose a reason for hiding this comment

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

why isn't this return a ITransactionAgentStatistics as well?

Copy link
Member

Choose a reason for hiding this comment

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

This method seems more like a copy method than a create method

@@ -66,8 +64,7 @@ public bool IsOverloaded()

DateTime now = DateTime.UtcNow;
this.monitor.TryAction(now);
long startCounter = this.statistics.TransactionStartedCounter;
double txPerSecondCurrently = CalculateTps(this.transactionStartedAtLastCheck, this.lastCheckTime, startCounter, now);
double txPerSecondCurrently = CalculateTps(this.lastStatistics.TransactionsStarted, this.lastCheckTime, this.statistics.TransactionsStarted, now);
Copy link
Contributor

Choose a reason for hiding this comment

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

where do you track ITransactionAgentStatistic.Throttled ? did I miss anything. I thought it will be tracked here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's tracked in the transaction agent, where the IsOverloaded is called. The agent is responsible for updating it's statistics.

{
return CommitReadOnlyTransaction(transactionInfo);
}
TransactionalStatus status = (writeParticipants == null)
Copy link
Member

Choose a reason for hiding this comment

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

Does there need a try/catch to ensure we track failed txns correctly, or are these async methods 'guaranteed' to not throw?

private const string FailedTransactionsPerSecondMetric = "TransactionAgent.FailedTransactions_PerSecond";

private const string ThrottledTransactionsTotalMetric = "TransactionAgent.ThrottledTransactions_Total";
private const string ThrottledTransactionsPerSecondMetric = "TransactionAgent.ThrottledTransactions_PerSecond";
Copy link
Member

Choose a reason for hiding this comment

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

Convention is to use only . as separators - see StatisticNames.cs

var currentReported = TransactionAgentStatistics.Create(statistics);

this.telemetryProducer.TrackMetric(TransactionsStartedTotalMetric, currentReported.TransactionsStarted);
this.telemetryProducer.TrackMetric(TransactionsStartedPerSecondMetric, PerSecond(this.lastReported.TransactionsStarted, currentReported.TransactionsStarted, now - lastReportTime));
Copy link
Member

Choose a reason for hiding this comment

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

Could extract var reportPeriod = now - lastReportTime

@@ -13,25 +13,24 @@ public static class SiloBuilderExtensions
/// <summary>
/// Configure cluster to use the distributed TM algorithm
/// </summary>
public static ISiloHostBuilder UseDistributedTM(this ISiloHostBuilder builder)
public static ISiloHostBuilder UseDistributedTM(this ISiloHostBuilder builder, bool withReporter = true)
Copy link
Member

Choose a reason for hiding this comment

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

This new parameter is not obvious and hence could benefit from a doc comment.

Slightly prefer naming it reportStatistics.

I'm not entirely convinced that this needs to be exposed - or could we implement this using the options pattern somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue here is that users can provide their own statistics reporting. So they can configure tm with reporting, or without, and provide their own. I'll add a comment.
As for being part of the options, the Tm has no options now and this is really about what we're setting up in the container, not how the TM is configured. :/

Copy link
Member

@ReubenBond ReubenBond left a comment

Choose a reason for hiding this comment

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

There are a few changes which could be made, but nothing ultimately blocking

@jason-bragg
Copy link
Contributor Author

@dotnet-bot test functional please

@veikkoeeva
Copy link
Contributor

I'll link as tangential to #4805 (comment) since it appears I just linked an example doing a bit of the same.

@jason-bragg
Copy link
Contributor Author

@dotnet-bot test functional please

@benjaminpetit benjaminpetit merged commit 00fe587 into dotnet:master Aug 2, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants