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 Custom to Context and expose it via public API #585

Merged
merged 7 commits into from
Nov 13, 2019
Merged

Add Custom to Context and expose it via public API #585

merged 7 commits into from
Nov 13, 2019

Conversation

gregkalapos
Copy link
Contributor

@gregkalapos gregkalapos commented Nov 5, 2019

Addressing #582.

Adding and exposing Custom which is not yet available in .NET.

Also added docs.

@soumithx
Copy link

soumithx commented Nov 5, 2019

is build failed? @gregkalapos

@gregkalapos
Copy link
Contributor Author

is build failed? @gregkalapos

We had some known CI issues which we already work on. The build fail is probably not related to this PR.

@@ -1,45 +1,50 @@
using System;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about the lots of changes here - this is again our line ending issue. The only real change here is that I added public Dictionary<string, string> Custom => _custom.Value; and public bool ShouldSerializeCustom() => _custom.IsValueCreated && Custom.Count > 0;

Copy link
Member

@bmorelli25 bmorelli25 left a comment

Choose a reason for hiding this comment

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

Docs LGTM. A couple suggestions.

docs/public-api.asciidoc Outdated Show resolved Hide resolved
[[api-transaction-Custom]]
==== `Dictionary<string,string> Custom`

Custom context is used to add non-indexed, custom contextual information to transactions. Non-indexed means the data is not searchable or aggregatable in Elasticsearch, and you cannot build dashboards on top of the data. However, non-indexed information is useful for other reasons, like providing contextual information to help you quickly debug performance issues or errors.
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 move each sentence to its own line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I did it.

Copy link
Contributor

@SergeyKleyman SergeyKleyman left a comment

Choose a reason for hiding this comment

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

LGTM other than missing Custom keys validation

----
Agent.Tracer.CaptureTransaction(transactionName, transactionType, (transaction) =>
{
transaction.Custom.Add("foo", "bar");
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more consistent to use indexer here just as in Labels example and also it might be worth using value that would not be possible to store as label (i.e., very long string).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, changed it to indexer

/// </summary>
[JsonProperty("tags")]
[JsonConverter(typeof(LabelsJsonConverter))]
public Dictionary<string, string> Custom => _custom.Value;
Copy link
Contributor

Choose a reason for hiding this comment

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

We need JsonConverter here as well to ensure the keys are valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a converter for this - also covered by tests now.

Copy link
Contributor

@SergeyKleyman SergeyKleyman left a comment

Choose a reason for hiding this comment

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

LGTM

@gregkalapos gregkalapos merged commit b89714d into elastic:master Nov 13, 2019
@gregkalapos gregkalapos deleted the ExposeTransactionCustom branch November 13, 2019 18:49
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.

4 participants