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

Ported wavefront-java-sdk to C# #1

Merged
merged 5 commits into from
Aug 22, 2018
Merged

Ported wavefront-java-sdk to C# #1

merged 5 commits into from
Aug 22, 2018

Conversation

hanwavefront
Copy link
Contributor

No description provided.

README.md Outdated
builder.TracingPort(tracingPort);

/* set this if you want to change the default flush interval of 5 seconds */
builder.FlushIntervalSeconds(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's encourage users to set it higher not lower :) Maybe 30 seconds in this example.

[Fact]
public void TestSanitize()
{
Assert.Equal("\"hello\"", Utils.Sanitize("hello"));

Choose a reason for hiding this comment

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

if you have a need to escape strings you can use string literals

@"""hello""" though if it is more clear is up for debate.

/// <summary>
/// Use this format to send metric data to Wavefront.
/// </summary>
public static readonly string WavefrontMetricFormat = "wavefront";

Choose a reason for hiding this comment

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

public const string WavefrontMetricFormat faster as it gets compiled down into a literal within the code; however, does have implications in how the clients consume our library (in that they would have to rebuild their clients with our version if we changed the value of our const). If the value is never expected to change this may not be an issue.

}
if (String.IsNullOrWhiteSpace(tag.Key))
{
throw new ArgumentException("metric point tag value cannot be blank");
Copy link

@MikeMcMahon MikeMcMahon Aug 18, 2018

Choose a reason for hiding this comment

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

our proxies do allow this though. they silently ignore it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have to keep in mind that we using the same logic for both proxy and direct ingestion.
While it is true that proxy has some safeguards for this, generally good idea to throw in SDK itself so that client send us clean data.

We do the same in our java sdk - https://github.com/wavefrontHQ/wavefront-java-sdk/blob/bc7524d86561547ecd188076a6ced75724e44a9e/src/main/java/com/wavefront/sdk/common/Utils.java#L69

{
}

var statusCode = (int)HttpStatusCode.BadRequest;

Choose a reason for hiding this comment

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

var vs. just using int, when the type is obvious it's useful, but the type is only obvious with c-style casting? I'd favor just using int explicitly vs var, which is incredibly useful for more complex object types.

Logger.Log(LogLevel.Warning, "Could not close old socket.", e);
}
socketOutputStream = new BufferedStream(client.GetStream(), bufferSize);
Logger.Log(LogLevel.Information, String.Format("Successfully reset connection to {0}:{1}", host, port));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: try to stick to 100 char limit so that I don't have to scroll right while going through the Pull Request.

}
if (String.IsNullOrWhiteSpace(tag.Key))
{
throw new ArgumentException("metric point tag value cannot be blank");
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to keep in mind that we using the same logic for both proxy and direct ingestion.
While it is true that proxy has some safeguards for this, generally good idea to throw in SDK itself so that client send us clean data.

We do the same in our java sdk - https://github.com/wavefrontHQ/wavefront-java-sdk/blob/bc7524d86561547ecd188076a6ced75724e44a9e/src/main/java/com/wavefront/sdk/common/Utils.java#L69

{
throw new ArgumentException("metric point tag key cannot be blank");
}
if (String.IsNullOrWhiteSpace(tag.Key))
Copy link
Contributor

Choose a reason for hiding this comment

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

@hanwavefront - Shouldn't this be
if (String.IsNullOrWhiteSpace(tag.Value))

{
throw new ArgumentException("histogram tag key cannot be blank");
}
if (String.IsNullOrWhiteSpace(tag.Key))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be
if (String.IsNullOrWhiteSpace(tag.Value))

/// <summary>
/// Wavefront direct ingestion client that sends data directly to Wavefront cluster via the direct ingestion API.
/// </summary>
public class WavefrontDirectIngestionClient : IWavefrontMetricSender, IWavefrontHistogramSender, IWavefrontTracingSpanSender, IBufferFlusher
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: avoid scrolling while reading github Pull requests, break into 2 lines?

/// Client that sends data directly via TCP to the Wavefront Proxy Agent. User should probably attempt to reconnect
/// when exceptions are thrown from any methods.
/// </summary>
public class WavefrontProxyClient : IWavefrontMetricSender, IWavefrontHistogramSender, IWavefrontTracingSpanSender, IBufferFlusher
Copy link
Contributor

Choose a reason for hiding this comment

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

break into 2 lines?

namespace Wavefront.CSharp.SDK.Integrations
{
/// <summary>
/// Client that sends data directly via TCP to the Wavefront Proxy Agent. User should probably attempt to reconnect
Copy link
Contributor

Choose a reason for hiding this comment

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

break into 2 lines to avoid scrolling to the right while reading code?

Copy link
Contributor

@sushantdewan123 sushantdewan123 left a comment

Choose a reason for hiding this comment

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

LGTM!

@vikramraman vikramraman merged commit b2c4254 into master Aug 22, 2018
@hanwavefront hanwavefront deleted the han/sdk-creation branch May 7, 2020 21:38
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