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

feat: Add OLTP Exporter Option for Protocol #2321

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bunkrur
Copy link

@bunkrur bunkrur commented Jun 13, 2023

Fixes #

I wanted to clean some stuff up and remove an alien commit from a friend. I feel like this is a happy compromise.

Some issues I ran into in the last attempt were

  • trying to get the config generator to respect http/protobuff within the config file.
  • trying to force enum convention in yaml
  • trying to do validation against the enum (its always gonna be valid unless we treat the input as a string)
  • trying to change the class structure - which would mean people would have to change their yaml configs due to code generation and I dont want to break that.

@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Jun 13, 2023
@bunkrur
Copy link
Author

bunkrur commented Jun 13, 2023

@tomkerkhove :)

@tomkerkhove
Copy link
Owner

The PR was only opened yesterday, please bear with me.

public string CollectorUri { get; set; }
//Todo: Headers
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need this? We might want to remove this

Copy link
Author

Choose a reason for hiding this comment

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

removing

@@ -391,7 +392,7 @@ public async Task RuntimeConfiguration_HasConfiguredCollectorUriInOpenTelemetryC
// Arrange
Copy link
Owner

Choose a reason for hiding this comment

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

Let's use InlineData to inject 2 protocol types to make sure it works with different versions and not grpc which can be the default

{
public class OpenTelemetryCollectorSinkConfiguration
{
public OtlpExportProtocol Protocol { get; set; } = default(OtlpExportProtocol);
Copy link
Owner

Choose a reason for hiding this comment

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

What is the default? THinking of this again, we need to make sure we don't break existing users

Copy link
Owner

Choose a reason for hiding this comment

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

Thinking of it again, this is probably what we want:

Suggested change
public OtlpExportProtocol Protocol { get; set; } = default(OtlpExportProtocol);
public OtlpExportProtocol? Protocol { get; set; };

Then in the code we will check if it was specified. If it was not, use the current protocol.

@@ -48,6 +72,11 @@ public ValidationResult Run()
errorMessages.Add($"Configured URI ({collectorUri}) for the OpenTelemetry Collector is not a valid URI.");
}
}
// Protocol Validation
if (!TryParseProtocol(collectorProtocol, out var parsedProtocol))
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need this? If the protocol would be bad, then it would not be present. I think we can drop this logic and just rely on the SDK

Copy link
Author

Choose a reason for hiding this comment

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

Removing

@@ -13,6 +14,27 @@ namespace Promitor.Agents.Scraper.Validation.Steps.Sinks
public class OpenTelemetryCollectorMetricSinkValidationStep : ValidationStep, IValidationStep
{
private readonly IOptions<ScraperRuntimeConfiguration> _runtimeConfiguration;
public static bool TryParseProtocol(string value, out OtlpExportProtocol result)
Copy link
Owner

Choose a reason for hiding this comment

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

As mentioned below, we don't need this

Copy link
Author

Choose a reason for hiding this comment

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

removing

@@ -115,6 +115,7 @@ private string BuildOpenApiDescription(IConfiguration configuration)
if (metricSinkConfiguration.OpenTelemetryCollector != null)
{
openApiDescriptionBuilder.AppendLine($"<li>OpenTelemetry Collector located on {metricSinkConfiguration.OpenTelemetryCollector.CollectorUri}</li>");
openApiDescriptionBuilder.AppendLine($"<li>OpenTelemetry Collector Protocol selected: {metricSinkConfiguration.OpenTelemetryCollector.Protocol}</li>");
Copy link
Owner

Choose a reason for hiding this comment

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

As mentioned earlier, this should be part of message in line 117

Comment on lines +229 to +230
metricSinkAsciiTable.AddRow("OpenTelemetry Collector", $"Url: {otelConfiguration.CollectorUri}.");
metricSinkAsciiTable.AddRow("OpenTelemetry Collector", $"Protocol: {otelConfiguration.Protocol}.");
Copy link
Owner

Choose a reason for hiding this comment

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

This should be consolidated

.AddOtlpExporter(options =>
{
options.Endpoint = new Uri(otelConfiguration.CollectorUri);
options.Protocol = otelConfiguration.Protocol;
Copy link
Owner

Choose a reason for hiding this comment

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

Only assign when configured

Suggested change
options.Protocol = otelConfiguration.Protocol;
if(otelConfiguration.Protocol != null)
{
options.Protocol = otelConfiguration.Protocol;
}

@tomkerkhove
Copy link
Owner

Let me know when you are done incorporating the feedback and I'll do another review - Thanks!

@tomkerkhove
Copy link
Owner

@bunkrur Any idea if you can complete the last comments or not?

@bunkrur
Copy link
Author

bunkrur commented Jul 3, 2023

I can, yeah just swallowed up recently. Will try by tomorrow

@tomkerkhove
Copy link
Owner

Let me know how you are doing @bunkrur (no pressure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 Ready for Review Pull Request is not reviewed yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants