-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add initial plugin for dotnet. #173
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a61fabe
chore: Scaffold dotnet plugin project.
kinyoklion bbb61dc
Add dotnet setup step and correct working directory.
kinyoklion 7bb9496
Explicit permissions.
kinyoklion f694eb1
Reformat workflow file.
kinyoklion f9544cd
Add project reference to implementation from tests.
kinyoklion a012647
feat: Add basic configuration and otel.
kinyoklion da1036d
Merge branch 'main' into rlamb/add-basic-config-dotnet
kinyoklion a118a18
WIP Plugin
kinyoklion e75a68f
feat: Add initial plugin for dotnet.
kinyoklion d5bc0e8
Merge branch 'main' into rlamb/add-dotnet-plugin
kinyoklion f5c306b
Re-add default metrics name.
kinyoklion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
sdk/@launchdarkly/observability-dotnet/src/LaunchDarkly.Observability/BaseBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| using System; | ||
|
|
||
| namespace LaunchDarkly.Observability | ||
| { | ||
| /// <summary> | ||
| /// Base builder which allows for methods to be shared between building a config directly and building a plugin. | ||
| /// <remarks> | ||
| /// This uses the CRTP pattern to allow the individual builder methods to return instances of the derived builder | ||
| /// type. | ||
| /// </remarks> | ||
| /// </summary> | ||
| public class BaseBuilder<TBuilder> where TBuilder : BaseBuilder<TBuilder> | ||
| { | ||
| private const string DefaultOtlpEndpoint = "https://otel.observability.app.launchdarkly.com:4318"; | ||
| private const string DefaultBackendUrl = "https://pub.observability.app.launchdarkly.com"; | ||
| private string _otlpEndpoint = DefaultOtlpEndpoint; | ||
| private string _backendUrl = DefaultBackendUrl; | ||
| private string _serviceName = string.Empty; | ||
| private string _environment = string.Empty; | ||
| private string _serviceVersion = string.Empty; | ||
|
|
||
| protected BaseBuilder() | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set the OTLP endpoint. | ||
| /// <para> | ||
| /// For most configurations, the OTLP endpoint will not need to be set. | ||
| /// </para> | ||
| /// <para> | ||
| /// Setting the endpoint to null will reset the builder value to the default. | ||
| /// </para> | ||
| /// </summary> | ||
| /// <param name="otlpEndpoint">The OTLP exporter endpoint URL.</param> | ||
| /// <returns>A reference to this builder.</returns> | ||
| public TBuilder WithOtlpEndpoint(string otlpEndpoint) | ||
| { | ||
| _otlpEndpoint = otlpEndpoint ?? DefaultOtlpEndpoint; | ||
| return (TBuilder)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set the back-end URL for non-telemetry operations. | ||
| /// <para> | ||
| /// For most configurations, the backend url will not need to be set. | ||
| /// </para> | ||
| /// <para> | ||
| /// Setting the url to null will reset the builder value to the default. | ||
| /// </para> | ||
| /// </summary> | ||
| /// <param name="backendUrl">The back-end URL used for non-telemetry operations.</param> | ||
| /// <returns>A reference to this builder.</returns> | ||
| public TBuilder WithBackendUrl(string backendUrl) | ||
| { | ||
| _backendUrl = backendUrl ?? DefaultBackendUrl; | ||
| return (TBuilder)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set the service name. | ||
| /// </summary> | ||
| /// <param name="serviceName">The logical service name used in telemetry resource attributes.</param> | ||
| /// <returns>A reference to this builder.</returns> | ||
| public TBuilder WithServiceName(string serviceName) | ||
| { | ||
| _serviceName = serviceName ?? string.Empty; | ||
| return (TBuilder)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set the service version. | ||
| /// </summary> | ||
| /// <param name="serviceVersion"> | ||
| /// The version of the service that will be added to resource attributes when a service name is provided. | ||
| /// </param> | ||
| /// <returns>A reference to this builder.</returns> | ||
| public TBuilder WithServiceVersion(string serviceVersion) | ||
| { | ||
| _serviceVersion = serviceVersion ?? string.Empty; | ||
| return (TBuilder)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Set the environment name. | ||
| /// </summary> | ||
| /// <param name="environment">The environment name (for example, "prod" or "staging").</param> | ||
| /// <returns>A reference to this builder.</returns> | ||
| public TBuilder WithEnvironment(string environment) | ||
| { | ||
| _environment = environment ?? string.Empty; | ||
| return (TBuilder)this; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Build an immutable <see cref="ObservabilityConfig"/> instance. | ||
| /// </summary> | ||
| /// <returns>The constructed <see cref="ObservabilityConfig"/>.</returns> | ||
| internal ObservabilityConfig BuildConfig(string sdkKey) | ||
| { | ||
| if (sdkKey == null) | ||
| { | ||
| throw new ArgumentNullException(nameof(sdkKey), | ||
| "SDK key cannot be null when creating an ObservabilityConfig builder."); | ||
| } | ||
|
|
||
| return new ObservabilityConfig( | ||
| _otlpEndpoint, | ||
| _backendUrl, | ||
| _serviceName, | ||
| _environment, | ||
| _serviceVersion, | ||
| sdkKey); | ||
| } | ||
| } | ||
| } |
7 changes: 0 additions & 7 deletions
7
sdk/@launchdarkly/observability-dotnet/src/LaunchDarkly.Observability/Class1.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.