Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add settings for OpenTelemetry export #2922

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Oct 30, 2024

Describe your changes

Add environment settings to input OpenTelemetry endpoint and headers
Screenshot 2024-10-30 at 13 22 26

Note:

  • an empty endpoint is considered as disabled. I don't think adding an extra checkmark is actually useful
  • The OpenTelemetry feature is only enabled for enterprise setup or via feature flag. I was thinking I would hide the settings if not enabled but I think it is nice to promote the feature even if not enabled. Editing the settings would show OpenTelemetry export is not enabled for this account error. I am happy to also make a mention of it being a paid feature in the environment setting page. Let me know @bastienbeurier

Checklist before requesting a review (skip if just adding/editing APIs & templates)

  • I added tests, otherwise the reason is:
  • I added observability, otherwise the reason is:
  • I added analytics, otherwise the reason is:

Copy link

linear bot commented Oct 30, 2024

@@ -118,6 +124,9 @@ export const EnvironmentSettings: React.FC = () => {
setSlackConnectedChannel(slack_notifications_channel);

setEnvVariables(env_variables);

setOtlpEndpoint(environment.otlp_settings?.endpoint || '');
setOtlpHeaders(environment.otlp_settings?.headers || {});
Copy link
Collaborator Author

@TBonnin TBonnin Oct 30, 2024

Choose a reason for hiding this comment

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

caveat: headers are reordered by key automatically. I didn't want to make the model and code more complicated for such a tiny feature and the fact that in most case there will be only 1 header max

Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

few open questions

@@ -0,0 +1,53 @@
import { z } from 'zod';
Copy link
Collaborator

Choose a reason for hiding this comment

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

having one endpoint per setting is a bit insane imo
what do you think of taking this opportunity to create a generic endpoint (that only accepts otlp for now)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is a bit insane. I also think the design is now overwhelming with all those options and I would vote for not only a endpoints refactor but a UI redesign as well. cc @bastienbeurier
I would prefer to push this otlp export feature to completion though and not go into a refactor at this point.

@@ -336,6 +336,10 @@ class EnvironmentService {
return db.knex.from<DBEnvironment>(TABLE).where({ id }).update({ hmac_key: hmacKey }, ['id']);
}

async editOtlpSettings(environmentId: number, otlpSettings: { endpoint: string; headers: Record<string, string> } | null): Promise<DBEnvironment | null> {
return db.knex.from<DBEnvironment>(TABLE).where({ id: environmentId }).update({ otlp_settings: otlpSettings }, ['id']);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same for this, there are 20 update functions while only need one that does this

await db.knex.from<DBEnvironment>(TABLE).where({ id: environmentId }).update(updatedEnv);

</form>
</div>
)}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to have an example in the tooltip or better in the placeholder of the input

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point. will do


const bodyValidation = z
.object({
endpoint: z.string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it a URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. good point

if (isEnterprise) {
return true;
}
return featureFlags.isEnabled('feature:otlp:account', account.uuid, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about self hosted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is supposed to be a scale plan only feature so they can only be enterprise or cloud. Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it shouldn't be shown in the UI then

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. Just check with @bastienbeurier though and we decided to keep it as is for now (aka: failing unless enterprise or cloud with flag enabled) and improve it when making the design of this page better

@TBonnin TBonnin force-pushed the tbonnin/nan-1976/otlp-settings branch from 282156a to 54281fa Compare October 31, 2024 14:39
@bodinsamuel
Copy link
Collaborator

let me know when you need a second review

@TBonnin TBonnin requested a review from bodinsamuel November 1, 2024 13:32
@TBonnin
Copy link
Collaborator Author

TBonnin commented Nov 1, 2024

@bodinsamuel fixed the zod schema and the endpoint placeholder.
The rest (multiple edit endpoints and functions, ux, etc...) will be improved/refactored later.

@TBonnin TBonnin force-pushed the tbonnin/nan-1976/otlp-settings branch from 54281fa to 492011f Compare November 1, 2024 13:34
@TBonnin TBonnin force-pushed the tbonnin/nan-1976/otlp-settings branch from 492011f to 688c735 Compare November 4, 2024 13:29
@TBonnin TBonnin merged commit f62f0d0 into master Nov 4, 2024
21 checks passed
@TBonnin TBonnin deleted the tbonnin/nan-1976/otlp-settings branch November 4, 2024 13:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants